var CURIMAGE = 0;

var rotater = true;



$(document).ready(

	function()

	{
		bindNieuwsHome();
		rotater = setTimeout("rotate()", 5000);

		if ($.browser.version.charAt(0) < 7 && $.browser.msie){$("#mainnav li").hover(function(){$(this).addClass('hover');},function(){$(this).removeClass('hover');});}
			setTimeout("bindHome()", 5000);
		checkLinks();
	}
);



function checkLinks()
{
	$("#layout-content a[href^=http]").each
	(
			function()
			{
				if(this.href.indexOf(location.hostname) == -1) 
				{ 
					$(this).attr('target', '_blank');
				}
			}
	);
	
	$("form[action^=http]").each
	(
			function()
			{
				if(this.action.indexOf(location.hostname) == -1) 
				{ 
					$(this).attr('target', '_blank');
				}
			}
	);
}



function bindHome()

{

	$(".gallery"+CURIMAGE).css('z-index', 10).fadeOut(2000);

	CURIMAGE++;

	if (CURIMAGE > 6)

	{

		CURIMAGE = 0;

	}

	$(".gallery"+CURIMAGE).css('z-index', 20).fadeIn(3000);



	setTimeout("bindHome()", 6000);

}



function bindNieuwsHome()

{

	$("#news-gallery-img img").attr("src", $("#news-gallery-list li.active img").attr("src"));

	

	$("#news-gallery-list li").hover(

		function()

		{

			clearTimeout(rotater);

			rotater = setTimeout("rotate()", 5000);	

			

			$("#news-gallery-list li.active").removeClass("active");

			$(this).addClass("active");

			

			

			$("#news-gallery-img img").attr("src", $("#news-gallery-list li.active img").attr("src"));

			$("#news-gallery-content a.list-title").text($("#news-gallery-list li.active a.news-list-title span.list-title-text").text());

			$("#news-gallery-content a.list-title").attr("href", $("#news-gallery-list li.active a.news-list-title").attr("href"));

			$("#news-gallery-content p").text($("#news-gallery-list li.active a.news-list-title span.list-content").text());

		}

	);

}



function rotate()

{

		var active = $("#news-gallery-list li.active");

		var next = active.next();

		

		if (next.length == 0)

		{

			next = $("#news-gallery-list li:first");

		}

		

		$("#news-gallery-list li.active").removeClass("active");

		next.addClass("active");

		

		$("#news-gallery-img img").attr("src", $("#news-gallery-list li.active img").attr("src"));

		$("#news-gallery-content a.list-title").text($("#news-gallery-list li.active a.news-list-title span.list-title-text").text());

		$("#news-gallery-content a.list-title").attr("href", $("#news-gallery-list li.active a.news-list-title").attr("href"));

		$("#news-gallery-content p").text($("#news-gallery-list li.active a.news-list-title span.list-content").text());

		

		rotater = setTimeout("rotate()", 5000);

}

