﻿// file for javascript required in login process
function idfocus()
{
	document.form1.txtLoginID.focus();
}
function openit(sURL){
	//alert(sURL);
	newwindow=open(sURL,"newwin","screenX=0,screenY=0,top=0,left=0,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=700,height=500");
}
			
function ltrim(strText) { 
	// this will get rid of leading spaces 
	while (strText.charCodeAt(0) == 160 || strText.charCodeAt(0) == 32)
	strText = strText.substring(1, strText.length)
	return strText;
}
//------------------------------------------------------------------------
function rtrim(strText){
	// this will get rid of trailing spaces 
	while (strText.charCodeAt(strText.length-1) == 160 || strText.charCodeAt(strText.length-1) == 32) 
	strText = strText.substring(0, strText.length-1); 
	return strText;
}
//------------------------------------------------------------------------
function trim(strText) {
	// this will get rid of leading/trailing spaces 
	return ltrim(rtrim(strText));
}

function submitLogin()	
{
	var blnSubmit = true;
	var sErrMsg = "";
	var blnRedirect = false;
	
	if (trim(document.form1.txtLoginID.value) == "" && trim(document.form1.txtPassword.value) == "")
	{
		sErrMsg = "Please Enter Custom ID and Password";
		blnSubmit = false;		
	}	
	else if (trim(document.form1.txtLoginID.value) != "" && trim(document.form1.txtPassword.value) == "")
	{
		sErrMsg = "Please Enter a Password";
		blnSubmit = false;	
	}
	else if (trim(document.form1.txtLoginID.value) == "" && trim(document.form1.txtPassword.value) != "")
	{
		sErrMsg = "Please Enter a Custom ID";
		blnSubmit = false;	
	}	  
	
	if (blnSubmit)
	{
		//document.forms['form1'].txtAction.value = 'LOGIN';
		//alert('action - ' + document.forms['form1'].txtAction.value)
		//document.forms['form1'].submit();
		
	}
	else if (blnRedirect)
	{
	    //alert('form')
	    //var tmp=<%=ConfigurationManager.AppSettings[\"IDREG_site\"].ToString()%>
	    //alert(tmp)
		//document.form1.action = "message.asp?msg=redirect";
		//alert(document.form1.action);
		//document.form1.submit();
	}
	else
	{
		alert(sErrMsg);
		return false;
	}
	return true;
}


