// JavaScript Document
//main

function repositionElements(page) { 
	promoteSearch(); // See note on this function below!	
	var availableWidth = getWindowWidth(); //search + left nav
	if (availableWidth < 760) {
		availableWidth = 760;
	}
//	alert(window.navigator.appName);
	var main = document.getElementById('main');
	var navLeft = parseInt(document.getElementById('navLeft').clientWidth);
	if (availableWidth < 955) {
		var user = document.getElementById("user");
		user.style.left = eval(availableWidth-user.clientWidth).toString()+'px';
		var navTop = document.getElementById('navTop');
		navTop.style.width = 900;
		var masthead = document.getElementById('masthead');
		masthead.style.width = 700;
		if(page=='home') { 
			main.style.width =  availableWidth - (183 + 350) - 10; 
			var searchDiv = document.getElementById('search');
			searchDiv.style.left = availableWidth - 350;
			}	
		else {				
			var relCont = document.getElementById('relatedContent');
			if (relCont!=null){
				main.style.width = eval(availableWidth - (navLeft + 250) - 10).toString()+'px'; 
				relCont.style.left = availableWidth - relCont.clientWidth;
				}
			else {
				var mainWide = document.getElementById("mainWide");
				mainWide.style.width = availableWidth-navLeft;
				}
			var searchDiv = document.getElementById('search');
			if (searchDiv!=null){
				searchDiv.style.left = availableWidth - searchDiv.clientWidth;}
			}
	}	

}

function getWindowWidth() { 
	var windowWidth=0;
	if (typeof(window.innerWidth)=='number') {
		windowWidth=window.innerWidth;
		}
	else {
		if (document.documentElement&&document.documentElement.clientWidth) {
			windowWidth=document.documentElement.clientWidth;
			}
		else {
			if (document.body&&document.body.clientWidth) {
				windowWidth=document.body.clientWidth;
				}
			}
		}
		return parseInt(windowWidth);

}

function resize() {
	//reloads the page on resize
	document.location.reload();
}

	
/* NOTE: NOT PART OF MENU SCRIPT
 *
 * trackImage()
 * Appends extended browser information as query string of selected object.
 *
 * parameters:
 * inPath: pathname in image src to seek
 *
 * returns:
 * void
 *
 */
 
 function trackImage(inPath)
 	{
		var strTimeZone = "GMT%20";
		var iOffset = (new Date()).getTimezoneOffset() / 60;
		if(iOffset < 0)
			{
				strTimeZone += "%2B";
				iOffset = 0 - iOffset;
			}
		else strTimeZone += "-";
		if(iOffset < 10) strTimeZone += "0";	
		strTimeZone += iOffset + "%3A00";
		for(var i = 0; i < document.images.length; i++)
			{
				if(document.images[i].src.indexOf(inPath) >= 0)
					{
						document.images[i].src += "?cd=" + window.screen.colorDepth + "&jv=" + (navigator.javaEnabled() ? "1" : "0") +"&lc=" + escape(window.location.href) + "&ln=" + navigator.userLanguage + "&rf=" + escape(document.referrer) +"&rs=" + window.screen.width + "x" + window.screen.height + "&tz=" + strTimeZone;
					}
			}
		return;
	}
 
/* NOTE: NOT PART OF MENU SCRIPT
 *
 * These functions are to promote the
 * improved search engine and will
 * (should?) eventually be removed.
 *
 */
 
var searchDefault = " ";
function promoteSearch()
	{
		var ctlSearch = document.getElementById("txtSearch");
		if(ctlSearch != null)
			{
				ctlSearch.style.fontWeight = "bold";
				ctlSearch.style.backgroundColor = "#ffffcc";
				if(ctlSearch.value == "")
					{
						ctlSearch.style.color = "#999999";
						ctlSearch.value = searchDefault;
					}
				ctlSearch.onfocus = clearSearch;
			}
		ctlSearch = document.getElementById("btnSearch");
		if(ctlSearch != null) ctlSearch.onclick = clearSearch; 
		return true;
	}
function clearSearch()
	{
		var ctlSearch = document.getElementById("txtSearch");
		if(ctlSearch != null)
			{
				ctlSearch.style.color = "#000000";
				if(ctlSearch.value == searchDefault)
					ctlSearch.value = "";
			}
		return true;
	}