var rotater = true;

$(document).ready(
	function()
	{
		bindNieuwsHome();
		rotater = setTimeout("rotate()", 5000);
		checkLinks();
	}
);



function checkLinks()
{
	$("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 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);
}