/* Photobook thumb hover
----------------------------------------------------------------------*/
$(function() {
	$(".overlay").hover(function()
	{
		$(this).addClass("active");
	},
	function() 
	{
		$(this).removeClass("active");
	});
});

$(function() {
	$(".layers").hover(function()
	{
		$(".overlay.active").hide();
	},
	function()
	{
		$(".overlay").show();
	});
});



/* Employee picture
----------------------------------------------------------------------*/
$(function() {
	$(".names li").hover(function() 
	{
    	$(this).addClass("hover");
	},
  	function() 
	{
		$(this).removeClass("hover");
	});

    // Geef alle buttons een click functie om alle info te tonen
    for($i = 0; $i <= 20; $i++)
    {
   		$("#"+$i).click(function()
   		{
	 	    // check de current, en zet deze eerst eens even uit.
			$nummer = $(this).attr("id");
			$(".popup.current").fadeOut("fast", function()
			{
				$(this).removeClass("current");
				$naam = "event_"+$nummer;
				$("#event_"+$nummer).fadeIn("slow");
	    		$("#event_"+$nummer).addClass("current");
	    		$("#popup_"+$nummer).fadeIn("slow", function()
	    		{
	    			$("#popup_"+$nummer).attr({style:""}).css({display: "block"});
	    		});
				$("#popup_"+$nummer).addClass("current");
	    	});
	    	$(".event.current").fadeOut("fast", function()
	    	{
				$(this).removeClass("current");
				$naam = "event_"+$nummer;
				$("#event_"+$nummer).fadeIn("slow");
	    		$("#event_"+$nummer).addClass("current");
	    		$("#popup_"+$nummer).fadeIn("slow", function()
	    		{
	    			$("#popup_"+$nummer).attr({style:""}).css({display: "block"});
	    		});
				$("#popup_"+$nummer).addClass("current");
	    	});    	
	   	})
	}
    // Toon eerste afbeelding
    $("#event_1").fadeIn("slow");
    $("#event_1").addClass("current");
    $("#popup_1").fadeIn("slow", function()
    {
		$("#popup_1").attr({style:""}).css({display: "block"});
    });
    $("#popup_1").addClass("current");

});



/* Directions
----------------------------------------------------------------------*/
$(function () {
/*	var directie = [ "rotterdam", "gorinchem", "breda" ]; */
	for($i = 0; $i <= 2; $i++)
	{
		$("#rotterdam,#gorinchem,#breda").click(function()
		{
			// check de juiste route
	    	$route = $(this).attr("id");
	    	/*alert ("#route_"+$route);*/	    	
			$(".route.current").fadeOut('fast', function()
			{
				$(this).removeClass("current");
				$("#route_"+$route).fadeIn('slow', function()
				{
					$(this).attr({style:""}).css({display: "block"});
					$(this).addClass('current');
										
				});
			});	   
		});		
		$("#rotterdam,#gorinchem,#breda").hover(function()
		{
			$(this).addClass('hover');
		},
		function() 
		{
			$(this).removeClass('hover');
		});
	}
	// Toon eerste route
	$('#route_rotterdam').fadeIn('slow', function() {
		//$(this).attr({style:""}).css({display: "block"});
	});
	$("#route_rotterdam").addClass('current');

});

/* Directions
----------------------------------------------------------------------*/
$(function() {
	$(".img-swap").hover(function()
	{
		this.src = this.src.replace("_off","_on");
	},
	function()
	{
		this.src = this.src.replace("_on","_off");
	});
});

/* Fancybox
----------------------------------------------------------------------*/
$(function() {
	/* Apply fancybox to multiple items */
	
	$("a.group").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'showCloseButton' : true,
		'speedIn'		:	600, 
		'type'			:	'iframe',
		'speedOut'		:	200, 
		'width'			:	800,
		'height'		: 	450,
		'scrolling'		: 	'no',
		'padding'		:	0,
		'autoScale'		:	true,
		'overlayShow'	:	true,
		'overlayColor'	:	'#333',
		'overlayOpacity' :	0.9,
		'hideOnContentClick' : true,
		'hideOnOverlayClick' : true
	});
});

