var TxPowermailTabs=new Class({initialize:function(a){this.element=$(a);if(this.element){this.menu=$$("#"+a+" a");this.show(this.getInitialTab());this.menu.each(function(b){this.setupTab(b)}.bind(this))}},setupTab:function(b){var a=this.menu.indexOf(b);b.addEvent("click",this.activate.bind(this,a))},activate:function(a){this.menu.each(function(b,c){this.hide(c)}.bind(this));this.show(a)},hide:function(a){this.menu[a].removeClass("active-tab");$(this.tabID(this.menu[a])).removeClass("active-tab-body")},show:function(a){this.menu[a].addClass("active-tab");$(this.tabID(this.menu[a])).addClass("active-tab-body")},tabID:function(a){return a.href.match(/#(\w.+)/)[1]},getInitialTab:function(){if(document.location.href.match(/#(\w.+)/)){var a=0;var b=RegExp.$1;this.menu.each(function(c,d){if(c.href.match(/#(\w.+)/)[1]===b){a=d}});return a||0}else{return 0}}});window.addEvent("domready",function(){var a=new TxPowermailTabs("tabs")});var Validator=new Class({initialize:function(c,b,d,a){if(typeof(d)==="function"){this.options=new Hash(a);this._test=d}else{this.options=new Hash(d);this._test=function(){return true}}this.error=b||"Validation failed.";this.className=c},test:function(b,a){return(this._test(b,a)&&this.testOptions(b,a))},testOptions:function(c,a){var b=true;if(this.options){this.options.each(function(d,e){if(b){b=this.methods[e]?this.methods[e](c,a,d):true}},this)}return b},methods:{pattern:function(a,c,b){return ValidationMethods.get("IsEmpty").test(a)||b.test(a)},minLength:function(a,c,b){return a.length>=b},maxLength:function(a,c,b){return a.length<=b},min:function(a,c,b){return a>=parseFloat(b)},max:function(a,c,b){return a<=parseFloat(b)},notOneOf:function(a,c,b){return b.every(function(d){return a!=d})},oneOf:function(a,c,b){return $A(b).any(function(d){return a==d})},is:function(a,c,b){return a==b},isNot:function(a,c,b){return a!=b},equalToField:function(a,c,b){return a==b.value},notEqualToField:function(a,c,b){return a!=b.value},include:function(a,c,b){return b.every(function(d){return ValidationMethods.get(d).test(a,c)})}}});var Validation=new Class({options:{onSubmit:true,stopOnFirst:false,immediate:false,focusOnError:true,useTitles:false,onFormValidate:function(a,b){},onElementValidate:function(a,b){}},initialize:function(b,a){$extend(this.options,a);this.form=$(b);if(this.options.onSubmit){this.form.addEvent("submit",this.onSubmit.bind(this))}if(this.options.immediate){this.form.getElements("input, textarea, select").each(function(c){c.addEvent("blur",function(d){this.validateField(d.target)}.bind(this))}.bind(this))}},onSubmit:function(a){if(!this.validateForm()){a.stop()}},validateForm:function(){var a=true;if(this.options.stopOnFirst){a=this.form.getElements("input, textarea, select").every(function(b){return this.validateField(b)}.bind(this))}else{this.form.getElements("input, textarea, select").each(function(c){var b=this.validateField(c);if(a&&!b){a=b}}.bind(this))}if(!a&&this.options.focusOnError){this.form.getElements("input, textarea, select").filter(function(b){return b.hasClass("validation-failed")})[0].focus()}this.options.onFormValidate(a,this.form);return a},validateField:function(a){var b=a.className.split(" ");return b.every(function(c){var d=this.test(c,a);this.options.onElementValidate(d,a);return d}.bind(this))},test:function(c,d){var a=this.get(c);var g="__advice"+c;var b="";if(this.isVisible(d)&&!a.test(d.value,d)){b=this.getAdvice(c,d);if(!b){var e=this.options.useTitle?((d&&d.title)?d.title:a.error):a.error;b=new Element("div");b.setStyles({display:"block",opacity:"0"});b.addClass("validation-advice");b.set("text",e);switch(d.type.toLowerCase()){case"checkbox":case"radio":var f=d.parentNode.parentNode;b.setProperty("id","advice-"+c+"-"+this.getElementId(f));if(f){b.inject(f,"bottom")}else{b.inject(d,"after")}break;default:b.setProperty("id","advice-"+c+"-"+this.getElementId(d));b.inject(d,"after")}}else{b.setStyles({display:"block",opacity:"0"})}b.fade(1);d.removeClass("validation-passed");d.addClass("validation-failed");return false}else{b=this.getAdvice(c,d);if(b){b.setStyles({display:"none",opacity:"0"})}d[g]=false;d.removeClass("validation-failed");d.addClass("validation-passed");return true}},isVisible:function(a){while(a.tagName!="BODY"){if(a.getStyle("display")=="none"||a.getStyle("opacity")=="0"){return false}a=a.getParent()}return true},getAdvice:function(a,b){switch(b.type.toLowerCase()){case"checkbox":case"radio":var c=b.parentNode.parentNode;advice=$("advice-"+a+"-"+this.getElementId(c))||$("advice-"+this.getElementId(c));break;default:advice=$("advice-"+a+"-"+this.getElementId(b))||$("advice-"+this.getElementId(b))}return advice},getElementId:function(a){return a.id?a.id:a.name},reset:function(){this.form.getElements("input, textarea, select").each(function(a){var b=a.getClassNames();b.each(function(d){var c=this.getAdvice(d,a);if(c){c.setStyles({display:"none",opacity:"0"})}a.removeClassName("validation-failed");a.removeClassName("validation-passed")})})},get:function(a){return ValidationMethods.methods[a]?ValidationMethods.methods[a]:ValidationMethods.methods._LikeNoIDIEverSaw_}});var ValidationMethods={get:function(a){return ValidationMethods.methods[a]?ValidationMethods.methods[a]:ValidationMethods.methods._LikeNoIDIEverSaw_},add:function(d,c,e,b){var a={};a[d]=new Validator(d,c,e,b);$extend(ValidationMethods.methods,a)},addAllThese:function(a){var b={};a.each(function(c){b[c[0]]=new Validator(c[0],c[1],c[2],(c.length>3?c[3]:{}))});$extend(ValidationMethods.methods,b)},methods:{_LikeNoIDIEverSaw_:new Validator("_LikeNoIDIEverSaw_","",function(){return true},{})}};ValidationMethods.addAllThese([["IsEmpty","",function(a){return((a===null)||(a.length===0))}],["required","Ce champ est obligatoire",function(a){return !ValidationMethods.get("IsEmpty").test(a)}],["validate-number","Veuillez entrer un chiffre valable dans ce champ",function(a){return ValidationMethods.get("IsEmpty").test(a)||(!isNaN(a)&&!/^\s+$/.test(a))}],["validate-digits","Veuillez utiliser uniquement des chiffres dans ce champ. Evitez les espaces et d\'autres caractères comme les points ou les virgules",function(a){return ValidationMethods.get("IsEmpty").test(a)||!/[^\d]/.test(a)}],["validate-alpha","Veuillez utiliser uniquement des lettres (a-z) dans ce champ",function(a){return ValidationMethods.get("IsEmpty").test(a)||/^[\sa-z\u00C0-\u00FF\-]+$/i.test(a)}],["validate-alphanum","Veuillez utiliser uniquement des lettres (a-z) ou des chiffres (0-9) dans ce champ. Aucun espace ou autres caractères ne sont autorisés.",function(a){return ValidationMethods.get("IsEmpty").test(a)||/^[\sa-z0-9\u00C0-\u00FF\-]+$/i.test(a)}],["validate-date","Veuillez entrer une date valable",function(a){var b=new Date(a);return ValidationMethods.get("IsEmpty").test(a)||!isNaN(b)}],["validate-email","Veuillez entrer une adresse email valable (test@test.com)",function(a){return ValidationMethods.get("IsEmpty").test(a)||/\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/.test(a)}],["validate-url","Veuillez entrer une URL valable (http://www.test.com)",function(a){return ValidationMethods.get("IsEmpty").test(a)||/^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_\-]*)(\.[A-Z0-9][A-Z0-9_\-]*)+)(:(\d+))?\/?/i.test(a)}],["validate-date-au","Veuillez utiliser ce format de date: jj/mm/aaaa. Par exemple 17/03/2006 pour le 17 mars 2006",function(a){if(ValidationMethods.get("IsEmpty").test(a)){return true}var b=/^(\d{2})\/(\d{2})\/(\d{4})$/;if(!b.test(a)){return false}var c=new Date(a.replace(b,"$2/$1/$3"));return(parseInt(RegExp.$2,10)==(1+c.getMonth()))&&(parseInt(RegExp.$1,10)==c.getDate())&&(parseInt(RegExp.$3,10)==c.getFullYear())}],["validate-currency-dollar","Veuillez entrer une somme en dollars valable. Par exemple $100.00.",function(a){return ValidationMethods.get("IsEmpty").test(a)||/^\$?\-?([1-9]{1}[0-9]{0,2}(\,[0-9]{3})*(\.[0-9]{0,2})?|[1-9]{1}\d*(\.[0-9]{0,2})?|0(\.[0-9]{0,2})?|(\.[0-9]{1,2})?)$/.test(a)}],["validate-selection","Veuillez faire un choix",function(a,b){return b.options?b.selectedIndex>0:!ValidationMethods.get("IsEmpty").test(a)}],["validate-one-required","Veuillez choisir une des options ci-dessus",function(a,c){var e=c.parentNode;e=e.parentNode;var b=e.getElements("input");var d=false;b.each(function(f){if(!d&&(f.type.toLowerCase()=="checkbox"||f.type.toLowerCase()=="radio")){d=f.checked}});return d}]]);