$(document).ready(function(){
	var delay=300;

	$("#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");
    });
    
autoRotate();
});

var curr_no=1;
var timer_no=1;
var rotate_timer="";
var timer=5000;

function showItem(no){
	if(curr_no!=no){
		resetItems();
		$("#news_image_"+no).fadeIn();
		$("#hdr_news"+no).css("height","135px");
		$("#hdr_news"+no).css("width","145px");

		$("#hdr_news"+no).css("backgroundImage","url('" + jsServerpad + "img/bg_tabbig"+no+".png')");
		
		$("#hdr_news"+no).children().removeClass();
		$("#hdr_news"+no).children("div").addClass("big");

		if (no == 4) {
			$("#hdr_news1").css("width","145px")
			$("#hdr_news2").css("width","145px")
			$("#hdr_news3").css("width","145px")
			$("#hdr_news4").css("width","145px")
			$("#hdr_news4 .big a").css("width","145px")
			$("#hdr_news4 .big a").css("width","135px")
			$("#hdr_news4 .big a").css("display", "block")
		}
		
		if (no == 3) {
			$("#hdr_news1").css("width","145px")
			$("#hdr_news2").css("width","145px")
			$("#hdr_news3").css("width","145px")
			$("#hdr_news4").css("width","145px")
			$("#hdr_news3 .big a").css("width","145px")
			$("#hdr_news3 .big a").css("width","135px")
			$("#hdr_news3 .big a").css("display", "block")
		}

		if (no == 2) {
			$("#hdr_news1").css("width","145px")
			$("#hdr_news2").css("width","145px")
			$("#hdr_news3").css("width","145px")
			$("#hdr_news4").css("width","145px")
			$("#hdr_news2 .big a").css("width","145px")
			$("#hdr_news2 .big a").css("width","135px")
			$("#hdr_news2 .big a").css("display", "block")
		}
		
		if (no == 1) {
			$("#hdr_news1").css("width","145px")
			$("#hdr_news2").css("width","145px")
			$("#hdr_news3").css("width","145px")
			$("#hdr_news4").css("width","145px")
			$("#hdr_news1 .big a").css("width","145px")
			$("#hdr_news1 .big a").css("width","135px")
			$("#hdr_news1 .big a").css("display", "block")
		}

		curr_no=no;
	}
}

function resetItems(){
	$("#news_image_"+curr_no).fadeOut();
	$("#hdr_news"+curr_no).css("height","60px");
	$("#hdr_news"+curr_no).css("width","145px");
	$("#hdr_news"+curr_no).css("backgroundImage","url('" + jsServerpad + "img/bg_tabsmall"+curr_no+".png')");
	
	$("#hdr_news"+curr_no).children().removeClass();
	$("#hdr_news"+curr_no).children("div").addClass("small");
}

function autoRotate(){
	showItem(timer_no);
	timer_no++;
	if(timer_no>4){
		timer_no=1;
	}
	rotate_timer=setTimeout("autoRotate()",timer);
}
