function truebody() {
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function showPopup(elementId) {
	document.getElementById("overlay").style.visibility = "visible";
	var scrollValue = Math.max(document.body.scrollTop, document.documentElement.scrollTop);
	document.getElementById(elementId).style.top = (scrollValue + 200) + 'px';
	document.getElementById(elementId).style.visibility = "visible";
	adjustOverlay();
	CreateIE6SelectBugIframe(document.getElementById("overlay"));
	AdjustIE6SelectBugIframe(document.getElementById("overlay"));
}

function hidePopup(elementId) {
	document.getElementById("overlay").style.visibility = "hidden";
	document.getElementById(elementId).style.visibility = "hidden";
	RemoveIE6SelectBugIframe(document.getElementById("overlay"));
}

function unwait() {
	document.getElementById("overlay").style.visibility = "hidden";
	document.getElementById("loading").style.visibility = "hidden";
	document.getElementById("loadingImage").style.visibility = "hidden";
	RemoveIE6SelectBugIframe(document.getElementById("overlay"));
	document.body.style.cursor = "default";
}

function wait() {
	document.body.style.cursor = "wait";
	document.getElementById("overlay").style.visibility = "visible";
	document.getElementById("loading").style.visibility = "visible";
	document.getElementById("loadingImage").style.visibility = "visible";
	adjustOverlay();
	CreateIE6SelectBugIframe(document.getElementById("overlay"));
	AdjustIE6SelectBugIframe(document.getElementById("overlay"));
}

function adjustOverlay() {
	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight)
	var overlay = document.getElementById("overlay")
	if (navigator.userAgent.indexOf("MSIE 6.") != -1) {
		overlay.style.position = "absolute";
		overlay.style.top = "0px";
		overlay.style.left = "0px";
		overlay.style.width = docwidth + "px";
		overlay.style.height = docheight + "px";
	} else {
		overlay.style.position = "fixed";
		overlay.style.top = "0px";
		overlay.style.left = "0px";
		overlay.style.width = "100%";
		overlay.style.height = "100%";
	}
	overlay.style.display = "block";
	overlay.style.zIndex = "104";
	overlay.style.backgroundColor = "#777777";
	overlay.style.filter = "alpha(opacity=92)";
	overlay.style.opacity = "0.92";

	var loading = document.getElementById("loading")
	loading.style.border = "1px solid";
	loading.style.left = truebody().clientWidth / 2 - 28 + "px";
	loading.style.top = truebody().scrollTop + 150 + "px";
	loading.style.padding = "12px";
	loading.style.position = "absolute";
	loading.style.display = "block";
	loading.style.color = "#E0E0E0";
	loading.style.zIndex = "105";
	loading.style.filter = "alpha(opacity=100)";
	loading.style.opacity = "1.0";
	loading.style.backgroundColor = "#FFFFFF";

	var image = document.getElementById("loadingImage")
	image.style.display = "block";
	image.style.zIndex = "105";
	image.style.filter = "alpha(opacity=100)";
	image.style.opacity = "1.0";
}

// Begin IE6 Select bug solution
// A number of functions that can be used to make sure that a select box is not displaying on top of another element
// (e.g. a popup window)
// - Call CreateIE6SelectBugIframe to create an iframe that can be postioned behind the popup element
// - Call AdjustIE6SelectBugIframe to reposition/resize the iframe when the popup element has changed (in size, position, or visibility)
// - Call RemoveIE6SelectBugIframe to remove the iframe
function GetIE6SelectBugIframeId(elt)
{
	return elt.id + "IE6SelectBugIframe";
}

function CreateIE6SelectBugIframe(elt)
{
	if (navigator.userAgent.indexOf("MSIE 6.") != -1) {
		if (elt && elt.parentNode) {
			var ie6IframeId = GetIE6SelectBugIframeId(elt);
			
			var ie6Iframe = document.getElementById(ie6IframeId);
			if (ie6Iframe)
			{
				ie6Iframe.parentNode.removeChild(ie6Iframe);
			}
			else
			{
				ie6Iframe = document.createElement("iframe");
			}
			ie6Iframe.id = ie6IframeId ;
			ie6Iframe.src = document.location.pathname.substring(0, document.location.pathname.substring(1).indexOf('/') + 1).concat("/empty.html");
			ie6Iframe.style.position = "absolute";
			ie6Iframe.style.display = "none";
			ie6Iframe.scrolling = "no";
			ie6Iframe.frameBorder = "0";
			ie6Iframe.style.backgroundColor = elt.style.backgroundColor;
			ie6Iframe.style.filter = elt.style.filter;
			ie6Iframe.style.opacity = elt.style.opacity;
			elt.parentNode.insertBefore(ie6Iframe, elt);
		}
	}
}

function RemoveIE6SelectBugIframe(elt)
{
	if (navigator.userAgent.indexOf("MSIE 6.") != -1) {
		if (elt && elt.parentNode) {
			var ie6Iframe = document.getElementById(GetIE6SelectBugIframeId(elt));
			if (ie6Iframe)
			{
				ie6Iframe.parentNode.removeChild(ie6Iframe);
			}
		}
	}
}

function AdjustIE6SelectBugIframe(elt)
{
	if (navigator.userAgent.indexOf("MSIE 6.") != -1) {
		if (elt) {
			var ie6Iframe = document.getElementById(GetIE6SelectBugIframeId(elt));
			if (ie6Iframe)
			{
				ie6Iframe.style.position = "absolute";
				ie6Iframe.style.top = elt.offsetTop;
				ie6Iframe.style.left = elt.offsetLeft;
				ie6Iframe.style.width = elt.offsetWidth + "px";
				ie6Iframe.style.height = elt.offsetHeight + "px";
				ie6Iframe.style.display = elt.style.display;
				ie6Iframe.style.visibility = elt.style.visibility;
				if (elt.currentStyle && elt.currentStyle.zIndex)
				{
					ie6Iframe.style.zIndex = elt.currentStyle.zIndex;
				}
				else if (elt.style.zIndex)
				{
					ie6Iframe.style.zIndex = elt.style.zIndex;
				}
			}
		}
	}
}
// End IE6 Select bug solution