// The follow tag is actually commented and not parsed.  It forces InterDev to parse the code as JavaScript.
// <SCRIPT Language="JavaScript">

if (navigator.appName.toLowerCase().indexOf("netscape") > -1)
{
	var ie = false;
	var ns = true;
}
else
{
	var ie = true;
	var ns = false;
}
	
var doc, layers, objName, objStyle, clipHeight, clipWidth, bodyWidth;
var objWidth, objHeight, objLeft, objTop, scrollTop;

var BrowserInitialized = false;
BrowserInitialize();

function BrowserInitialize()
{
	if (BrowserInitialized) return;
	
	if (ie)
	{
		doc = document.all;
		layers = "document.all";
		objStyle = ".style";
		objWidth = ".clientWidth";
		objHeight = ".clientHeight";
		clipHeight = objStyle + ".clipHeight";
		clipWidth = objStyle + ".clipWidth";
		bodyWidth = "document.body.clientWidth";
		bodyHeight = "document.body.clientHeight";
		scrollTop = "document.body.scrollTop";
	}
	else
	{
		doc = document.layers;
		layers = "document.layers";
		objStyle = "";
		objWidth = ".clip.width";
		objHeight = ".clip.height";
		clipHeight = ".clip.height";
		clipWidth = ".clip.width";
		bodyWidth = "window.innerWidth";
		bodyHeight = "window.innerHeight";
		scrollTop = "window.pageYOffset";
	}
	
	BrowserInitialized = true;
}

function show(id)
{
	BrowserInitialize();

	var stCommand = "getDiv('" + id + "')" + objStyle + ".visibility = 'visible';"
	eval(stCommand);
}

function hide(id)
{
	BrowserInitialize();

	eval("getDiv('" + id + "')" + objStyle + ".visibility = 'hidden';");
}

function getLeft(id)
{
	BrowserInitialize();

	return( parseInt(eval("getDiv('" + id + "')" + objStyle + ".left")));
}

function getOffsetLeft(id)
{
	BrowserInitialize();

	return( parseInt(eval("getDiv('" + id + "').offsetLeft")));
}

function setLeft(id, x)
{
	BrowserInitialize();

	var stCommand = "getDiv('" + id + "')" + objStyle + ".left = " + x + ";"
	eval(stCommand);
}

function getTop(id)
{
	BrowserInitialize();

	return( parseInt(eval("getDiv('" + id + "')" + objStyle + ".top")));
}

function getOffsetTop(id)
{
	BrowserInitialize();

	return( parseInt(eval("getDiv('" + id + "').offsetTop")));
}

function setTop(id, y)
{
	BrowserInitialize();

	eval("getDiv('" + id + "')" + objStyle + ".top = " + y + ";");
}

function getWidth(id)
{
	BrowserInitialize();

	return( parseInt(eval("getDiv('" + id + "')" + objWidth )));
}

function setWidth(id, w)
{
	BrowserInitialize();

	eval("getDiv('" + id + "')" + clipWidth + " = " + w);
}

function getHeight(id)
{
	BrowserInitialize();

	return( parseInt(eval("getDiv('" + id + "')" + objHeight )));
}

function setHeight(id, h)
{
	BrowserInitialize();

	eval("getDiv('" + id + "')" + clipHeight + " = " + h);
}

function setInnerText(id, stText)
{
	BrowserInitialize();

	var obj = getDiv(id);
	
	if (ie)
		obj.innerHTML = stText;
	else
	{
		obj.document.open();
		obj.document.write(stText);
		obj.document.close();
	}
}

function setBackgroundColor(obj, color)
{
	BrowserInitialize();

	if (!obj) return false;
	ns ? obj.bgColor = color : obj.style.backgroundColor = color;
}

function getDiv(id, rootName)
{
	BrowserInitialize();

	if (ie)
		return doc[id];
	else
	{
		if (rootName == null)
			rootName = "doc";
		
		var root = eval(rootName);
		var ret;
		
		for(var ctr = 0; ctr < root.length; ctr++)
		{
			if (root[ctr].id.toLowerCase() == id.toLowerCase())
			{
				return root[ctr];
			}
			
			if (eval(rootName + "[" + ctr + "]." + layers + ".length") > 0)
			{
				ret = getDiv(id, rootName + "[" + ctr + "]." + layers);
				if (ret != null)
				{
					return ret;
				}
			}
		}
	}
	
	return null;
}

