// deze functie bepaalt de lengte van een string, dit omdat value.length niet goed
// omgaat met UTF8-karakters.
function charCount(str) {
   // counts the number of unicode characters, which may differ from str.length
   var esc = escape(str); // escape more robust than encodeURI
   return esc.replace(/%uD[C-F]../g,'')
   .replace(/%u..../g,'??')
   .replace(/%[A-F]./g,"??")
   .replace(/%../g,"'")
   .length;
}

// Haal de table node op waar het element el instaat.
function get_table_node(el) {
  var the_table = el.parentNode;
  while (the_table.nodeName != "TABLE") the_table = the_table.parentNode;
  return the_table;
}

Validation = 
function()   {     
   this.g = function(x) {     return document.getElementById(x);   }

   //defaults
   this.msg_empty          = 'Het veld <field> is verplicht';    
   this.msg_email          = 'Het veld <field> is geen geldig emailadres';    
   this.msg_number         = 'Het veld <field> is geen nummer';
   this.msg_telephone      = 'Het veld <field> is geen geldig telefoonnummer';
   this.msg_document       = 'Het veld <field> is geen geldig document (.doc, .docx, .pdf)';
   this.msg_image          = 'Het veld <field> is geen geldig document';
   this.length_textarea    =  4000;
   this.msg_length         = 'Het veld <field> bevat meer dan '+this.length_textarea+' tekens';
   this.msg_sofinr         = "Het veld <field> is geen geldig sofinummer";   
   this.msg_banknr         = "Het veld <field> is geen geldig bankrekeningnummer";   
   this.msg_postcode       = "Het veld <field> is geen geldige postcode";   
   this.dateFormat         = 'dd-mm-jjjj';
   this.msg_date_format    = 'Het veld <field> heeft niet het juiste formaat ('+this.dateFormat+')';
   this.msg_datecompare    = 'Datum <field2> mag niet voor datum <field1> liggen.';
   this.msg_date           = 'Het veld <field>: Jaar moet na 1900 liggen';
   this.msg_compare_fields = 'De velden <field1> en <field2> komen niet overeen.';
   this.checkTable         = new Array();
   this.returnOnError      = true;
   this.validateWhenHidden = true;
   this.retval             = 'true';
}

Validation.prototype.isHidden = function(el)	{
	while(el.parentNode)	{
		if(el.style.display == 'none' || el.style.visibility == 'hidden')	return true;	
		el = el.parentNode;
	}	
	return false;
}


Validation.prototype.tabelInArray =
function(tabel)  {
   if (this.checkTable.length==0) return true;

   for (var i=0; i<this.checkTable.length; i++) {
      if (tabel.id == this.checkTable[i]) return true;
   }
   return false;
}

Validation.prototype.FormValidate = 
function()   {


   var retval = true;
   var tabel;
   var veld;
   
   for(var i=0; i<this.requiredFields.length; i++)   {
     veld = this.requiredFields[i][0];
     if(this.requiredFields[i][2] == "date1" || this.requiredFields[i][2] == "date2" || this.requiredFields[i][2] == "compare" || this.requiredFields[i][2] == "compare_fields") 
        veld = this.requiredFields[i][0].split(',')[0];

     try {
        tabel =    get_table_node(this.g(veld));
     }
     catch(err) {
        tabel = "";
     }

	 
     if (tabel != "" && tabel.style.display != 'none' && this.tabelInArray(tabel)) {
	    if(!this.validateWhenHidden)	{
			if(!this.isHidden(this.g(veld)))	{
				retval = this.validateFields(i);
			}
		}
		else	{
			retval = this.validateFields(i);
		}
     }

     if (!retval) return false
   }

   if(!this.returnOnError && this.retval == 'false') {
      return false;
   }
   else   {
     return true; 
   }
}

