
var keep = false;
function ToggleLoginPanel()
{
	var LoginPanel = document.getElementById ('LoginPanel');
	if (LoginPanel)
	{
		var display = LoginPanel.style.display;
		if (display == 'none' || !display)
		{
			LoginPanel.style.display = 'block';
			var LoginInput = document.getElementById ('Username');
			if (LoginInput) LoginInput.focus();
			
			keep = true;
			document.onclick = CloseLoginPanel;
			document.onkeydown = EscapeLoginPanel;
	
			var UsernameField = document.getElementById ('Username');
			var PasswordField = document.getElementById ('Password');
			var SessionSubmit = document.getElementById ('SessionSubmit');
			if (UsernameField) UsernameField.onclick = Keep;
			if (PasswordField) PasswordField.onclick = Keep;
			if (SessionSubmit) SessionSubmit.onclick = Keep;
		}
		else
		{
			LoginPanel.style.display = 'none';
		}
		return false;
	}
	else return true;	
}

function Keep()
{
	keep = true;
}

function CloseLoginPanel (event)
{
	if (keep)
	{
		keep = false;
		return;
	}
	var LoginPanel = document.getElementById ('LoginPanel');
	if (!LoginPanel) return;
	LoginPanel.style.display = 'none';

	document.onclick = null;
	document.onkeydown = null;
}

function EscapeLoginPanel (event)
{
	if (window.event) event = window.event;
	var code = event.keyCode ? event.keyCode : event.which ? event.which : null;
	if (code == 27)
	{
		var LoginPanel = document.getElementById ('LoginPanel');
		if (!LoginPanel) return;
		LoginPanel.style.display = 'none';

		document.onclick = null;
		document.onkeydown = null;
	}
}




nn4 = (document.layers) ? true : false;

ie4 = (document.all) ? true : false;

dom = (document.createTextNode)? true : false;


function popupWindow(fileUrl, winW, winH, winN, scrollB) {


	var winWidth = (winW)? winW : 740;
	
	var winHeight = (winH)? winH : 520;

	var winName = (winN)? winN : 'popupWin';
	
	winWidth = parseInt(winWidth) + 18;
	winHeight = parseInt(winHeight) + 27;
		
	var scrollBars = (scrollB)? scrollB : 'auto';

	if (nn4 || ie4 || dom) {

		if (screen.width < winWidth + 50) { winWidth = screen.width - 50; scrollbars = 'yes'; }

		if (screen.height < winHeight + 100) { winHeight = screen.height - 100; scrollbars = 'yes'; }

		posX = Math.round((screen.width - winWidth) / 2);

		posY = Math.round((screen.height - winHeight) / 2);

		posCode = (nn4)? "screenX="+posX+",screenY="+posY : "left="+posX+",top="+posY;

	} else {

		posCode = "";

	}
	
	var popupWin = window.open("/"+fileUrl, winName,"menubar=no,toolbar=no,scrollbars=" + scrollBars + ",status=yes,resizable=yes,width=" + winWidth + ",height=" + winHeight + "," + posCode);

	if (popupWin) popupWin.focus();

}


	function line_highlight(obj, on, off){
		if(obj.tagName == 'TD')
			var h_obj = obj.parentNode;
		else
			var h_obj = obj;
		if(!on)
			on = 'highlight';
		h_obj.className = h_obj.className == on ? off : on;
	}
	
	
	function viewParagraph(ptable, link){
		var obj = document.getElementById(ptable);
		obj.className = obj.className == 'pNone' ? 'pVisible' : 'pNone';
		link.className = link.className == 'cur' ? '' : 'cur';
	}