ONEGEEK.forms.GValidator.plugins = {
  
  account_number :{
    _extends :'GenericTextField',
    regex :/^(([0-9]{3,7}|[0-9]{9}))$/g,
    cleanRegex : /[^0-9]/g,
    errorMsg :'Please give your bank account number.',
    contextMsg :'You will use this password to login.',
  
    validate : function() {
      this.clean();
	  
	  var accountnr = this.field.value.toString();
	  
	  // Validate first with regex
      var validated = this.field.value.match(this.regex);
	  
	  //account is not POSTBANK/ING, so try 11-proef
	  if (accountnr.length == 9)
	  {
		  var sum = 0;
		  for (var i=0; i<accountnr.length; i++)
		  {
			  var digit = accountnr.charAt(i);
			  sum = sum + digit * (9-i);
		  }
		  validated = (sum % 11 == 0);
	  }
      
      // Set the state
      if (validated) {
        this.setState(ONEGEEK.forms.FIELD_STATUS_OK);
        return true;
      } else if (this.modified === false) {
        this.setState(ONEGEEK.forms.FIELD_STATUS_INFO);
      } else {
        this.setState(ONEGEEK.forms.FIELD_STATUS_ERROR);
      }
  
      return false;
    }
  },

  account_name :{
    _extends :'GenericTextField',
    regex :/^([a-zA-Z\-\'\s]{2,30})$/g,
    cleanRegex : /[^a-zA-Z\-\'\s]/g,
    errorMsg :'Your bank account name is not correct.',
    contextMsg :'Please fill in the name of your bank account.',
  
    validate : function() {
      this.clean();
  
      // Validate first with regex
      var validated = this.field.value.match(this.regex);
      
      // Set the state
      if (validated) {
        this.setState(ONEGEEK.forms.FIELD_STATUS_OK);
        return true;
      } else if (this.modified === false) {
        this.setState(ONEGEEK.forms.FIELD_STATUS_INFO);
      } else {
        this.setState(ONEGEEK.forms.FIELD_STATUS_ERROR);
      }
  
      return false;
    }
  },
  
  account_city :{
    _extends :'GenericTextField',
    regex :/^([a-zA-Z\-\'\s]{2,30})$/g,
    cleanRegex : /[^a-zA-Z\-\'\s]/g,
    errorMsg :'Your bank account name is not correct.',
    contextMsg :'Please fill in the name of your bank account.',
  
    validate : function() {
      this.clean();
  
      // Validate first with regex
      var validated = this.field.value.match(this.regex);
      
      // Set the state
      if (validated) {
        this.setState(ONEGEEK.forms.FIELD_STATUS_OK);
        return true;
      } else if (this.modified === false) {
        this.setState(ONEGEEK.forms.FIELD_STATUS_INFO);
      } else {
        this.setState(ONEGEEK.forms.FIELD_STATUS_ERROR);
      }
  
      return false;
    }
  },
  long_phone :{
    _extends :'GenericTextField',
    regex :/^([\+]?[0-9]{10,16})$/g,
    cleanRegex : /[^0-9\+]/g,
    errorMsg :'Please give your phone number.',
    contextMsg :'We will use this number to contact you.',
  
    validate : function() {
      this.clean();
  
      // Validate first with regex
      var validated = this.field.value.match(this.regex);
      
      // Set the state
      if (validated) {
        this.setState(ONEGEEK.forms.FIELD_STATUS_OK);
        return true;
      } else if (this.modified === false) {
        this.setState(ONEGEEK.forms.FIELD_STATUS_INFO);
      } else {
        this.setState(ONEGEEK.forms.FIELD_STATUS_ERROR);
      }
  
      return false;
    }
  }

}