var errorcheck;
function submitIt(UserLogin)
{
  var uid = UserLogin.userid.value; 
  var pw = UserLogin.password.value;
  uid = trimspaces(UserLogin.userid.value);
  UserLogin.userid.value = uid;
  pw = trimspaces(UserLogin.password.value);
  UserLogin.password.value = pw;
  if(!checkForChars(uid))
	{
	  if (errorCheck == 1)
	  alert("Please enter your User ID.");
	  else
	  alert("Please use letters and/or numbers with no spaces for your user ID.");
	  UserLogin.userid.focus();
	  UserLogin.userid.select();
	  return false;
	}
  if(!checkfor6(uid))
	{
	  alert("User ID must be at least 6 letters and/or numbers, without spaces.");
	  UserLogin.userid.focus();
	  UserLogin.userid.select();
	  return false;
	  }
  if(!checkForChars(pw))
	{
	  if (errorCheck == 1)
	  alert("Please enter your Password.");
	  else
	  alert("Please use letters, numbers and no spaces in the password.");
	  UserLogin.password.focus();
	  UserLogin.password.select();
	  return false;
	}
  if(!checkfor6(pw))
	{
	  UserLogin.password.focus();
	  UserLogin.password.select();
	  alert("Password must be at least 6 letters and numbers.");
	  return false;
	}
  return true;
}

function checkForChars(txtFld)
{
  var valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
  var ok = "yes";
  var temp;
  if (txtFld.length == 0)
	{
	  errorCheck = 1;
	  return false;
	}
  for (var i=0; i<txtFld.length; i++)
	{
	  temp = "" + txtFld.substring(i, i+1);
	  if (valid.indexOf(temp) == "-1") ok = "no";
	}
  if (ok == "no")
	{
	  errorCheck = 2;
	  return false;
	}
  return true;
}


function checkfor6(parm1)
{
  if (parm1.length < 6)
	{
	  return false;
	}
  else
  return true;
}


function trimspaces(field)
{
  var x
  var precount = 0;
  var postcount = 0;
  var retfield = ""
  for (x=0;x<field.length;x++)
	{
	  if (field.charAt(x) == " " )
	  precount++;
	  else
	  break;
	}
  for ( x=field.length; x>0; x-- )
	{
	  if (field.charAt(x-1) == " " )
	  postcount++;
	  else
	  break;
	}
  if (field.length == precount)
  retfield = "";
  else
  retfield = field.substring(precount,(field.length-postcount));
  return retfield;
}


