function EnableTab(element)
{
	if (element != null)
	{
		// Disable all of the tabs
		DisableTabs(new Array("tabHumor","tabGames","tabOfficeFun","officeFunTabsHumor","officeFunTabsGames","officeFunTabsBusinessCards","tabGamesSpecficHumor","tabGamesSpecficGames","tabGamesSpecficOfficeFun"));
				
		// Crated hash for paths
		var myPaths = new Array();
		myPaths["tabHumor"] = "/exclude/tabContent/0,,620|1,00.html";
		myPaths["tabGames"] = "/exclude/tabContent/0,,620|2,00.html";
		myPaths["tabOfficeFun"] = "/exclude/tabContent/0,,620|3,00.html";
		myPaths["officeFunTabsHumor"] = "/exclude/tabContent/0,,620|7,00.html";
		myPaths["officeFunTabsGames"] = "/exclude/tabContent/0,,620|8,00.html";
		myPaths["officeFunTabsBusinessCards"] = "/exclude/tabContent/0,,620|9,00.html";
		myPaths["tabGamesSpecficHumor"] = "/exclude/tabContent/0,,620|4,00.html";
		myPaths["tabGamesSpecficGames"] = "/exclude/tabContent/0,,620|5,00.html";
		myPaths["tabGamesSpecficOfficeFun"] = "/exclude/tabContent/0,,620|6,00.html";

			
		// Select the proper tab and set the style
		element.setAttribute("class", element.id + "_Selected");
		element.setAttribute("className", element.id + "_Selected");
		
		// Read in its contents
		var tabsBodyContent = document.getElementById("tabsBodyContent");
		advAJAX.get({
			//url: GetLocationPath() + element.id + ".html",
			url: myPaths[element.id],
			async: (navigator.userAgent.indexOf('Safari') == -1),
			onSuccess : function(obj) { tabsBodyContent.innerHTML = obj.responseText; },
			onError : function(obj) { alert("Error: " + obj.status); }
		});
	}
}

function DisableTabs(tabs)
{
	

	for (var i=0; i < tabs.length; i++)
	{
		DisableTab(document.getElementById(tabs[i]));
	}
}

function DisableTab(element)
{
	if (element != null)
	{
		// Set de-selected style
		element.setAttribute("class", element.id + "_notSelected");
		element.setAttribute("className", element.id + "_notSelected");
	}
}

function GetLocationPath()
{
	return location.href.substring(0,location.href.lastIndexOf("/")+1);
}


function PositionSubMenu(element)
{
	var menu = document.getElementById(element.id + "Menu");	

	menu.style.top = (findPosY(element) + 1) + "px";
	menu.style.left = (findPosX(element) - 247) + "px";
	menu.style.display = "inline";
}

 
function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft
 			obj = obj.offsetParent;
		}
 	}
 	else if (obj.x) { 
 		curleft += obj.x; 
 	}
 
	return curleft;
}
 
 
function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
 			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
 	else if (obj.y) {
 		curtop += obj.y;
 	}
 
	return curtop;
}
function getXMLHttpRequest() {
	    if (window.XMLHttpRequest) {
                req = new XMLHttpRequest();
            } else if (window.ActiveXObject) {
	        req = new ActiveXObject("Microsoft.XMLHTTP");
            }
            return req;
	}
// This is the function to include other pages within an html page
function printPageContent(URL)
{
  //alert("in");
  var theURL = location.href.substring(0, location.href.lastIndexOf('/') + 1) + URL;
  //alert(theURL);
  //alert(typeof java.net.URL);
  //theURL = "W:\active\TBS\_client_assets\_client_ftp\finals\includes\subNav.html";

	req = getXMLHttpRequest();
		req.open('GET', URL, false);
	    req.send(null);
		theText = req.responseText;
	  
  document.write(theText);
}


function getBackgroundImage(x, y)
{
	var navigationImage = "http://i.tbs.com/v5cache/TBS/TBS04/images/static/v5_img_sprite_navigation.jpg";
	return "transparent url(" + navigationImage + ") " + x + "px " + y + "px";
}

function setOriginalMenuStyle(element)
{
	if (element.getAttribute("originalStyle") != null)
		element.style.background = element.getAttribute("originalStyle");
	else
		element.style.background = "none";
}

/* from v4 site*/

var myWindows = new Array();

function imageSwap(whichImage, toWhichImage){
	if (document.images!= null)
	{ document.images[whichImage].src = eval(toWhichImage); }	
}
function showSelected() {
	var value = document.showSelect.showList.options[document.showSelect.showList.selectedIndex].value;
	window.location.href=value;
}
function openWin(html, name, width, height, scroll) {
	if (width == '')
		var width = 350;
	if (height == '')
		var height = 650;
	myWindows[myWindows.length] = open( html, name, 'width='+width+',height='+height+',status=no,scrollbars='+scroll+',resizable=yes,location=no,toolbar=no');
}
function openFooterWin(path, width, height) {
	window.open(path, 'PopupWin', 'width='+width+',height='+height+',resizable=yes,scrollbars=auto,location=no,toolbar=no,status=no');
}
