function SwitchLayer(lid)
{
	var elem = document.getElementById(lid);
	elem.style.display = elem.style.display == 'none' ? '' : 'none';
}

function getWinSize(popW,popH)
{
	var winW=screen.availWidth;
	var winH=screen.availHeight;

	leftPos = Math.round((winW - popW) / 2);
	topPos = Math.round((winH - popH) / 2);
}

var BaseUrl = null;
function OpenWindow(popW, popH, loc, winname)
{
	getWinSize(popW,popH);
	window.open(BaseUrl + loc, winname, "scrollbars=yes,resizable=yes,left=" + leftPos + ",width=" + popW + ",top=" + topPos + ",height=" + popH);
}

function ShowWindow(popW, popH, loc)
{
	getWinSize(popW,popH);	
	window.open(BaseUrl + loc, null, "scrollbars=yes,resizable=yes,left=" + leftPos + ",width=" + popW + ",top=" + topPos + ",height=" + popH);
	//window.showModalDialog(BaseUrl + loc, null, "status:no;help:no;bord1er:thin;statusbar:no;scroll:no;dialogWidth:" + popW + "px;dialogHeight:" + popH + "px;");
}

function SetBlankPassword(elemId)
{
	document.getElementById(elemId).value = '******';
}

var saveInputId = null;

function SelectDateTime(inputId)
{	
	saveInputId = inputId;
	ShowWindow(380, 240, "Protect/selectdate.aspx?date=" + escape(document.getElementById(saveInputId).value));
}

function OnSelectDate(dt)
{
	if(saveInputId && document.getElementById(saveInputId))
		document.getElementById(saveInputId).value = dt;
}

function EndSelectDate(dt)
{
	if(window.opener && window.opener.OnSelectDate) 
		window.opener.OnSelectDate(dt);
	window.close();	
}