function getWindowHeight()
{
	BrowserInitialize();

	if (ie)
		return document.body.clientHeight;
	
	var windowWidth = window.innerWidth;
	var windowHeight = window.innerHeight;
	var scrollWidth = window.document.width;
	
	if (scrollWidth > windowWidth)
		windowHeight -= 16;
	
	return windowHeight;
}

function getWindowWidth()
{
	BrowserInitialize();

	if (ie)
		return document.body.clientWidth;
	
	var windowHeight = window.innerHeight;
	var windowWidth = window.innerWidth;
	var scrollHeight = window.document.height;
	
	if (scrollHeight > windowHeight)
		windowWidth -= 16;
	
	return windowWidth;
}

function getBodyHeight()
{
	BrowserInitialize();

	if (ie)
		return document.body.scrollHeight;
	else
		return document.height;
}

function getScrollTop()
{
	BrowserInitialize();

	if (ie)
		return document.body.scrollTop;
	else
		return window.pageYOffset;
}

function setClass(obj, stClassName, stContents)
{
	BrowserInitialize();

	if (ie)
		obj.className = stClassName;
	else
		WriteLayer(obj, '<DIV ID="' + obj.id + '" Class="' + stClassName + '">' + stContents + '</DIV>');
}	

// Write Method
function WriteLayer(obj, html)
{
	BrowserInitialize();

	if (ie) 
		obj.innerHTML = html;
	{
		obj = document.layers[obj.id].document;
		obj.open();
		obj.write(html);
		obj.close();
	}
}

function layerWrite(id,nestref,text)
{
	BrowserInitialize();

	if (ns4) {
		if (nestref) var lyr = eval('document.'+nestref+'.document.'+id+'.document')
		else var lyr = document.layers[id].document
		lyr.open()
		lyr.write(text)
		lyr.close()
	}
	else if (ie4) document.all[id].innerHTML = text
}

function showTransition(id)
{
	BrowserInitialize();

	if (ie) 
	{
		var div = getDiv(id);
		div.filters.item(0).Apply();
		div.style.visibility = "visible";
		div.filters.item(0).Play();
	}
	else
	{
		show(id);
	}
}

function hideTransition(id)
{
	BrowserInitialize();

	if (ie) 
	{
		var div = getDiv(id);
		div.filters.item(0).Apply();
		div.style.visibility = "hidden";
		div.filters.item(0).Play();
	}
	else
	{
		hide(id);
	}
}

function showCentered(id)
{
	BrowserInitialize();

	var div = getDiv(id);

	setLeft(id, (getWindowWidth() - div.clientWidth) / 2);
	setTop(id, (getWindowHeight() - div.clientHeight) / 2);
	show(id);
}

function getRadio(radio)
{
	BrowserInitialize();

	for (var ctr = 0; ctr < radio.length; ctr++)
		if (radio[ctr].checked == true)
			return radio[ctr].value;
}

function jsFormatNumber(num, nDigits)
{
	BrowserInitialize();

	var num = new Number(num);
	var ctr, str;
	
	if (nDigits == 0) return Math.round(num);
	if (num == 0)
	{
		str = "0.";
		for (ctr = 0; ctr < nDigits; ctr++)
			str += "0";
		
		return str;
	}
		
	for (ctr = 0; ctr < nDigits; ctr++)
		num *= 10;
	
	str = Math.round(num).toString();
	
	str = str.substring(0, str.length - nDigits) + "." + str.substring(str.length - nDigits);
	return str;
}

function getTotalOffsetTop(obj)
{
	var top = obj.offsetTop;
	
	while (obj.parentElement && obj.parentElement.tagName != "HTML")
	{
		obj = obj.parentElement;
		
		if (obj.tagName != "TR" && obj.tagName != "FORM") top += obj.offsetTop;
	}
	
	return top;
}

function getTotalOffsetLeft(obj)
{
	var left = obj.offsetLeft;
	
	while (obj.parentElement)
	{
		obj = obj.parentElement;
		
		if (obj.tagName != "TR" && obj.tagName != "FORM") left += obj.offsetLeft;
	}
	
	return left;
}