$(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);
	});
	$("#hdr_news5").mouseover(function () {
		showItem(5);
	});
	
    $("#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=5000;

function showItem(no){
	if(curr_no!=no){
		resetItems();
		$("#caroussel_items").css("backgroundImage","url('http://www.vvzonline.nl/Images/Carousel/bg_tab"+no+"_act.png')");
		$("#news_image_"+no).fadeIn();
		$("#news_text_"+no).fadeIn();
		t=50+(no*37)-37;
		$("#arrow_news").css("top",t+"px");
		$("#hdr_news"+no).css("height","140px");
		$("#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();
	$("#news_text_"+curr_no).fadeOut();
	$("#hdr_news"+curr_no).css("height","35px");
	$("#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>5){
		timer_no=1;
	}
	rotate_timer=setTimeout("autoRotate()",timer);
}
function stopRotate(){
	if(typeof rotateTimer != 'undefined'){
		clearTimeout(rotate_timer);
	}
}