function openPopup(href)
{
	window.open(href,"_blank","width=580,height=430,toolbar=no,scrollbars=yes,location=no,resizable=no");
	return false;
}


function openPopupWH(href,w,h)
{
	window.open(href,"_blank","width="+w+",height="+h+",toolbar=no,scrollbars=yes,location=no,resizable=no");
	return false;
}


function openHelpWindow(href)
{
	return openPopupWH(href,580,500);
}


function openModalDlg(href,nStyle,strFormName,strCmdName)
{
	switch (nStyle)
	{
		case 0:
		case 2:
		case 1:
			var res;
			if (res=window.showModalDialog(href,"","dialogWidth:590px;dialogHeight:450px;status:no"))
			{
				if (strFormName)
				{
					var o=document.forms[strFormName];
					o.insertAdjacentHTML("afterBegin",'<input type="hidden" name="dlgcmd" value="'+strCmdName+'">');
					for (i in res)
					{
//						alert(i+"="+res[i]);
						o.insertAdjacentHTML("afterBegin",'<input type="hidden" name="'+i+'" value="'+res[i]+'">');
					}
					document.forms[strFormName].submit();
				}
			}
			return true;
		default:
			alert("style"+nStyle+" not implemented!");
			break;
	}
	return false;
}


function isValidDate(v)
{
	return (Date.parse(v) && (new Date(v)).getYear()>=70 && (new Date(v)).getYear()<=2099);
}

function doAutoSubmit(frm)
{
	if (frm['apply'] && frm['apply'].length) frm['apply'][0].click();
	else if (frm['apply']) frm['apply'].click();
	else frm.submit();
}

function LST_SelectAll(listObj)
{
	var i;
	var opts=listObj.options;
	for (i=0; i<opts.length; i++)
	{
		opts[i].selected=true;
	}
}

function LST_ClearSelection(listObj)
{
	var i;
	var opts=listObj.options;
	for (i=0; i<opts.length; i++)
	{
		opts[i].selected=false;
	}	
}


function loadMain(href)
{
	window.top.main.location=href;
	return false;
}


function confirmOperation()
{
	return confirm("Do you want to proceed with the requested operation?");
}


function confirmDelete()
{
	return confirm("Do you really want to delete this document?");
}


function trim(str)
{
	return 	str.replace(/^ *| *$/g,"");
}
