function Form(oForm) {
  this.FormObj = oForm;
  
  this.setAction = function(action) {
    this.FormObj.action = action;
  }

  this.setEncription = function(enctype) {
    this.FormObj.enctype = enctype;
  }
  
  this.setMethod = function(method) {
    this.FormObj.method = method;
  }
  
  this.validate = function() {
    var msg = "";
    var formElements = this.FormObj;
    
    var attr = "";
    for(i=0; i<formElements.length; i++) {
      var BC = this.getBC();
      if(!BC) return;
   
      var oElement    = formElements[i];
      var oReq        = BC.getAttribute(oElement, "required");
      if(oReq)   oReq = oReq.toLowerCase();

      if(oReq == "yes" || oReq == "true" || oReq == "1") {
        var controlType  = BC.getAttribute(oElement, "type");
        var controlValue = BC.getAttribute(oElement, "value");
        var controlClass = BC.getAttribute(oElement, "className");
        var dataType     = BC.getAttribute(oElement, "datatype");
        var controlID    = BC.getAttribute(oElement, "id");
        var minValue     = parseFloat(BC.getAttribute(oElement, "min"));
        var maxValue     = parseFloat(BC.getAttribute(oElement, "max"));
        var numericValue = parseFloat(controlValue);
        
        if(!isNaN(minValue)) {
          if(isNaN(numericValue) || (numericValue<minValue))
            msg += "\n   - " +  controlID + " (min=" + minValue + ")";      	 
        }
        if(!isNaN(maxValue)) {
          if(isNaN(numericValue) || (numericValue>maxValue))
            msg += "\n   - " +  controlID + " (max=" + maxValue + ")";
        }
        switch(controlType) {
        	case "text":
        	case "password":
        	   if(!controlValue)
                msg += "\n   - " +  controlID;      	 
        	   break;
        	case "select-one":
        	   if(!controlValue)
                msg += "\n   - " +  controlID;      	 
            break;
        	default: 
       	       if(!controlValue)
                msg += "\n   - " +  controlID;      	 
        	 break;
        } // End switch
        
        switch(dataType) {
        	case "email":
        	   if((controlValue.indexOf("@") == -1) || (controlValue.indexOf(".") == -1))
                msg += "\n   - " +  controlID + " (invalid " + dataType + ")";
        	   break;
        } // End switch
      }
    }
    //debugger;
    if(msg) {
        msg = "Please fill in the required field(s):" + msg;
        alert(msg);
        return false;
    }
    return true;
  }
  
  this.submit = function(bRequiresValidate) {
    if(typeof(updateRTEs) != "undefined")
      updateRTEs();      
    //alert(this.FormObj.action);

    if(bRequiresValidate) {
      if(this.validate()) {
        try {
          this.FormObj.submit();
        } catch (e) {
            alert("" +
              "javascript error:"+
              "\n     file: form.js"+
              "\n     class: Form"+
              "\n     function: submit"+
              "\n     message: "+e.message+
              "");
        }
      }
    }
    else this.FormObj.submit();  
  }

  this.clear = function() {
    this.reset();
  }
  
  this.reset = function() {
    var formElements = this.FormObj;
    var BC = this.getBC();
    if(!BC) return;
    for(i=0; i<formElements.length; i++) {
      var oElement    = formElements[i];
      var controlType  = BC.getAttribute(oElement, "type");
      switch(controlType) {
      	case "text":
      	case "password":
          oElement.value  = "";
      	  break;
      	default: 
      	 break;
      } // End switch
    } // End For
  } // End function reset

  this.getBC = function() {
    var BC = null;
    try {
        BC = new BrowserComptability();
    } catch (e) {
        alert("" +
          "javascript error:"+
          "\n     file: form.js"+
          "\n     class: Form"+
          "\n     function: validate"+
          "\n     message: "+e.message+
          "\n     suggestion: Please make sure you have included browserSpecific.js"+            
          "");
    }
    return BC;
  } // End function getBC

} // End class Form