/*
 * Wietse Wind, iPublications
 */

isAtImage = 0;
PreloadImage = [];

function tNextImage(){
    NextImage = isAtImage + 1;
    if(NextImage > 8) NextImage = 0;
    if(PreloadImage[NextImage] !== false){
        PreloadImage[NextImage] = new Image();
        PreloadImage[NextImage].src = 'images/' + NextImage + '.jpg';
    }
    $("#image" + isAtImage).after('<img id="image' + NextImage + '" class="image" src="images/' + NextImage + '.jpg" style="display: none;" alt="" />');
    $(PreloadImage[NextImage]).load(function(){
        $("#image" + NextImage).fadeIn(2000, function(){
            $("#image" + isAtImage).remove();
            isAtImage = NextImage;
            setTimeout(function(){tNextImage();}, 10000);
        });
    });
}

function movie(nr,target){
    if(target > 0){
        canvas = 'content-fullscreen';
        x = 640;
        y = 364;
    }else{
        canvas = 'filmcanvas';
        x = 410;
        y = 236;
        $("#bibfs a").attr('href', 'film1.html?m=' + nr);
    }
    if(nr == 1){
        $("#" + canvas).html('<object width="' + x + '" height="' + y + '"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=4411462&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=e83949&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=4411462&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=e83949&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="' + x + '" height="' + y + '"></embed></object>');
    }
    if(nr == 2){
        $("#" + canvas).html('<object width="' + x + '" height="' + y + '"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=4411479&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=e83949&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=4411479&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=e83949&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="' + x + '" height="' + y + '"></embed></object>');
    }
    if(nr == 3){
        $("#" + canvas).html('<object width="' + x + '" height="' + y + '"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=4412384&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=e83949&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=4412384&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=e83949&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="' + x + '" height="' + y + '"></embed></object>');
    }
}

$(document).ready(function(){
    $("#mainh1").after('<img src="images/main-titel.png" class="png" border="0" height="57" width="477" style="behavior: url(iepngfix.htc);" />').remove();
    $("#mainh2").after('<img src="images/main-titel-film.png" class="png"  border="0" height="57" width="237" style="behavior: url(iepngfix.htc);" />').remove();
    $("#meerinfo").after('<img src="images/kijk_meer_info.png" class="png" height="55" width="398" border="0" style="behavior: url(iepngfix.htc);" />').remove();
    
    $("a.movie img").mouseover(function(){
        $(this).css({'border-color' : '#000'});    
    }).mouseout(function(){
        $(this).css({'border-color' : '#e04250'});    
    });
    
    $("#filmtags span").each(function(a){
        $(this).mouseover(function(){
            $("a.movie img:eq(" + a + ")").css({'border-color' : '#000'});
        }).mouseout(function(){
            $("a.movie img:eq(" + a + ")").css({'border-color' : '#e04250'});
        });
    });
    
    setTimeout(function(){tNextImage();}, 10000);
});
