/** Valid Form Input
P0 = Id of form,
P1 = Field Id,
P2 = Field Label
P3 = Required field if true,
P4 = Validation required or none,
p5 to P8 = same as above for next field 
*/
function CheckForm(){
  var FErrors= "";
  var oForm = document.getElementById('formId' + arguments[0]);
  var formLength = oForm.elements.length;
		
  for(arg = 1 ; arg <= arguments.length -4; ) {

    FId = arguments[arg++];
    FLabel = arguments[arg++];
    FReq = arguments[arg++];
    FTest = arguments[arg++];

    for(i=0;i<=formLength-1;i++){

      if(oForm.elements[i].id == FId){

        var inputtext = oForm.elements[i].value;
        j=formLength;
        if (FReq & inputtext=="") {
          FErrors = FErrors + FLabel + " must be entered.\n";
        } else if (inputtext!="" & FTest!="none") {
          if (FTest=="numeric") {
            if (!inputtext.match(/^[0-9]+$/)) {
              FErrors = FErrors + FLabel + " must be numeric.\n";
            }
          } else if (FTest=="aplhanum") {
            if (!inputtext.match(/^[0-9a-zA-Z]+$/)) {
              FErrors = FErrors + FLabel + " must be alphanumeric.\n";
            }
          } else if (FTest=="email") {
            if (inputtext.match(/^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,6}$/)==null) {
              FErrors = FErrors + FLabel + " must be a valid email address format.\n";
            }
          } else {
            FErrors = FErrors + FLabel + "requires unknown validation.\n";
          }
        }
      }
    }
  }

  if(FErrors!=""){
    alert("Please correct the following fields...\n" + FErrors);
    return false;
  }
}		