Validation.prototype.validateFields =
function (i) {
	
   var l_tmp = this.requiredFields[i][0].split(',');
   if (this.g(this.requiredFields[i][0])  || this.g(l_tmp[0]) ) {
   
   
   
   
      // controleren van verplicht veld
      if(this.requiredFields[i][2]=="radio")   {
         if(!this.radioSelected(i)) {
            if(this.returnOnError) return false;
            else this.retval = 'false';
         }
      }
      if(this.requiredFields[i][2]=="compare") {
         if(!this.compareDates(i)) {
            if(this.returnOnError) return false;
            else this.retval = 'false';
         }
      }
      if(this.requiredFields[i][2]=="sofinr") {
         if(!this.sofiNr(i)) {
            if(this.returnOnError) return false;
            else this.retval = 'false';
         }
      }
      if(this.requiredFields[i][2]=="banknr") {
         if(!this.bankNr(i)) {
            if(this.returnOnError) return false;
            else this.retval = 'false';
         }
      }
      if(this.requiredFields[i][2]=="postcode") {
         if(!this.postcode   (i)) {
            if(this.returnOnError) return false;
            else this.retval = 'false';
         }
      }
      if(this.requiredFields[i][2]=="text") {
         if(!this.validateEmptyFields(i))   {
            if(this.returnOnError) return false;
            else this.retval = 'false';
         }
      }
      // controleren of het wel een valide emailadres is
      if(this.requiredFields[i][2]=="email") {
         if(!this.validateEmail(i)) {
            if(this.returnOnError) return false;
            else this.retval = 'false';
         }
      }
      // controleren of het nummer is
      if(this.requiredFields[i][2]=="number") {
         if(!this.validateNumber(i)) {
            if(this.returnOnError) return false;
            else this.retval = 'false';
         }
      }
      // controleren van de lengte
      if(this.requiredFields[i][2]=="length") {
         if(!this.checkLength(i)) {
            if(this.returnOnError) return false;
            else this.retval = 'false';
         }
      }
      // controleren of het een telefoonnummer is
      if(this.requiredFields[i][2]=="tele") {
         if(!this.validateTelephoneNumber(i)) {
            if(this.returnOnError) return false;
            else this.retval = 'false';
         }
      }
      // controleren of het een geldig document is
      if(this.requiredFields[i][2]=="document") {
         if(!this.validateDocument(i)) {
            if(this.returnOnError) return false;
            else this.retval = 'false';
         }
      }
      // controleren of het een geldige image is
      if(this.requiredFields[i][2]=="image") {
         if(!this.validateImage(i)) {
            if(this.returnOnError) return false;
            else this.retval = 'false';
         }
      }      
      // datumcontrolle als het om een veld gaat
      if(this.requiredFields[i][2]=="date1") {
         // opdelen van de string en in een array stoppen. 
         // 0=veld; 1=formaat; 2=scheidingsteken;
         //
         var tmp        = this.requiredFields[i][0].split(',');
         var format     = tmp[1];
         var waarde     = this.g(tmp[0]).value;
         var veld       = this.requiredFields[i][1];
            if(!this.validateDate(veld, waarde, format, tmp[0], i)) {
            if(this.returnOnError) return false;
            else this.retval = 'false';
         }
      }
      // datumcontrolle als het om drie velden gaat
      if(this.requiredFields[i][2]=="date2") {     
         // split the string and put it in an array
         var tmp = this.requiredFields[i][0].split(',');
         //
         //if(!this.validateDate(tmp[0], this.g(tmp[0]).value, this.g(tmp[1]).value, this.g(tmp[2]).value, tmp[1])) return false;
         if(!this.validateDate(this.requiredFields[i][1], this.g(tmp[0]).value+"-"+this.g(tmp[1]).value+"-"+this.g(tmp[2]).value, "dmy", tmp[0], i)) {
            if(this.returnOnError) return false;
            else this.retval = 'false';
         }
      }
      // checkbox checked controle
      if(this.requiredFields[i][2] == "checkbox")   {
         if(!this.checkboxChecked(i)) {
            if(this.returnOnError) return false;
            else this.retval = 'false';
         }
      }
      // compare 2 fields
      if(this.requiredFields[i][2] == "compare_fields")   {
         if(!this.compareFields(i)) {
            if(this.returnOnError) return false;
            else this.retval = 'false';
         }
      }
      
      return true;
   }
}   

Validation.prototype.validateEmptyFields = 
function(i)   {

   if(this.g(this.requiredFields[i][0]).value == '')   {
      
      if(typeof(this.customAlert) == 'function')   {
         var retval = this.customAlert(i, 'required');
         if(retval) return retval;
         return false;
      }
      else   {
         alert(this.msg_empty.replace('<field>', this.requiredFields[i][1])); 
         this.g(this.requiredFields[i][0]).focus();
         return false;
      } 
   }
   return true;  
}

