jQuery(document).ready(function($)
{
	if (PluginDetect.getVersion("QuickTime"))
	{ 
	  	$("#film_gal li a").each(function(){
	  		newhref = 'qtime.php?mov=' + $(this).attr('href').split("=")[1];
	  		$(this).attr('href', newhref);
	  	});
	}
	$('a.play img').css('opacity',0.6);
	$('a.play img').hover(function() {
		$(this).css('opacity',0.9);
	},function() {
		$(this).css('opacity',0.6);
	});
	
	$(".fancyimg").fancybox();
	$(".fancy").fancybox({ 
		'hideOnContentClick': false, 
		'speedIn'		: 400, 
		'speedOut'		: 200, 
		'width'			: 700,
		'height'		: 530,
		'autoScale'		: true,
		'overlayShow'	: true, 
		'overlayOpacity': 0.75,
		'type'			: 'iframe',
		'scrolling'      : 'no'
	});	
	
	if ($("#intro").length > 0) {
		intro();
	} 
});

function intro() {
	if (document.referrer.indexOf('martenaukes.nl') == -1){
		$('#intro img').css({"opacity": 0});
		$('#intro .flits').attr('src','/site_images/flits.png');
	
		$('.introEl').each(function(n) {
	    	$(this).flitser();
		});
	} else {
		$("#intro").remove();
	}
};

var cnt = 0;
jQuery.fn.flitser = function() {
	cnt++;
	var duration = 1250;
	var tarflits = this.find('.flits');
	
	imgtag = '#img'+cnt;
	$(imgtag).delay(cnt * duration + 280).addClass('frame').animate({opacity:1},2250,'easeOutBack');
	tarflits.css({'width':0, 'height':0})
	.delay(cnt * duration).animate({width:'540px', height:'500px', opacity:1}
		,220 , 'easeOutBack'
	,function() {
		tarflits.animate({opacity:0},100);
		if (cnt == 3) {
    	  $("#intro")
    	  	.delay((cnt+1) * duration)
    	  	.animate({opacity:0, display:'none'}
    	  	,2000, 'easeInOutCubic'
    	  	,function() {
    	  		$("#intro").remove();
    	  	});
    	}
	});
};
