// JavaScript Document
var citzFormValidator
document.addEvent('domready', function() {

	citzFormValidator = new Form.Validator.NikeInline($('frm_Register_id'), {
    'stopOnFailure':true,
    'useTitles': true,
    'errorPrefix':''
    
  });
//'onFormValidate': function(ok, form, event) {  if(ok) $('citzregister').submit();  }

  /*By Nike: Check the 3 fields of birthdate a once, to produce only 1 error */
  citzFormValidator.add('chkbirthdate',{errorMsg:'ouille',
  test:function(el){
      return( ($('sel_Register_birthdate_day').getSelected()[0].value!='') && ($('sel_Register_birthdate_month').getSelected()[0].value!='') && ($('sel_Register_birthdate_year').getSelected()[0].value!=''))
    }
  });

  /*By Nike: Well...if you are not me, you'd probably better be asking ;) */
  citzFormValidator.add('chknativelg',{errorMsg:'ouille',
  test:function(el){
      var sfx=language_inputs.inputs.getKeys()[0];
      var sel_obj=$(language_inputs.prefix+'_input'+sfx);
      if( sel_obj.getSelected()[0].value!='' ) {
        return true;
      } else {
        return false;
      }
    }
  });
  
});


/*By Nike: Extend Moomoo Form.Validator.Inline class, be able to change some anoying markup & behaviours */
Form.Validator.NikeInline= new Class({
  Extends: Form.Validator.Inline,

  /* While we're at it, just include the extras (needed for pwd confirm)*/
  Implements: Form.Validator.Extras,
  
  initialize: function(form, options){
    this.parent(form, options);
  },


  showAdvice: function(className, field){ 
    var advice = this.getAdvice(className, field);
    if (advice && !field.retrieve(this.getPropName(className))
        && (advice.getStyle('display') == 'none'
        || advice.getStyle('visiblity') == 'hidden'
        || advice.getStyle('opacity') == 0)){
      field.store(this.getPropName(className), true);
      advice.setStyle('display', 'inline');
    }
  },

  hideAdvice: function(className, field){
    var advice = this.getAdvice(className, field);
    if (advice && field.retrieve(this.getPropName(className))){
      field.store(this.getPropName(className), false);
      advice.setStyle('display', 'none');
    }
  }
  
});
