$(document).ready(function(){
	var delay=300;
	$("#hdr_news1").mouseover(function () {
		showItem(1);
	});
	$("#hdr_news2").mouseover(function () {
		showItem(2);
	});
	$("#hdr_news3").mouseover(function () {
		showItem(3);
	});
	
    $("#caroussel").bind("mouseenter",function(){
            clearTimeout(rotate_timer);
        }).bind("mouseleave",function(){
        timer_no=curr_no;
            autoRotate();
    });
});

var curr_no=1;
var timer_no=1;
var rotate_timer="";
var timer=5000;

function showItem(no){
	if(curr_no!=no){
		resetItems();
		$("#caroussel_items").css("backgroundImage","url('/static/project/images/bg_tab"+no+"_act.png')");
		$("#news_image_"+no).fadeIn();
		t=50+(no*58)-58;
		$("#hdr_news"+no).css("background","url(/images/top-left-navigation-sel.png) center right no-repeat");
		$("#hdr_news"+no).children().removeClass();
		curr_no=no;
	}
}



function resetItems(){
	$("#news_image_"+curr_no).fadeOut();
	$("#hdr_news"+curr_no).css("background","none");
	$("#hdr_news"+curr_no).children().removeClass();
}


function autoRotate(){
	showItem(timer_no);
	timer_no++;
	if(timer_no>3){
		timer_no=1;
	}
	rotate_timer=setTimeout("autoRotate()",timer);
}