Validation.prototype.validateEmail =
function(i)   {
      var emailReg = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{2,3}\])|(([a-zA-Z\-0-9]{2,}\.)+[a-zA-Z]{2,4}))$/;
   var regex = new RegExp(emailReg);

   if (this.g(this.requiredFields[i][0]).value=="") return true;

   if(!regex.test(this.g(this.requiredFields[i][0]).value)) {
      if(typeof(this.customAlert) == 'function')   {
         var retval = this.customAlert(i, this.requiredFields[i][2]);
         if(retval) return retval;
         return false;
      }
      else {
         alert(this.msg_email.replace("<field>", this.requiredFields[i][1]));
         this.g(this.requiredFields[i][0]).focus();
         return false;
      }
   }
   return true;
}

Validation.prototype.validateNumber =
function(i)   {
   //  check for valid numeric strings
   var strValidChars = "0123456789";
   var String        = this.g(this.requiredFields[i][0]).value;
   var strChar;

   for (j = 0; j < String.length; j++) {
      strChar = String.charAt(j);
     
      if (strValidChars.indexOf(strChar) == -1) {

         if(typeof(this.customAlert) == 'function')   {
			var retval = this.customAlert(i, this.requiredFields[i][2]);
            return (retval) ? retval : false;
         }
         else {
            alert(this.msg_number.replace("<field>", this.requiredFields[i][1]));
            this.g(this.requiredFields[i][0]).focus();
            return false;
         }
      }
   }
   return true;
}

Validation.prototype.validateTelephoneNumber =
function(i)   {
   //  check for valid numeric strings
   var strValidChars = "0123456789 -+()";
   var String        = this.g(this.requiredFields[i][0]).value;
   var strChar;

   for (j = 0; j < String.length; j++) {
      strChar = String.charAt(j);

      if (strValidChars.indexOf(strChar) == -1) {
         if(typeof(this.customAlert) == 'function')   {
			var retval = this.customAlert(i, this.requiredFields[i][2]);
            return (retval) ? retval : false;
         }
         else {
            alert(this.msg_telephone.replace("<field>", this.requiredFields[i][1]));
            this.g(this.requiredFields[i][0]).focus();
            return false;
         }
      }
   }
   return true;
}

Validation.prototype.checkExtension =
function(val, arr)   {
   var ext = this.getExtension(val);
   
   for(var i = 0; i < arr.length; i++)   {
      if(arr[i].toLowerCase() == ext.toLowerCase())   return true;
   }
   return false;
}

Validation.prototype.getExtension = 
function(val)   {
   var i = val.lastIndexOf('.');
   if(i == -1) return "";
   return val.substring(i+1);   
}

Validation.prototype.validateDocument =
function(i)   {
   var legalExt = ['doc', 'pdf', 'docx'];
   
   if  (!this.checkExtension(this.g(this.requiredFields[i][0]).value, legalExt) && this.g(this.requiredFields[i][0]).value!="") {
      if(typeof(this.customAlert) == 'function')   {
         var retval = this.customAlert(i, this.requiredFields[i][2]);
         return (retval) ? retval : false;
      }
      else {
         alert(this.msg_document.replace("<field>", this.requiredFields[i][1]));
         this.g(this.requiredFields[i][0]).focus();
         return false;
      }
   }
   return true;
}

Validation.prototype.validateImage =
function(i)   {
   var legalExt = ['jpg', 'gif', 'png', 'jpeg', 'bmp'];

   if  (!this.checkExtension(this.g(this.requiredFields[i][0]).value, legalExt) && this.g(this.requiredFields[i][0]).value!="") {
      if(typeof(this.customAlert) == 'function')   {
         var retval = this.customAlert(i, this.requiredFields[i][2]);
         return (retval) ? retval : false;
      }
      else {
         alert(this.msg_image.replace("<field>", this.requiredFields[i][1]));
         this.g(this.requiredFields[i][0]).focus();
         return false;
      }
   }
   return true;
}

