<!--
// Copyright information must stay intact
// FormCheck v1.10
// Copyright NavSurf.com 2002, all rights reserved
// Creative Solutions for JavaScript navigation menus, scrollers and web widgets
// Affordable Services in JavaScript consulting, customization and trouble-shooting
// Visit NavSurf.com at http://navsurf.com

function formCheck(formobj){
  // name of mandatory fields
  var fieldRequired = Array("name", "email", "purpose", "comments");
  // field description to appear in the dialog box
	var fieldDescription = Array("Name", "E-mail address", "Purpose of enquiry", "Comments");
  // dialog message
  var alertMsg = "Please complete the following fields:\n";

  var l_Msg = alertMsg.length;

  for (var i = 0; i < fieldRequired.length; i++){
    var obj = formobj.elements[fieldRequired[i]];
    if (obj){
      switch(obj.type){
      case "select-one":
        if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
          alertMsg += " - " + fieldDescription[i] + "\n";
        }
        break;
      case "select-multiple":
        if (obj.selectedIndex == -1){
          alertMsg += " - " + fieldDescription[i] + "\n";
        }
        break;
      case "text":
      case "textarea":
        if (obj.value == "" || obj.value == null){
          alertMsg += " - " + fieldDescription[i] + "\n";
        }
        break;
      default:
      }
      if (obj.type == undefined){
        var blnchecked = false;
        for (var j = 0; j < obj.length; j++){
          if (obj[j].checked){
            blnchecked = true;
          }
        }
        if (!blnchecked){
          alertMsg += " - " + fieldDescription[i] + "\n";
        }
      }
    }
  }

  if (alertMsg.length == l_Msg){
    // All fields have been completed; now do any validation that we need
    var email = formobj.elements["email"].value;
    var email2 = formobj.elements["email2"].value;
    if (email != email2) {
    	alert("The e-mail addresses you have provided do not match.");
      return false;
    } else {
      return true;
    }
  }else{
    alert(alertMsg);
    return false;
  }
}
// -->

