Object.extend(String.prototype,{isEmail:function(){return this.match(/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i)?true:false},isUrl:function(){var b=/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;return b.test(this)},trim:function(){return this.replace(/^\s*/,"").replace(/\s*$/,"")},empty:function(){return this.length==0?true:false},min_length:function(b){return this.length<b?true:false},isFrenchPhoneNumber:function(){var b=
this.replace(/ /g,"").replace(/\./g,"").replace(/\-/g,"").replace(/\+/g,""),a=/^0[0-9]{9}$/;return a.test(b)},ucfirst:function(){if(this.length==0)return this;var b=this.charAt(0).toUpperCase();return b+this.substr(1,this.length-1)},ucwords:function(){return this.replace(/^(.)|\s(.)/g,function(b){return b.toUpperCase()})},number_format:function(b,a,c){var d=this,e=isNaN(b=Math.abs(b))?2:b;b=a==undefined?".":a;c=c==undefined?",":c;a=d<0?"-":"";var f=parseInt(d=Math.abs(+d||0).toFixed(e))+"",g=(g=f.length)>
3?g%3:0;return a+(g?f.substr(0,g)+c:"")+f.substr(g).replace(/(\d{3})(?=\d)/g,"$1"+c)+(e?b+Math.abs(d-f).toFixed(e).slice(2):"")},checkDate:function(b){if(this.trim().empty())return false;switch(b){case "JJ-MM-AAAA":case "DD-MM-YYYY":var a=this.split("-");b=a[0];var c=a[1]-1;a=a[2];break;case "JJ/MM/AAAA":case "DD/MM/YYYY":a=this.split("/");b=a[0];c=a[1]-1;a=a[2];break;default:throw new Error("checkDate: le format d'entr\u00e9e n'est pas reconnu");}var d=new Date(a,c,b);return b==d.getDate()&&c==d.getMonth()&&
a==d.getFullYear()},reverse:function(){return this.split("").reverse().join("")},base64_decode:function(){data=this;var b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",a,c,d,e,f,g=0,i=0;e="";var h=[];if(!data)return data;data+="";do{a=b.indexOf(data.charAt(g++));c=b.indexOf(data.charAt(g++));e=b.indexOf(data.charAt(g++));f=b.indexOf(data.charAt(g++));d=a<<18|c<<12|e<<6|f;a=d>>16&255;c=d>>8&255;d=d&255;if(e==64)h[i++]=String.fromCharCode(a);else if(f==64)h[i++]=String.fromCharCode(a,
c);else h[i++]=String.fromCharCode(a,c,d)}while(g<data.length);e=h.join("");return e=e.utf8_decode()},utf8_decode:function(){str_data=this;var b=[],a=0,c=0,d=0,e=0,f=0;for(str_data+="";a<str_data.length;){d=str_data.charCodeAt(a);if(d<128){b[c++]=String.fromCharCode(d);a++}else if(d>191&&d<224){e=str_data.charCodeAt(a+1);b[c++]=String.fromCharCode((d&31)<<6|e&63);a+=2}else{e=str_data.charCodeAt(a+1);f=str_data.charCodeAt(a+2);b[c++]=String.fromCharCode((d&15)<<12|(e&63)<<6|f&63);a+=3}}return b.join("")}});
compareDate=function(b,a,c){switch(b){case "JJ-MM-AAAA":case "DD-MM-YYYY":a=a.split("-");b=new Date(a[2],a[1]-1,a[0]);a=c.split("-");c=new Date(a[2],a[1]-1,a[0]);break;case "JJ/MM/AAAA":case "DD/MM/YYYY":a=a.split("/");b=new Date(a[2],a[1]-1,a[0]);a=c.split("/");c=new Date(a[2],a[1]-1,a[0]);break;default:throw new Error("checkDate: le format d'entr\u00e9e n'est pas reconnu");}if(b.getTime()==c.getTime())return 0;else if(b.getTime()>c.getTime())return 1;else if(b.getTime()<c.getTime())return-1};