var curr_menu="none";
var t;
var doso=true;

$(document).ready(function(){
	$(".top_menu_item_act").each(function() {
		var img_name=$(this).attr('id');
		$(this).parent().parent().css("padding","0px");
		$(this).html("<img src='/static/project/images/nav/"+img_name+"_act.gif' style='float:left;'>");
	});


	$(".top_menu_item").each(function() {
		var this_name=$(this).attr('id');
		$(this).parent().parent().css("padding","0px");
		$(this).html("<img src='/static/project/images/nav/"+this_name+".gif' class='hover' style='float:left;'>");
	});


	$(".main_menu_item_act").each(function() {
		var img_name=$(this).attr('id');
		$(this).parent().parent().css("padding","0px");
		$(this).html("<img src='/static/project/images/nav/"+img_name+"_act.gif' style='float:left;'>");
	});

	$(".main_menu_item").each(function() {
		var this_name=$(this).attr('id');
		$(this).parent().parent().css("padding","0px");
		$(this).html("<img src='/static/project/images/nav/"+this_name+".gif' id='main_menu_"+this_name+"' style='float:left;'>");
		$(this).parent().parent().bind("mouseenter",function(){
				t=setTimeout("showSubMenu('"+this_name+"')",200);
			}).bind("mouseleave",function(){
				hideSubMenu(this_name);
	    });

	});
	
	//$(".submenu:last").css('left-margin','-127px');
	
	$(".hover").hover(
		function () {
			dot=$(this).attr('src').lastIndexOf('.');
			name=$(this).attr('src').substring(0,dot);
			suffix=$(this).attr('src').substring(dot);
			$(this).attr({src : name+"_mo"+suffix});
		}, 
		function () {
			$(this).attr({src : name+suffix});
		}
	);

	$("#header_img").hover(
		function () {
			$("#photo_header").fadeOut();
			$("#bg_photo_header").fadeOut();
		}, 
		function () {
			$("#photo_header").fadeIn();
			$("#bg_photo_header").fadeIn();
		}
	);

	$(".tab_label").click(function(){
		this_id=$(this).attr('id');
		$(this).parent()
		showTab($(this).parent(),this_id);
	});

	$(".wedstrijden a").click(function(){ 
		doso=false;
	});
	
	$(".wedstrijden .small").click(function(){ 
		if(doso){
			$(this).hide();
			$(this).prev("tr").show();
		}
		doso=true;
	});

	$(".wedstrijden .big").click(function(){ 
		if(doso){
			$(this).hide();
			$(this).next("tr").show();
		}
		doso=true;
	});	
	
	$("#print_icon").click(function(){ 
		window.open('print.html', 'print','width=650,height=400,scrollbars=yes,toolbar=yes,location=no'); 
		
	});
	
	$(".x").click(function(){ 
		$(this).parent().hide();
	});

	$(".help").click(function(){ 
		$(this).next().slideDown();
	});
	
	
	
});

function showSubMenu(menu_name){
	if(menu_name!="none"){
		$("#main_menu_"+menu_name).attr({src : "/static/project/images/nav/"+menu_name+"_mo.gif"});
 		$("#"+menu_name).parent().next("ul").slideDown(300);
	}
}


function hideSubMenu(menu_name){
	if(menu_name!="" && menu_name!="none"){
	  	clearTimeout(t);
		if($("#"+menu_name).parent().next("ul").attr("class")=="submenu"){
			$("#"+menu_name).parent().next("ul").slideUp(120,function(){
				$("#main_menu_"+menu_name).attr({src : "/static/project/images/nav/"+menu_name+".gif"});
			});
		}
		else{
			$("#main_menu_"+menu_name).attr({src : "/static/project/images/nav/"+menu_name+".gif"});
		}
	}
}


function showTab(container,tab_id){
		noof_divs=$(container).children().size();
		noof_tabs=noof_divs/3;
		parent_id=$(container).attr('id');
		i=1;
		j=0;
		k=1;
		xtra="";
		$(container).children().each(function() {
			var child = $(this);
			child.removeClass();
			j++;
			if(j==1){
				xtra="_first";
			}
			else if(j==noof_divs){
				xtra="_last";
			}
			else{
				xtra="";
			}
			
			if(i==1){
				if(tab_id==k){
					child.addClass("tab_left_act"+xtra);
				}
				else{
					child.addClass("tab_left"+xtra);
				}
			}
			if(i==2){
				if(tab_id==k){
					child.addClass("tab_label_act");
				}
				else{
					child.addClass("tab_label");
				}
			}
			if(i==3){
				if(tab_id==k+1){
					child.addClass("tab_right_inact");
				}
				else if(tab_id==k){
					child.addClass("tab_right_act"+xtra);
				}
				else{
					child.addClass("tab_right_act"+xtra);
				}
			}
			
			i++;
			if(i==4){
				i=1;
				$("#"+parent_id+"_content_"+k).hide();
				k++;
			}
		});
		$("#"+parent_id+"_content_"+tab_id).show();
}


