function InitLoad()
{
	//SetFooter();
	if (window.quotesInit) quotesInit();
}
function InitResize()
{
	SetFooter();
}
window.onload = InitLoad;
window.onresize = InitResize;

function OpenWindow(url, name, width, height, resizable, scrollbars, statusbar, menubar, toolbar)
{
	var win = (window.name) ? eval(name) : null;
	var optionString = "";
	if (width) optionString += "width=" + width + ",";
	if (height) optionString += "height=" + height + ",";
	if (resizable) optionString += "resizable=1,";
	if (scrollbars) optionString += "scrollbars=1,";
	if (statusbar) optionString += "status=1,";
	if (menubar) optionString += "menubar=1,";
	if (toolbar) optionString += "toolbar=1,";
	if (optionString != "") optionString = optionString.substr(0, optionString.length - 1);
	win = window.open(url, name, optionString);
	win.focus();
}

function PrintPage()
{
	if (window.print) window.print();
	else alert("Please select \"Print...\" from the File menu.");
}

function OpenPopup(url)
{
	OpenWindow(url, "Popup", 560, 500, false, true, false, false, false);
}

function OpenYouCanHelp(url)
{
	OpenWindow(url, "YouCanHelpPopup", 450, 375, false, true, false, false, false);
}

function OpenImage(url)
{
	OpenWindow(url, "ImageDisplay", 540, 550, false, true, false, false, false);
}

function Trim(theString)
{
	var newString = theString;
	while (newString.charAt(0) == " " || newString.charCodeAt(0) == 10 || newString.charCodeAt(0) == 13 || newString.charCodeAt(0) == 9) {
		newString = newString.substring(1,newString.length);
	}
	while (newString.charAt(newString.length - 1) == " " || newString.charCodeAt(newString.length - 1) == 10 || newString.charCodeAt(newString.length - 1) == 13 || newString.charCodeAt(newString.length - 1) == 9) {
		newString = newString.substring(0,newString.length - 1);
	}
	return newString;
}

function SetFooter()
{
	if (document.getElementById) 
	{
		var windowHeight = GetWindowHeight();
		if (windowHeight > 0) 
		{
			var contentElement = document.getElementById("ContentWrapper");
			if (contentElement == null)
			{
				// Might be a popup...
				contentElement = document.getElementById("Content");
				if (contentElement == null)
				{
					// Nope - give up
					return;
				}
			}
			var homeOffset = document.getElementById("ScrollingQuotes") ? 40 : 1;
			var headerHeight = document.getElementById("Header").offsetHeight;
			var contentHeight = contentElement.offsetHeight + headerHeight;
			var footerElement = document.getElementById("Footer");
			if (footerElement)
			{
				var footerHeight  = footerElement.offsetHeight;
				if (windowHeight - (contentHeight + footerHeight + homeOffset) >= 0)
				{
					footerElement.style.position = "relative";
					footerElement.style.top = (windowHeight - (contentHeight + footerHeight) - homeOffset) + "px";
				}
				else 
				{
					footerElement.style.position = "static";
				}
			}
		}
	}
}

function GetWindowHeight() 
{
	var windowHeight = 0;
	if (typeof(window.innerHeight) == "number") 
	{
		windowHeight = window.innerHeight;
	}
	else 
	{
		if (document.documentElement && document.documentElement.clientHeight) 
		{
			windowHeight = document.documentElement.clientHeight;
		}
		else 
		{
			if (document.body && document.body.clientHeight) 
			{
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}