iNavWidthBase = 706;
iNavHeightBase = 360;
iNavPadding = 20; //minimum padding around table
iDragDif = 105;

function showLogin()
{
		aDims = getPageSize();
		
		//do the do for the cover
		oCover = getElement("cover");
		oCover.style.width = document.body.offsetWidth + "px";
		oCover.style.height = aDims[3] + "px";
		oCover.style.visibility = "visible";
		oCover.onmousedown = hideLogin;
		
		//do the do for the navigation
		oLogin = getElement("login");

		//resize & position the nav
		iLeft = (340 > aDims[2] ? iNavPadding : parseInt((aDims[2]-340)/2));
		iTop = (260 > aDims[3] ? iNavPadding : parseInt((aDims[3]-260)/2));

		oLogin.style.left = iLeft.toString() + "px"
		oLogin.style.top = iTop.toString() + "px"
		oLogin.style.visibility = "visible";
		
		oUserName = getElement("username");
		oUserName.focus();
}

function resizeCover()
{
oCover = getElement("cover");
if (oCover.style.visibility == "visible")
	{
		showLogin()
	}
}

function hideLogin()
{
	//do the do for the cover
	oCover = getElement("cover");
	oCover.style.width = "0px";
	oCover.style.height = "0px";
	oCover.style.visibility = "hidden";
	
	//do the do for the navigation
	oLogin = getElement("login");
	oLogin.style.left = "0px";
	oLogin.style.top = "0px";
	oLogin.style.visibility = "hidden";
}

function doLogin()
{
oUser = getElement("username");
oPass = getElement("password");
sAlert = "";
if (oUser.value == "")
	{
		sAlert += "You must enter a user name.\n";
	}
if (oPass.value == "")
	{
		sAlert += "You must enter a password.\n";
	}
oChk = getElement("agree");
if (!oChk.checked)
	{
		sAlert += "You must check the \"I Agree to the terms above.\" to log in to this site";
	}
if (sAlert != "")
	{
		alert(sAlert)
	} else {
		getElement("login_form").submit();
	}
}

function clickCheck(e)
{
	if(document.all)
		{
			e = event;
			oThis = e.srcElement
		} else {
			oThis = e.target
		}
		
		if (!childCheck(oThis))
		{
			oContextMenu = getElement("contextmenu");
			oContextMenu.style.visibility = "hidden";
		}
	return false;
}

function childCheck(oCheck)
{
while (oCheck.parentNode && (oCheck.parentNode.tagName != "BODY" || oCheck.parentNode.tagName != "HTML"))
	{
		if (oCheck.getAttribute("id") == "contextmenu")
			{
				return true;
			} else {
				if(oCheck.parentNode)
					{
						oCheck = oCheck.parentNode;
					} else {
						return false;
					}
			}
	}
return false;
}

function contextMenu(e)
{
	if(document.all)e = event;
	iX = e.clientX + ((document.all) ? document.documentElement.scrollLeft : window.scrollX);
	iY = e.clientY + ((document.all) ? document.documentElement.scrollTop : window.scrollY);
	oContextMenu = getElement("contextmenu");
	if(oContextMenu != null)
		{
			oContextMenu.style.top = iY + 0 + "px";
			oContextMenu.style.left = iX + 0 + "px";
			oContextMenu.style.visibility = "visible";
			document.onmousedown = clickCheck;
		}
	return false;
}