$(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");
        if(media!="video"){
            autoRotate();
        }
    });
    
    $("#tab_next_match").click(function(){
		$("#tab_next_match").css("background","none");
		$("#tab_score").css("background","url(/static/project/images/tab_home_red_stand.gif)");
		$("#content_next_match").show();
		$("#content_score").hide();
	});

	$("#tab_score").click(function(){
		$("#tab_next_match").css("background","url(/static/project/images/tab_home_red_volgendewedstrijd.gif)");
		$("#tab_score").css("background","none");
		$("#content_next_match").hide();
		$("#content_score").show();
	});
	
	$("#foto_player_thumb1,#foto_player_thumb2,#foto_player_thumb3,#foto_player_thumb4").click(function () {
		no=$(this).attr('no');
		big_picture=$(this).attr('big_picture');
		$(".foto_player_thumb").show();
		$(this).hide();
		$(".foto_player_label").hide();
		$("#foto_player_label"+no).show();
		
		$("#foto_player").hide();
		$("#foto_player").attr("src",big_picture);
		$("#foto_player").fadeIn();
	});
		
	$("#video_player_thumb1,#video_player_thumb2,#video_player_thumb3,#video_player_thumb4").click(function () {
		no=$(this).attr('no');
		//big_picture=$(this).attr('big_picture');
		
		$(".video_player_thumb").show();
		$(this).hide();
		
		$(".video_player_label").hide();
		$("#video_player_label"+no).show();
		
		$(".video_player").hide();
		$("#video_player"+no).show();
		
		
		//$("#video_player").attr("src",big_picture);
		//$("#video_player").fadeIn();
	});
	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://pixector.com/hiphop/wp-content/themes/hiphop/images/bg_tab"+no+"_act.png')");
		$("#news_image_"+no).fadeIn();
		t=50+(no*58)-58;
		$("#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();
	$("#hdr_news"+curr_no).css("height","57px");
	$("#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);
}

