// Tab functions and globals
var selectedTab = "none",
//	numberOfTabs = 5,
	subNavString = "none",
	lastTab = homeTab,
	last_subNavString = subNav;

var     tab_size=110, left_margin=5, right_margin=20;

function getPlayer() { if (VMPInstalled()) alert("You already have VMP installed."); else VMPInstallWithFrame() }

function popup(destination,width,height) {
	if(arguments.length<4)
		window.open(destination, "redirector", "width="+width+",height="+height+",toolbar=no,location=no,scrollbars");
	else
		window.open(destination, "redirector", "width="+width+",height="+height+","+arguments[3]);
}


// Initialize the home tab when the page loads
function showSubNav(ht,visStatus) {
	if (document.all) {
		eval("document.all['"+ht+"'].style.visibility = '"+visStatus+"'");
	} else {
		eval("document.getElementById('"+ht+"').style.visibility = '"+visStatus+"'");
	}
}

function handleTab(theTab) {
	// Load secondary navigation
        /*
	switch(theTab) {
		case "tab1":
			subNavString = "subNav1";
		break;
		case "tab3":
			subNavString = "subNav3";
		break;
		default:
			subNavString = "subNav0";
		break;	
	}
        */

	subNavString="subNav" + theTab.substring(3);
	// Switch SubNavigation
	if (last_subNavString != "none") showSubNav(last_subNavString,'hidden');
	if (subNavString != "none") showSubNav(subNavString,'visible');
	
	// Switch Images if necessary
	if (theTab == homeTab) {
		if (theTab != lastTab) {
			eval("document." + lastTab + ".src = " + lastTab + "normal" + ".src");
		}
	} else {
		if (lastTab != homeTab) {
			eval("document." + lastTab + ".src = " + lastTab + "normal" + ".src");
		}
		eval("document." + theTab + ".src = " + theTab + "over" + ".src");
	}
	
	lastTab = theTab;
	last_subNavString = subNavString;
}

function handleRollover(thisTab,theState) {	
	var flipImg = true;
	if (thisTab == lastTab) flipImg = false;
	if (thisTab == homeTab) flipImg = false;
	if (flipImg) eval("document." + thisTab + ".src = " + theState + ".src");
}

function initSubNav() { 

        for (cpc = 0; cpc < numberOfTabs; cpc++) setSubNav(cpc); 

} 



function setSubNav(thisSub) { 

        centerPoint = left_margin + tab_size * thisSub + tab_size/2; 

        if (document.all) {
            eval("divWidth = document.all['subNav"+thisSub+"'].offsetWidth"); 
            totalWidth=document.all['maintab'].offsetWidth;
        } else {
            eval("divWidth = document.getElementById('subNav"+thisSub+"').offsetWidth"); 
            totalWidth=document.getElementById('maintab').offsetWidth;
        }
 
        if ((centerPoint + divWidth/2) <= totalWidth) {
            leftPoint = Math.ceil(centerPoint - (divWidth / 2)); 
        } else {
            leftPoint=Math.ceil(totalWidth-divWidth-right_margin);
        }

        if (leftPoint < left_margin) {
            leftPoint=left_margin;
        }

        leftPointStr = leftPoint + "px"; 

        if (document.all) eval("document.all['subNav"+thisSub+"'].style.marginLeft = '" + leftPointStr + "'"); 

        else eval("document.getElementById('subNav"+thisSub+"').style.marginLeft = '" + leftPointStr + "'"); 

} 

