/*
	Name					: Himanshu Shah
	Created On				: 27/11/2002
	Modified By				:
	Last Modified date	:
	Called By				: Login.htm
	Reason					: For javascript functions required in Login.htm
	Calling					: 
*/
	var i = 0 ;
/* this function is called to do validations during submit of the form when an enter key is pressed */	
	function TrapEnterKey()
	{
		if(window.event.keyCode == 13)
		{
 			//alert(event.srcElement.tagName);
 			if(Trim(event.srcElement.tagName.toUpperCase()) != "A")
			{
				FormSubmit(document.frmLogin);
			}
		}
	}
	function kp_convert_upper() 
	{
	     if ((event.keyCode >= 97 && event.keyCode <= 122))
	         event.keyCode -= 32;
	}


/* this function is called to do validations during submit of the form */		
	function FormSubmit(FormName)
	{
		if (FormName.item().name == "txtUserName")
		{
			txtCtrValue = new String();
			
			
			// Check if the something is entered in the username field
			if ( FormName.item("txtUserName").value.length > 0 )
			{
				// if something entered then trim the spaces
				txtCtrValue = Trim(FormName.item("txtUserName").value);
			}
			else 
			{
				txtCtrValue = FormName.item("txtUserName").value ;
			}	
			if (txtCtrValue == "")
			{
				FormControlName = new String();
				// Call the TrimPrefix function to trim the 3 characters prefix
				FormControlName = TrimPrefix(FormName.item("txtUserName").name);
				alert(MSG_EMPTY_TEXTFIELD + FormControlName + " !");
				FormName.item("txtUserName").value="";
				FormName.item("txtUserName").focus();
				return;
			}
			else 
			{
				// if something is entered in username then only check for password entry.
				txtCtrValue = new String();
				if ( FormName.item("txtPassword").value.length > 0 )
				{
					txtCtrValue = Trim(FormName.item("txtPassword").value);
				}
				else 
				{
					txtCtrValue = FormName.item("txtPassword").value ;
				}		
				if (txtCtrValue == "")
				{
					FormControlName = new String();
					FormControlName = TrimPrefix(FormName.item("txtPassword").name);
					alert(MSG_EMPTY_TEXTFIELD + FormControlName + " !");
					FormName.item("txtPassword").value="";
					FormName.item("txtPassword").focus();
					return;
				}
				else
				{
					
					
					
					FormName.action = "ValidateLogin.asp";
					FormName.method = "post";
					FormName.submit();
				}
			}	
		}
	}
	
/* this function is called to do clear content and reset the controls of the form when reset button is clicked */		
	function FormReset(FormName)
	{
		FormName.reset();
	}	