function fValidateUIDStr(xstr) 
{  
 var validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890._";
	
 for (x=0; x<xstr.length; x++)
 {
  y = xstr.charAt(x);
  if (validChars.indexOf(y) == -1)
  {
   return(false);
  }
 }
 return (true);
}

function fValidatePWStr(xstr) 
{  
 var validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
	
 for (x=0; x<xstr.length; x++)
 {
  y = xstr.charAt(x);
  if (validChars.indexOf(y) == -1)
  {
   return(false);
  }
 }
 return (true);
}

function validate_login(frm)
{
 if (frm.user.value=="")
 {
  alert('Please enter username');
  frm.user.focus();
  return(false);
 }

 if (fValidateUIDStr(frm.user.value)==false)
 {
  alert('Invalid username entered');
  frm.user.focus();
  return(false);    
 }

 if (frm.pw.value=="")
 {
  alert('Please enter password');
  frm.pw.focus();
  return(false);
 }

 if (fValidatePWStr(frm.pw.value)==false)
 {
  alert('Invalid password entered');
  frm.pw.focus();
  return(false);    
 }
      
 return(true);    
}

function fSetLoginFocus() 
{
 if (document.getElementById) 
 {
   document.getElementById("user").focus();
 }
 else
 {
  if (document.all) 
  {
   document.forms(0).item(0).focus();
  }
 }
}
