// JavaScript Document

/*
 * Tab panel script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Stefan Isfeld
 * 
 *
 */
 

$(document).ready(function(){
	
	//**********************************************
	// Tab panel control
	//**********************************************
	/* CONFIG */
	$( "#tabContainer #tabContent0" ).css( {"display":"block"} );
	
	numTabs = $( "#listTab .tabItem").length;
	for (index=0; index < numTabs; index++) {
			$("#listTab .tabItem:eq("+index+")").css( {"background":"url(/pics/sports/sport_basic/pic_dn_"+index+".jpg) no-repeat"} );
		}
	$( "#listTab .tabItem:first").css( {"background":"url(/pics/sports/sport_basic/pic_up_0.jpg) no-repeat"} );
	/* CONFIG */
	
	// Switch content when a tab is clickrd
	$("li.tabItem").click(function(){
		// Get the tab that was clicked
		tabId = $(this).attr("id");
		divElement = eval("document.getElementById('"+tabId+"').parentNode");
		filter = "#" + $(divElement).attr("id") +" ." + $(this).attr("class");
		
		// Toggle external modules

		if ( ($(divElement).attr("id") == "listTab") && ( tabId == 0 )) {
			$("#ticketSummaryMod").css( {"display":"none"} );
			$("#prolineSummaryMod").css( {"display":"block"} );
			$("#designatorMod").css( {"display":"none"} );
		} 
		if	( ($(divElement).attr("id") == "listTab") && ( tabId == 1 )) {
			$("#ticketSummaryMod").css( {"display":"block"} );
			$("#prolineSummaryMod").css( {"display":"none"} );
			$("#designatorMod").css( {"display":"none"} );
		}
		
		// set all tabs to not selected
		numTabs = $(filter).length;
		for (index=0; index < numTabs; index++) {
			whichDiv = "#" + index;
			$(whichDiv).css( {"background":"url(/pics/sports/sport_basic/pic_dn_"+index+".jpg) no-repeat"} );
		}
		// Highlight the clicked tab
		$(this).css( {"background":"url(/pics/sports/sport_basic/pic_up_"+tabId+".jpg) no-repeat"} );
		bGround = "url(/pics/sports/sport_basic/pic_up_"+tabId+".jpg) no-repeat";
		
		// Get the class name of the content container
		divElement = eval("document.getElementById('tabContent"+tabId+"').parentNode");
		filter = "#" + $(divElement).attr("id") + " div.tabCont";

		// Turn on the matching content
		$( filter ).css( {"display":"none"} );
		$( "#tabContent"  + tabId ).css( {"display":"block"} );
		
		
		
	});	
	
	//**********************************************
	var bGround;
	$(".tabItem").mouseover(function() {
		whichId = $(this).attr('id');
		bGround = $(this).css("background");
		$(this).css( {"background":"url(/pics/sports/sport_basic/pic_ov_"+whichId+".jpg) no-repeat" } );

		}).mouseout(function() {
			$(this).css( {"background": bGround } );
			});	

});

