$(document).ready(function(){
	var delay=200000;
	$("#hdr_news1").mouseover(function () {
		showItem(1);
	});
	$("#hdr_news2").mouseover(function () {
		showItem(2);
	});
	$("#hdr_news3").mouseover(function () {
		showItem(3);
	});
	$("#hdr_news4").mouseover(function () {
		showItem(4);
	});
	
    $("#caroussel").bind("mouseenter",function(){
            clearTimeout(rotate_timer);
        }).bind("mouseleave",function(){
        timer_no=curr_no;
        var media=$("#hdr_news"+curr_no).attr("media");
        if(media!="video"){
            autoRotate();
        }
    });
    
	autoRotate();
});

var curr_no=1;
var timer_no=1;
var rotate_timer="";
var timer=4000;

function showItem(no){
	if(curr_no!=no){
		resetItems();
		$("#caroussel_items").css("backgroundImage","url('./assets/images/newsflash/bg_active_"+no+".jpg')");
		$("#news_image_"+no).fadeIn();
		t=50+(no*58)-58;
		$("#arrow_news").css("top",t+"px");
		$("#hdr_news"+no).css("height","83px");
		$("#hdr_news"+no).children().removeClass();

		$("#hdr_news"+no).children("#black").addClass("hdr_news_big_black");
		$("#hdr_news"+no).children("#white").addClass("hdr_news_big_white");
		curr_no=no;
	}
}

function resetItems(){
	$("#news_image_"+curr_no).fadeOut();
	$("#hdr_news"+curr_no).css("height","83px");
	$("#hdr_news"+curr_no).children().removeClass();
	$("#hdr_news"+curr_no).children("#black").addClass("hdr_news_small_black");
	$("#hdr_news"+curr_no).children("#white").addClass("hdr_news_small_white");
}

function autoRotate(){
	showItem(timer_no);
	timer_no++;
	if(timer_no>4){
		timer_no=1;
	}
	rotate_timer=setTimeout("autoRotate()",timer);
}

