$(document).ready(function(){

	var headline_count;
	var headline_interval;
	var old_headline = 0;
	var current_headline = 0;

	$(document).ready(function()
	{
		headline_count = $("div.interface-news-item").size();
		$("div.interface-news-item:eq("+current_headline+")").css('left','-925px');

		headline_interval = setInterval(headline_rotate,5000); //time in milliseconds
		$('#interface-news').hover(function()
		{
			$(this).css('font-weight','bold');
			clearInterval(headline_interval);
		},
		function()
		{
		  headline_interval = setInterval(headline_rotate,5000); //time in milliseconds
		  headline_rotate();
		  $(this).css('font-weight','100');
		});
	});

	function headline_rotate()
	{
	  current_headline = (old_headline + 1) % headline_count;
	  $("div.interface-news-item:eq(" + old_headline + ") > a").css('color','#4c4d4e');
	  $("div.interface-news-item:eq(" + old_headline + ")").animate({left: -1860},"slow", function()
	  {
	  	$(this).css('left','5px');
	  });
	  $("div.interface-news-item:eq(" + current_headline + ") > a").css('color','#4c4d4e');
	  $("div.interface-news-item:eq(" + current_headline + ")").show().animate({left: -925},"slow");
	  old_headline = current_headline;
	}

	$("a.fancybox").fancybox({
		'overlayOpacity'	:	0.85,
		'overlayColor'		:	'#000'
	});

	$(".interface-faq-list li a.faq-category").toggle(function(){
		$(this).css("color","#FFF");
		}, function () {
		$(this).css("color","#87888A");;
	});

	$('.interface-faq-list li a.faq-category').click(function() {
		$(this).next().slideToggle('fast');
		return false;
	}).next().hide();

	/* Video player*/

	var portal_video = document.getElementById('portal_video');
	var lelystad = ($('.location-1').length);
	var zeewolde = ($('.location-2').length);
	var almere = ($('.location-4').length);
	var tilburg = ($('.location-5').length);
	var uithoorn = ($('.location-6').length);

	if(portal_video)
	{
		var so = new SWFObject('/ENGINE/MOVIES/GARAGEPARK/WEBSITE/player-viral.swf','mpl','615','340','9');
		so.addParam('allowfullscreen','true');
		so.addParam('allowscriptaccess','always');
		so.addParam('wmode','opaque');
		so.addParam('menu', 'false');
		so.addVariable('file','/ENGINE/MOVIES/GARAGEPARK/WEBSITE/portal_video.flv');
		so.addVariable('image','/ENGINE/IMAGES/GARAGEPARK/WEBSITE/portal_video_teaser.jpg');
  		so.addVariable('controlbar','bottom');
  		so.addVariable("autostart","true");
		so.write('portal_video');
	}

	if(lelystad)
	{
		var so = new SWFObject('/ENGINE/MOVIES/GARAGEPARK/WEBSITE/player-viral.swf','mpl','448','270','9');
		so.addParam('allowfullscreen','true');
		so.addParam('allowscriptaccess','always');
		so.addParam('wmode','opaque');
		so.addParam('menu', 'false');
		so.addVariable('file','/ENGINE/MOVIES/GARAGEPARK/WEBSITE/lelystad/lelystad.flv');
  		so.addVariable('controlbar','bottom');
		so.addVariable('image','/ENGINE/IMAGES/GARAGEPARK/WEBSITE/film_lelystad.jpg');
		so.write('interface-department-movie');

	}

	if(zeewolde)
	{
		var so = new SWFObject('/ENGINE/MOVIES/GARAGEPARK/WEBSITE/player-viral.swf','mpl','448','270','9');
		so.addParam('allowfullscreen','true');
		so.addParam('allowscriptaccess','always');
		so.addParam('wmode','opaque');
		so.addParam('menu', 'false');
		so.addVariable('file','/ENGINE/MOVIES/GARAGEPARK/WEBSITE/zeewolde/zeewolde.flv');
  		so.addVariable('controlbar','bottom');
  		so.addVariable('image','/ENGINE/IMAGES/GARAGEPARK/WEBSITE/film_zeewolde.jpg');
		so.write('interface-department-movie');
	}

	if(almere)
	{
		var so = new SWFObject('/ENGINE/MOVIES/GARAGEPARK/WEBSITE/player-viral.swf','mpl','448','270','9');
		so.addParam('allowfullscreen','true');
		so.addParam('allowscriptaccess','always');
		so.addParam('wmode','opaque');
		so.addParam('menu', 'false');
		so.addVariable('file','/ENGINE/MOVIES/GARAGEPARK/WEBSITE/almere/almere.flv');
  		so.addVariable('controlbar','bottom');
		so.addVariable('image','/ENGINE/IMAGES/GARAGEPARK/WEBSITE/film_almere.jpg');
		so.write('interface-department-movie');
	}

	if(tilburg)
	{
		var so = new SWFObject('/ENGINE/MOVIES/GARAGEPARK/WEBSITE/player-viral.swf','mpl','448','270','9');
		so.addParam('allowfullscreen','true');
		so.addParam('allowscriptaccess','always');
		so.addParam('wmode','opaque');
		so.addParam('menu', 'false');
		so.addVariable('file','/ENGINE/MOVIES/GARAGEPARK/WEBSITE/tilburg/tilburg.flv');
  		so.addVariable('controlbar','bottom');
		so.addVariable('image','/ENGINE/IMAGES/GARAGEPARK/WEBSITE/film_tilburg.jpg');
		so.write('interface-department-movie');
	}
	
	if(uithoorn)
	{
		var so = new SWFObject('/ENGINE/MOVIES/GARAGEPARK/WEBSITE/player-viral.swf','mpl','448','270','9');
		so.addParam('allowfullscreen','true');
		so.addParam('allowscriptaccess','always');
		so.addParam('wmode','opaque');
		so.addParam('menu', 'false');
		so.addVariable('file','/ENGINE/MOVIES/GARAGEPARK/WEBSITE/uithoorn/uithoorn.flv');
  		so.addVariable('controlbar','bottom');
		so.addVariable('image','/ENGINE/IMAGES/GARAGEPARK/WEBSITE/film_uithoorn.jpg');
		so.write('interface-department-movie');
	}	

	$('#department-txt-normal').show();

	// Menu met of zonder webcams
	if(zeewolde)
	{
		$('.menu-content-department-bottom').remove();
		$('.menu-content-department-cam').show();
	}
	else
	{
		$('.menu-content-department-cam').remove();
		$('.menu-content-department-bottom').show();
	}

	$('#webcam-location-2').click(function()
	{
		$('#interface-department-movie').hide();
		$('#interface-department-webcam').show();
	});

	$('#interface-content-webcam-close').click(function()
	{
		$('#interface-department-webcam').hide();
		$('#interface-department-movie').show();
	});

   	$('#interface-overlay-close').click(function()
    {
    	$('#overlay').hide();
    	$('#interface-overlay').fadeOut('fast');
    });

    $('.menu-content-department > li > a').hover(function()
    {
     	$(this).css('color','#000');
    },
    function()
    {
    	$(this).css('color','#FFF');
    });

    $('#setGoogleMapsByLocation').click(function()
    {
    	if(!$("#overlay").length)
    	{
    		var docHeight = $(document.body).height();
    		$("body").append("<div id='overlay'></div>");
    		$("#overlay").height(docHeight).css({'opacity' : 0.6, 'position': 'absolute', 'top': 0, 'left': 0, 'background-color': 'black','width': '100%','z-index': '99'});
    	}
    	else
    	{
    		$("#overlay").show();
    	}

    	if(lelystad)
    		$('#interface-overlay-googlemaps-inside').html('<iframe width="450" height="450" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://www.garagepark.nl/GOOGLEMAPS/lelystad.html"></iframe>');

    	if(zeewolde)
    		$('#interface-overlay-googlemaps-inside').html('<iframe width="450" height="450" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://www.garagepark.nl/GOOGLEMAPS/zeewolde.html"></iframe>');

    	if(almere)
    	   $('#interface-overlay-googlemaps-inside').html('<iframe id="iframe_garagepark" width="450" height="450" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://www.garagepark.nl/GOOGLEMAPS/almere.html"></iframe>');

    	if(tilburg)
    	   $('#interface-overlay-googlemaps-inside').html('<iframe id="iframe_garagepark" width="450" height="450" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://www.garagepark.nl/GOOGLEMAPS/tilburg.html"></iframe>');

    	if(uithoorn)
    	   $('#interface-overlay-googlemaps-inside').html('<iframe id="iframe_garagepark" width="450" height="450" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://www.garagepark.nl/GOOGLEMAPS/uithoorn.html"></iframe>');

    	$('#interface-overlay-googlemaps').fadeIn('fast');
    })


    $('#interface-overlay-close-google').click(function()
    {
    	$("#overlay").hide();
    	$('#interface-overlay-googlemaps').fadeOut('fast');
    });

	$('#interface-almereBig-close').click(function()
	{
		$("#overlay").hide();
		$('#interface-almereBig').hide();
	});

	var times = ($('#interface-times').length);

	if(times)
	{
		timeExpand($('#interface-times'));	
	}	

	$('.interface-times-close').click(function()
	{
		$('#interface-times').animate({opacity:"hide"},600);;	
	})

});

function timeExpand(element_o)
{
	element_o.animate({opacity:"show"},600);
}