//TODO: update item calls to be able to work with user controls/master pages

// Determine browser type
NS = navigator.appName == "Netscape";
IE = navigator.appName == "Microsoft Internet Explorer";
Unknown = !(NS || IE);


// global variables
var showNavline = true;
var gg_pageElementIdPrefix = "";

function addLoadEvent(functionName) 
{
	var oldonload = window.onload;
	if (typeof window.onload != 'function') 
	{
		window.onload = functionName;
	} 
	else 
	{
		window.onload = function()
		{
			oldonload();
			functionName();
		};
	}
}

/* TOP NAV FUNCTIONS */
function setTopNavItem()
{
	var siteMapID = document.getElementById('ctl00_parentSiteMapID').value;
	siteMapID = (siteMapID < 1)?1:siteMapID;
	var elem = document.getElementById('topmenu_' + siteMapID);
	if (elem != null)
		elem.childNodes[0].className = 'topnavlink_active';
}

function setLeftNavItem()
{
	try {
		aAnchors = tblLeftNav.getElementsByTagName("A");
		for (var i=0;i<aAnchors.length;i++)
		{
			if (aAnchors[i].href.toLowerCase() == window.location.href.toLowerCase())
			{
				aAnchors[i].className = 'menutier2active';
				break;
			}
		}
	}
	catch(e){}
}

function HideNavline()
{
	showNavline = false;
}

// go to specific URL
function go(url) 
{
	window.location.href = url;
}

// open a new window
function newwindow(url, name)
{
	var win = window.open(url, name, "fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=yes,directories=no,location=no,width=550,height=350,left=25,top=25")
	if ((!win) || (win == null))
		alert("The PartnerPortal is being blocked by your anti pop-up software.  Please enable pop-ups on this page.");
}

function ShowHide(id)
{
	var div = document.getElementById(id)
	if (id != null)
	{
		div.style.display = (div.style.display == 'none')?'inline':'none';
	}	
}

// *******************************************************
// CHANGE COUNTRY CODE
// *******************************************************
function changeCountry()
{
	var objID = 'countryIframe';
	var oFrame = document.getElementById(objID);
	if (oFrame == null)
	{
		oFrame = document.createElement("IFRAME");
		oFrame.id = 'countryIframe';
		oFrame.className = 'countryIframe';
		oFrame.src = '/common/countrypicker.aspx';
		oFrame.frameBorder = 0;
		oFrame.style.display = 'none';
		oFrame.scrolling = 'auto';
		document.body.appendChild(oFrame);
	}
	oFrame.style.display = (oFrame.style.display == 'none')?'':'none';
}


// *******************************************************
// FOOTER CODE
// *******************************************************
var g_objFooter;
var g_footerHeight = 0;
var g_formHeight = 0;

function PositionFooter()
{
	var clientHeight = document.documentElement.clientHeight;
	var contentHeight = document.body.scrollHeight;	
	var footerPositionTop = 0;
	if (clientHeight > 0)
	{
		//will work in mozilla
		g_formHeight = (contentHeight > clientHeight)?contentHeight-2:clientHeight-2;
	}
 	else
	{
		//workaround for IE
		var windowHeight = document.body.clientHeight;
		g_formHeight = (windowHeight > contentHeight)?windowHeight:contentHeight;
	}

	//push down to allow for menus
	if (g_formHeight < 500)
		g_formHeight = 500;
	
	footerPositionTop = g_formHeight - g_footerHeight;
	document.forms[0].style.height = g_formHeight;
	g_objFooter.style.top = footerPositionTop - 1;
	g_objFooter.style.position = "absolute";

	// position left side nav border		
	var navline = document.getElementById("navline");
		
	if (navline != null)
	{
		if (!showNavline)
			navline.style.display = "none";
			
		navline.style.height = (footerPositionTop) - 161;
	}
}

function SetFooter() 
{
	g_objFooter = document.getElementById("footer");
	g_footerHeight = g_objFooter.style.height;
	g_footerHeight = g_footerHeight.replace(/px/,"");
	g_footerHeight = parseFloat(g_footerHeight); //convert to int
	g_footerHeight = g_footerHeight + 1;
		
	PositionFooter();
	g_objFooter.style.visibility = "visible";
}

function resetFooter()
{
	//used by the resize event
	setTimeout("PositionFooter()", 10);
}
// *******************************************************