var activeNewsItemIndex=-1;
var numNewsItems;
var displaySeconds=5;
var newsaktiv;

$(document).ready
(
	function() 
	{
		//alert("dbug");
		nextNewsItem();

		$("#nextnews").click
		(
			function(event)
			{
				event.preventDefault();
				//$("#debugwin").html(""+activeNewsItemIndex);
				nextNewsItem();
				this.blur();
			}
		);

		$("#prevnews").click
		(
			function(event)
			{
				event.preventDefault();

				activeNewsItemIndex-=2;
				if( activeNewsItemIndex < 0 )
					activeNewsItemIndex = ($(".newsitem").length)+activeNewsItemIndex;
				
				//$("#debugwin").html(""+activeNewsItemIndex);
				nextNewsItem();
				this.blur();
			}
		);

		$(".newsWidget").mouseover(function()
		{
			//alert("hello");
			//window.clearTimeout(newsaktiv);
		})
		$(".newsWidget").mouseout(function()
		{
			//alert("hello");
			//newsaktiv = window.setTimeout("nextNewsItem()", (displaySeconds * 1000));
		})
	}
);

function nextNewsItem()
{
	window.clearTimeout(newsaktiv);

	numNewsItems = $(".newsitem").length

	$(".newsitem:visible").each
	(
		function(intIndex)
		{
			//$(this).slideUp();
			$(this).hide();
		}
	);
	
	activeNewsItemIndex++;
	if( (activeNewsItemIndex+1) > numNewsItems )
		activeNewsItemIndex = 0;
	
	//$("#debugwin").html(activeNewsItemIndex);

	$(".newsitem").each
		(
			function(intIndex)
			{
				//$(this).slideUp();
				//$(this).fadeOut();
				if( intIndex == activeNewsItemIndex )
				{
					//$(this).slideDown();
					$(this).fadeIn("fast");
				}
			}
		);
	newsaktiv = window.setTimeout("nextNewsItem()", (displaySeconds * 1000));
}