
function checkText(theField, theMessage){

	if(!allValid){
		return false;
	}

  	if (theField.value == ""){
      alert(theMessage);
      theField.focus();
      allValid = false;
    }
}

function checkNum(theField, theMessage)
{
	var checkOK = "0123456789";
    var allNum = "";
	var theString = theField.value;

	if(!allValid)
	{
		return false;
	}

	if (theString.length == 0)
	{
      	allValid = false;
	}

    for (i = 0;  i < theString.length;  i++)
	{
      ch = theString.charAt(i);
      for (j = 0;  j < checkOK.length;  j++)
        if (ch == checkOK.charAt(j))
          break;
          if (j == checkOK.length)
		  {
             allValid = false;
          }
      allNum += ch;
    }

	if(!allValid)
	{
    	alert(theMessage);
        theField.focus();
        allValid = false;
		return false;
	}
}

function checkString(theField, theMessage){
	var checkOK = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    var allNum = "";
	var theString = theField.value;

	if(!allValid){
		return false;
	}

	if (theString.length == 0){
      allValid = false;
	}

    for (i = 0;  i < theString.length;  i++)
	{
      ch = theString.charAt(i);
      for (j = 0;  j < checkOK.length;  j++)
        if (ch == checkOK.charAt(j))
          break;
          if (j == checkOK.length)
		  {
             allValid = false;
          }
      allNum += ch;
    }

	if(!allValid){
    	alert(theMessage);
        theField.focus();
        allValid = false;
		return false;
	}
}



	
function checkEmail(theField, theMessage) {
  	var str = theField.value;

	if(!allValid){
		return false;
	}

    if (window.RegExp) {
      var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
      var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$";
      var reg1 = new RegExp(reg1str);
      var reg2 = new RegExp(reg2str);
      if (!reg1.test(str) && reg2.test(str)) {
        return true;
      }
      	allValid = false;
    } else {
      if(str.indexOf("@") >= 0)
        return true;
      	allValid = false;
    }

	if(!allValid){
    	alert(theMessage);
        theField.focus();
        allValid = false;		
		return false;
	}

}

function checkBox(theField, theMessage)
{
	if(!allValid)
	{
		return false;
	}
	
  	if (!theField.checked )
	{
      alert(theMessage);
      theField.focus();
      allValid = false;
    }
}
