/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

// JavaScript Document
var news_index = 0;
var news_fading = true;
var news_mouseon = false;

jQuery(function(){
	jQuery(".news").hide();
	jQuery(".news").each(function(index, domElement) {
			jQuery(this).bind("mouseenter", index, enterBtn);
			jQuery(this).bind("mouseleave", index, leaveBtn);
		});
	jQuery(".news:eq(" + news_index + ")").fadeIn(2000, function(){
			news_fading = false;
	   });

	setTimeout("checkNews()", 5000);
});

function enterBtn(ev)
{
	news_mouseon = true;
	jQuery(".news:visible").addClass("news_on");
}

function leaveBtn(ev)
{
	news_mouseon = false;
	jQuery(".news:visible").removeClass("news_on");
}

function checkNews()
{
	if (!news_mouseon)
	{
		news_index++;

		if (news_index == jQuery(".news").length)
			news_index = 0;

		fading = true;
		jQuery(".news:visible").fadeOut("fast", function(){
				jQuery(".news:eq(" + news_index + ")").fadeIn("slow", function(){
						fading = false;
						setTimeout("checkNews()", 5000);
				   });
			});
	}
	else
		setTimeout("checkNews()", 5000);
}