Validation.prototype.validateDate =
function(veld, dateStr,format,elementId, i)   {

   if(dateStr == '') return true;

   var maanden = [
                     ["leeg"     , "0"],
                     ["Januari"  ,"31"],
                     ["Februari" ,"29"],
                     ["Maart"    ,"31"],
                     ["April"    ,"30"],
                     ["Mei"      ,"31"],
                     ["Juni"     ,"30"],
                     ["Juli"     ,"31"],
                     ["Augustus" ,"31"],
                     ["September","30"],
                     ["Oktober"  ,"31"],
                     ["November" ,"30"],
                     ["December" ,"31"]
                 ];
   
   if(format == "dmy" || format == "dd-mm-yyyy" || format == "mdy" || format == "mm-dd-yyyy")   {
      var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;
   }
   
   if(format == "my" || format == "mm-yyyy")   {
      var datePat = /^(\d{1,2})(\/|-)(\d{4})$/;
   }
   if(format == "ym" || format == "yyyy-mm")   {
      var datePat = /^(\d{2}|\d{4})(\/|-)(\d{1,2})$/;
   }
   
   var matchArray = dateStr.match(datePat); // formaat ok?
   
   if (matchArray == null) {
      if(typeof(this.customAlert) == 'function')   {
         var retval = this.customAlert(i, 'date');
         if(retval) return retval;
         return false;
      }
      else {
         alert(this.msg_date_format.replace("<field>", veld));
         this.g(elementId).focus();
         return false;
      } 
   }
   
   if(format=="dmy" || format == "dd-mm-yyyy")   {
      month = matchArray[3]; 
      day = matchArray[1];
      year = matchArray[4];
   }
   else if(format=="mdy" || format == "mm-dd-yyyy")   {
      month = matchArray[1]; 
      day = matchArray[3];
      year = matchArray[4];
   }
   else if (format == "my" || format == "mm-yyyy")   {
      month = matchArray[1]; 
      year = matchArray[3];
      day = 1;
   }
   else if(format == "ym" || format == "yyyy-mm")   {
      month = matchArray[3]; 
      year = matchArray[1];
      day = 1;
   }
   
   // remove leading '0' from months, '08' and '09' 
   if(month.substr(0,1) == '0')	{
	  month = month.substr(1,1);
   }
   
   
   if (month < 1 || month > 12) { 
      if(typeof(this.customAlert) == 'function')   {
         var retval = this.customAlert(i, 'date');
         if(retval) return retval;
         return false;
      }
      else {
         alert(this.msg_date_format.replace("<field>", veld));
         this.g(elementId).focus();
         return false;
      }  
   }

   if (day < 1 || day > 31) {
      if(typeof(this.customAlert) == 'function')   {
         var retval = this.customAlert(i, 'date');
         if(retval) return retval;
         return false;
      }
      else {
         alert(this.msg_date_format.replace("<field>", veld));
         this.g(elementId).focus();
         return false;
      }
   }
   
   if ((month==4 || month==6 || month==9 || month==11) && day==31) {
      if(typeof(this.customAlert) == 'function')   {
         var retval = this.customAlert(i, 'date');
         if(retval) return retval;
         return false;
      }
      else {
         alert( maanden[month][0] + " heeft maximaal " + maanden[month][1] + " dagen");
         this.g(elementId).focus();
         return false;
      }
   }

   if (month == 2) { // check for february 29th
      var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
      
      if (day>29 || (day==29 && !isleap)) {
         if(typeof(this.customAlert) == 'function')   {
			var retval = this.customAlert(i, 'date');
            if(retval) return retval;
            return false;
         }
         else {
            alert(year+" is geen schrikkeljaar");
            this.g(elementId).focus();
            return false;
         }
      }
   }

   if (year < 1900) { 
      if(typeof(this.customAlert) == 'function')   {
         var retval = this.customAlert(i, 'date');
         if(retval) return retval;
         return false;
      }
      else {
         alert(this.msg_date.replace("<field>", veld));
         this.g(elementId).focus();
         return false;
      }
   } 

   return true;  // date is valid
}

