var NS4 = 0;
var IE4 = 0;
var OPERA5 = 0;
var HTML = '';
var clickX = 0;
var clickY = 0;
var oldX;
var oldY;
var sCurrentId = '';
var idTimeout = 0;

if (document.layers)
{
	NS4 = 1;
}
else if (document.all)
{
	IE4 = 1;
	if (navigator.userAgent.indexOf("Opera 5") != -1)
	{
		OPERA5 = 1;
		IE4 = 0;
	}
}

function IsVisible(sId)
{
	if (NS4)
	{
		if (document.layers[sId].visibility == 'show')
			return true;
	}
	else
	{
		if (document.all[sId].style.visibility == 'visible')
			return true;
	}

	return false;
}

function HideLayer(sId)
{
	if (NS4)
		document.layers[sId].visibility = 'hide';
	else
		document.all[sId].style.visibility = 'hidden';
}

function ShowLayer(sId)
{
	if (NS4)
		document.layers[sId].visibility = 'show';
	else
		document.all[sId].style.visibility = 'visible';
}

function ShowLayerDelay(sId, nMilliseconds)
{
	if (IsVisible(sId) == false)
		window.setTimeout("ShowLayer('" + sId + "');", nMilliseconds);
}

function ClearAutoHide(sId)
{
	window.clearTimeout(idTimeout);

	if (sCurrentId != '' && sCurrentId != sId)
		AutoHide();
	else
		idTimeout = 0;
}

function SetAutoHide(sId, nMilliseconds)
{
	if (sCurrentId != '' && sCurrentId != sId)
	{
		window.clearTimeout(idTimeout);
		AutoHide();
	}

	if (idTimeout == 0)
	{
		sCurrentId = sId;
		ShowLayer(sCurrentId);
		idTimeout = window.setTimeout("AutoHide()", nMilliseconds);
	}
}

function AutoHide()
{
	HideLayer(sCurrentId);
	sCurrentId = '';
	idTimeout = 0;
}

function MoveLayer(sId, x, y)
{
	if (NS4)
		document.layers[sId].moveTo(x, y);
	else
	{
		document.all[sId].style.pixelLeft = x;
		document.all[sId].style.pixelTop = y;
	}
}

function SetTopLayer(sId)
{
	var n;
	var z;

	if (NS4)
	{
		z = document.layers[sId].zIndex;
		for (n = 0; n < document.layers.length; n++)
		{
			if (document.layers[n].zIndex > document.layers[sId].zIndex)
			{
				if (document.layers[n].zIndex > z)
					z = document.layers[n].zIndex;
				document.layers[n].zIndex -= 1;
			}
		}
		document.layers[sId].zIndex = z;
	}
	else
	{
		z = document.all[sId].style.zIndex;
		for(n = 0; n < document.all.length; n++)
		{
			if (document.all(n).tagName == "DIV")
			{
				if (document.all(n).style.zIndex > document.all[sId].style.zIndex)
				{
					if (document.all(n).style.zIndex > z)
						z = document.all(n).style.zIndex;
					document.all(n).style.zIndex -= 1;
				}
			}
		}
		document.all[sId].style.zIndex = z;
	}
}

function SelectForm(sFormName, blChecked)
{
	var objForm = document.forms[sFormName];
	var n;

	for (n = 0; n < objForm.length; n++)
	{
		if (objForm[n].type == 'checkbox' && objForm[n].disabled == false)
			objForm[n].checked = blChecked;
	}
}

function SetPointer(obj, sColor, nStart, nStop)
{
	var n;
	var nLength;

	if (typeof(obj.style) == 'undefined' || typeof(obj.cells) == 'undefined')
		return false;

	nLength = obj.cells.length;
	for (n = nStart; n < nLength - nStop; n++)
		obj.cells[n].bgColor = sColor;

	return true;
}

function CheckField(sFormName, sFieldName)
{
	var objForm = document.forms[sFormName];
	var n;

	if (objForm.all[sFieldName].disabled == false)
	{
		if (objForm.all[sFieldName].type == 'text' && objForm.all[sFieldName].value == '')
			return false;
		else if (objForm.all[sFieldName].type == 'checkbox')
			return objForm.all[sFieldName].checked;
	}

	return true;
}

function FocusField(sFormName, sFieldName, blFocus)
{
	var objForm = document.forms[sFormName];

	if (objForm.all[sFieldName].disabled == false)
		objForm.all[sFieldName].focus();
}

function EnableField(obj, sFilter)
{
	var s;
	var n;
	var objForm = obj.form.elements;
	var objCur;
	var blEnable;

	if (obj != null)
	{
		blEnable = obj.checked;
		for(n = 0; n < objForm.all.length; n++)
		{
			objCur = objForm.all(n);
			if (objCur.tagName == 'INPUT')
			{
				s = objCur.name;
				if (s.indexOf(sFilter) != -1)
					objForm.all(n).disabled = blEnable;
			}
		}
	}
}
