window.onload = function init()
{
  	for( tbIdx in tabList )
  		initTab( tabList[tbIdx][0], tabList[tbIdx][1] );
  		
  	var u = window.location.toString();
	var i = u.lastIndexOf( "#" );	
	if( i > 0 )
	{
		currpanel = u.substring( i + 1 );
		currtab = currpanel.substring( 0, 4 ) + "tab";
	}
	var tb = document.getElementById( currtab );
	activateTab( currtab, currpanel );
}


function initTab( tabId, tabContentId )
{
	//alert( tabId + tabContentId );
	
}
	
function selectTab( newtab, newpanel )
{
	if( newtab != currtab )
	{
		activateTab( newtab, newpanel );
	}
}

function setTabTop( tabname, imgsrc, crsor )
{
	var tabtop = tabname.substring( 0, 4 ) + "top";
	tabtop = document.getElementById( tabtop );
	tabtop.src = "images/" + imgsrc;
	tabtop.style.cursor = crsor;
}
	
function activateTab( newtab, newpanel )
{
	document.getElementById( currpanel ).style.display = "none";
	currpanel = newpanel;
	document.getElementById( newpanel ).style.display = "inline";

	var tb = document.getElementById( currtab );

	tb.style.backgroundColor = "#98A268"; 
	tb.style.borderColor = "#7C864E #58632C #7C864E #6A743D"; 
	tb.style.borderStyle = "solid ridge";
	tb.style.cursor = "pointer"; 

	var lk = tb.getElementsByTagName( "a" );
	lk[0].style.textDecoration = "underline";
	lk[0].style.color = "#330033";
	lk[0].style.cursor = "pointer";
	setTabTop( currtab, "TabTop.gif", "pointer" );
	
	tb = document.getElementById( newtab );

	tb.setAttribute( "className", "tabSelect" ); //temp
	
	tb.style.backgroundColor = "transparent"; //"#BAC488";
	tb.style.borderColor = "#7C864E #58632C #7C864E #7C864E";
	tb.style.borderStyle = "none solid"; 
	tb.style.cursor = "default";

	lk = tb.getElementsByTagName( "a" );
	lk[0].style.textDecoration = "none";
	lk[0].style.color = "#000000";
	lk[0].style.cursor = "default";
	setTabTop( newtab, "TabTopSelect.gif", "default" );
	lk[0].focus();
	
	currtab = newtab;
}