Validation.prototype.toDate =
function(string,mask)   { 

   var format = mask;
   var tekst  = string;

   if(format == "dmy" || format == "dd-mm-yyyy" || format == "mdy" || format == "mm-dd-yyyy")   {
      var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;
   }
   
   if(format == "my" || format == "mm-yyyy")   {
      var datePat = /^(\d{1,2})(\/|-)(\d{4})$/;
   }
   if(format == "ym" || format == "yyyy-mm")   {
      var datePat = /^(\d{2}|\d{4})(\/|-)(\d{1,2})$/;
   }
   
   var matchArray = string.match(datePat); // formaat ok?
   
   if(format=="dmy" || format == "dd-mm-yyyy")   {
      month = matchArray[3]; 
      day = matchArray[1];
      year = matchArray[4];
   }
   else if(format=="mdy" || format == "mm-dd-yyyy")   {
      month = matchArray[1]; 
      day = matchArray[3];
      year = matchArray[4];
   }
   else if (format == "my" || format == "mm-yyyy")   {
      month = matchArray[1]; 
      year = matchArray[3];
      day = 1;
   }
   else if(format == "ym" || format == "yyyy-mm")   {
      month = matchArray[3]; 
      year = matchArray[1];
      day = 1;
   }
   var datum =new Date();
   datum.setFullYear(year,month, day);

   return datum;
}

Validation.prototype.compareDates =
function(i)   {

   var veld       = this.requiredFields[i][0].split(",");

   if(this.g(veld[0]).value == '' || this.g(veld[1]).value == '')   return true;

   var prompt     = this.requiredFields[i][1].split(",");
   var datum1     = this.toDate(this.g(veld[0]).value , veld[2]);
   var datum2     = this.toDate(this.g(veld[1]).value , veld[2]);

   var alert_text = this.msg_datecompare.replace("<field1>", prompt[0]);
   alert_text     = alert_text.replace("<field2>", prompt[1]);

   if (datum1 > datum2) {
      if(typeof(this.customAlert) == 'function')   {
         var retval = this.customAlert(i, this.requiredFields[i][2]);
         if(retval) return retval;
         return false;
      }
      else {
         alert(alert_text);
         this.g(veld[0]).focus();
         return false;
      }
   }
   return true;
}

Validation.prototype.checkLength =
function(i)   {
//   if (this.g(this.requiredFields[i][0]).value.length > this.length_textarea) {
//   value.length is vervangen door de functie charCount, omdat het anders fout gaat met utf8-
//   karakters. 
      if (charCount(this.g(this.requiredFields[i][0]).value) > this.length_textarea) {
      if(typeof(this.customAlert) == 'function')   {
         var retval = this.customAlert(i, this.requiredFields[i][2]);
         return (retval) ? retval : false;
      }
      else {
         alert(this.msg_length.replace("<field>", this.requiredFields[i][1]));
         return false;
      }
   }
   else return true;
}

Validation.prototype.sofiNr =
function(i)   {
   //-    Voer een 11-proef controle uit
   var string = this.g(this.requiredFields[i][0]).value;
   
   if(string == "") return true;
   
   var j = string.indexOf(".");

   while (j >= 0) {
      string     = string.replace(".","");
      j = string.indexOf(".");            
   }

   if(string.length == 9)   {
      var sumvalue=0; checksum=0;    b=0; z=0;
      var X1 = string.substr(0, 1); X2 = string.substr(1, 1); X3 = string.substr(2, 1); X4 = string.substr(3, 1); X5 = string.substr(4, 1);
      var X6 = string.substr(5, 1); X7 = string.substr(6, 1); X8 = string.substr(7, 1); X9 = string.substr(8, 1);

      V1 = X1 * 9; V2 = X2 * 8; V3 = X3 * 7; V4 = X4 * 6; V5 = X5 * 5; V6 = X6 * 4; V7 = X7 * 3; V8 = X8 * 2; V9 = X9;

      sumvalue = parseFloat(V1) + parseFloat(V2) + parseFloat(V3) + parseFloat(V4) + parseFloat(V5) + parseFloat(V6) + parseFloat(V7) + parseFloat(V8) - parseFloat(V9);
      z = sumvalue / 11;
      b =  Math.round(z);

      if(b != z)       {
         if(typeof(this.customAlert) == 'function')   {
			var retval = this.customAlert(i, this.requiredFields[i][2]);
            return (retval) ? retval : false;
         }
         else {
            alert(this.msg_sofinr.replace("<field>", this.requiredFields[i][1]));
            return false;
         }
      }
   }
   else   {
      if(typeof(this.customAlert) == 'function')   {
         var retval = this.customAlert(i, this.requiredFields[i][2]);
         return (retval) ? retval : false;
      }
      else {
         alert(this.msg_sofinr.replace("<field>", this.requiredFields[i][1]));
         return false;
      }
   }
   return true;
}