$(function() {
	/* Apply fancybox to multiple items */
	
	$("a[rel=group]").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'showCloseButton' : true,
		'speedIn'		:	600, 
		'type'			:	'image',
		'speedOut'		:	200, 
		'width'			:	700,
		'height'		: 	450,
		'padding'		:	0,		
		'scrolling'		: 	'no',
		'autoScale'		:	true,
		'overlayShow'	:	true,
		'overlayColor'	:	'#333',
		'overlayOpacity' :	0.9,
		'hideOnContentClick' : true,
		'hideOnOverlayClick' : true
	});
	
	$(".slideshow_afbeelding").click(function()
	{
		//alert($(this).attr('src'));
		$.fancybox({
			'transitionIn'	:	'elastic',
			'transitionOut'	:	'elastic',
			'showCloseButton' : true,
			'speedIn'		:	600, 
			'type'			:	'image',
			'speedOut'		:	200, 
			'width'			:	700,
			'height'		: 	466,
			'padding'		:	0,
			'href'			:	this.src,	
			'cyclic'		: 	true,
			'scrolling'		: 	'no',
			'autoScale'		:	true,
			'overlayShow'	:	true,
			'rel'			:	'gallery',
			'overlayColor'	:	'#333',
			'overlayOpacity' :	0.9,
			'hideOnContentClick' : true,
			'hideOnOverlayClick' : true
		});
	});
});

/* Projects picture
----------------------------------------------------------------------*/
$(function() {

	$("#projects_more").hide();

	$("#projects_readmore").click(function() 
	{
		$("#projects_intro").fadeOut(function() 
		{
			$("#projects_more").fadeIn(function()
			{
				$("#projects_more").attr({style:""}).css({display: "block"});;
			});
		});
	});
	
	$("#projects_readless").click(function() 
	{
		$("#projects_more").fadeOut(function() 
		{
			$("#projects_intro").fadeIn(function()
			{
				$("#projects_intro").attr({style:""}).css({display: "block"});;
			});
		});
	});
	
   	$('.slideshow_afbeelding').hide();   

    
    // Geef alle buttons een click functie om alle info te tonen
    for($i = 0; $i <= 20; $i++)
    {
		$("#"+$i).click(function() 
		{	// check de current, en zet deze eerst eens even uit.
			$nummer = $(this).attr("id");
	    	
	    	$(".picholder_projects .current").fadeOut("fast", function() 
	    	{
				$(this).removeClass("current");
				$("#afb_"+$nummer).fadeIn("slow");
	    		$("#afb_"+$nummer).addClass("current");
	    		
	    		// Als slideshow bezig is, ook daar alles van stoppen
	    		playcount= 0;
				clearInterval(playSlideshow);
				
				$("#pauseButton").hide();
				$("#playButton").show();
    		});
    	})
    }
    // Toon eerste afbeelding
    $("#afb_0").fadeIn();
    $("#afb_0").addClass("current");
		//$("#afb_0").addClass('last-active');
});

function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next = $active.next().length ? $active.next() : $('#slideshow IMG:first');

    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );

    $active.addClass('last-active');
	
	//$next.fadeOut("fast", function(){
	
	//}
	$next.fadeIn("slow", function()
	{

	});
	$next.css({opacity: 0.0})
		.addClass('active')
        .addClass("current")
        .animate({opacity: 1.0}, 1000, function() 
        {
        	$active.removeClass('active last-active');
		});
   	if(playcount == 0)
   	{
   		playSlideshow = setInterval( "slideSwitch()", 4000 );
   		playcount++
   	}
}

var playSlideshow = setInterval("slideSwitch()", 5000 );
var playcount = 0;
clearInterval(playSlideshow);

$("#pauseButton").hide();

$(function() {
	$("#pauseButton").click(function()
	{
		playcount= 0;
		clearInterval(playSlideshow);
		$("#pauseButton").hide();
		$("#playButton").show();
	});
	$("#playButton").click(function()
	{
		$('.slideshow_afbeelding').removeClass('active last-active');
		slideSwitch();
		$("#playButton").hide();
		$("#pauseButton").show();
	});
});


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