Validation.prototype.bankNr =
function(i)   {
   //-    Voer een 11-proef controle uit
   var string = this.g(this.requiredFields[i][0]).value;

   var j = string.indexOf(".");

   while (j >= 0) {
      string     = string.replace(".","");
      j = string.indexOf(".");            
   }

   var input = string;
   var tot   = 0;
   var deel  = 0;
   var rest  = 0;

   if (input.length>9) {
      if(typeof(this.customAlert) == 'function')   {
         var retval = this.customAlert(i, this.requiredFields[i][2]);
         return (retval) ? retval : false;
      }
      else {
         alert(this.msg_banknr.replace("<field>", this.requiredFields[i][1]));
         return false;
      }
   }
   else{
      for (j=0;j<input.length;j++){
         getal=input.substr(j,1);
         tot +=getal * (9 - j);
      }
      deel =tot/11;

      rest=tot%11;

      if (rest!=0) {
         if(typeof(this.customAlert) == 'function')   {
			var retval = this.customAlert(i, this.requiredFields[i][2]);
            return (retval) ? retval : false;
         }
         else {
            alert(this.msg_banknr.replace("<field>", this.requiredFields[i][1]));
            return false;
         }
      }
   }
   return true;  
}

Validation.prototype.postcode =
function(i)   {
   var string = this.g(this.requiredFields[i][0]).value;

   if(string=="") return true;
   
   if(!string.match(/^[1-9]{1}[0-9]{3}[ ]{0,}[a-zA-Z]{2}$/))	{
      if(typeof(this.customAlert) == 'function')   {
         var retval = this.customAlert(i, this.requiredFields[i][2]);
         return (retval) ? retval : false;
      }
      else {
         alert(this.msg_postcode.replace("<field>", this.requiredFields[i][1]));
         return false;
      }
   }
   
   return true;
}

Validation.prototype.checkboxChecked =
function(i)   {
   if(!this.g(this.requiredFields[i][0]).checked)   {
      if(typeof(this.customAlert) == 'function')   {
         var retval = this.customAlert(i, this.requiredFields[i][2]);
         return (retval) ? retval : false;
      }
      else {
         alert(this.msg_empty.replace('<field>', this.requiredFields[i][1])); 
         return false;
      }
   }
   else   {
      return true;
   }
}

Validation.prototype.radioSelected = 
function(i)   {
   var tmp = this.g(this.requiredFields[i][0]);
   var form = tmp.form;
   var radio = form[ this.requiredFields[i][0] ];
   
   if(radio.length == undefined)	{ // single radio button
      if(radio.checked) return true;
   }
   else	{
      for(var j = 0; j < radio.length; j++)   {
         if(radio[j].checked) {
            return true;
         }
      }
   }
   if(typeof(this.customAlert) == 'function')   {
      var retval = this.customAlert(i, this.requiredFields[i][2]);
      return (retval) ? retval : false;
   }
   else {
     alert(this.msg_empty.replace('<field>', this.requiredFields[i][1])); 
     return false;
   }
}

Validation.prototype.compareFields = 
function(i)	{
	var tmp = this.requiredFields[i][0].split(',');
	var prompt = this.requiredFields[i][1].split(',');
	
	if(this.g(tmp[0]).value != this.g(tmp[1]).value)	{
 	   if(typeof(this.customAlert) == 'function')   {
	       var retval = this.customAlert(i, this.requiredFields[i][2]);
	       return (retval) ? retval : false;
	    }
	    else {
			alert_txt = this.msg_compare_fields.replace('<field1>', prompt[0]);
			alert_txt = alert_txt.replace('<field2>', prompt[1]);
		
			alert(alert_txt); 
			return false;
	    }
	}
	else	{
		return true;
	}
	
	
}
Validation.prototype.debug = function()	{
	alert(this.requiredFields.join('\n'));
}
