var email={tldn:RegExp("^[^@]+@[^@]+.(A[C-GL-OQ-UWXZ]|B[ABD-JM-OR-TVWYZ]|C[ACDF-IK-ORUVX-Z]|D[EJKMOZ]|E[CEGR-U]|F[I-KMOR]|G[ABD-IL-NP-UWY]|H[KMNRTU]|I[DEL-OQ-T]|J[EMOP]|K[EG-IMNPRWYZ]|L[A-CIKR-VY]|M[AC-EGHK-Z]|N[ACE-GILOPRUZ]|OM|P[AE-HKL-NR-TWY]|QA|R[EOSUW]|S[A-EG-ORT-VYZ]|T[CDF-HJ-PRTVWZ]|U[AGKMSYZ]|V[ACEGINU]|W[FS]|XN|Y[ETU]|Z[AMW]|AERO|ARPA|ASIA|BIZ|CAT|COM|COOP|EDU|GOV|INFO|INT|JOBS|MIL|MOBI|MUSEUM|NAME|NET|ORG|PRO|TEL|TRAVEL)$","i")};
(function(e){e.extend(e.expr[":"],{regex:function(b,c,f){c=RegExp(f[3],"g");b="text"===b.type?b.value:b.innerHTML;return b==""?true:c.exec(b)}});e.fn.output=function(b){return typeof b=="undefined"?this.is(":text")?this.val():this.html():this.is(":text")?this.val(b):this.html(b)};formatter={getRegex:function(b){b=e.extend({type:"decimal",precision:5,decimal:".",allow_negative:true},b);var c="";if(b.type=="decimal"){c=b.allow_negative?"-?":"";c=b.precision>0?"^"+c+"\\d+$|^"+c+"\\d*"+b.decimal+"\\d{1,"+
b.precision+"}$":"^"+c+"\\d+$"}else if(b.type=="phone-number")c="^\\d[\\d\\-]*\\d$";else if(b.type=="alphabet")c="^[A-Za-z]+$";return c},isEmail:function(b){b=e(b).output();var c=true;c=/[s~!#$%^&*+=()[]{}<>\/;:,?|]+/;if(b.match(c)!=null)return false;if(b.match(/((\.\.)|(\.\-)|(\.\@)|(\-\.)|(\-\-)|(\-\@)|(\@\.)|(\@\-)|(\@\@))+/)!=null)return false;if(b.indexOf("'")!=-1)return false;if(b.indexOf('"')!=-1)return false;if(email.tldn&&b.match(email.tldn)==null)return false;return c},formatString:function(b,
c){c=e.extend({type:"decimal",precision:5,decimal:".",allow_negative:true},c);var f=e(b).output(),d=f;if(c.type=="decimal"){if(d!=""){var a;a=c.allow_negative?"\\-":"";var g="\\"+c.decimal;d=d.replace(RegExp("[^\\d"+a+g+"]+","g"),"");a=c.allow_negative?"\\-?":"";a=c.precision>0?RegExp("^("+a+"\\d*"+g+"\\d{1,"+c.precision+"}).*"):RegExp("^("+a+"\\d+).*");d=d.replace(a,"$1")}}else if(c.type=="phone-number")d=d.replace(/[^\-\d]+/g,"").replace(/^\-+/,"").replace(/\-+/,"-");else if(c.type=="alphabet")d=
d.replace(/[^A-Za-z]+/g,"");d!=f&&e(b).output(d)}};e.fn.format=function(b,c){b=e.extend({type:"decimal",precision:5,decimal:".",allow_negative:true,autofix:false},b);var f=b.decimal;c=typeof c=="function"?c:function(){};this.keypress(function(d){e(this).data("old-value",e(this).val());var a=d.charCode?d.charCode:d.keyCode?d.keyCode:0;if(a==13&&this.nodeName.toLowerCase()!="input")return false;if(d.ctrlKey&&(a==97||a==65||a==120||a==88||a==99||a==67||a==122||a==90||a==118||a==86||a==45)||a==46&&d.which!=
null&&d.which==0)return true;if(a<48||a>57)if(b.type=="decimal"){if(b.allow_negative&&a==45&&this.value.length==0)return true;if(a==f.charCodeAt(0))return b.precision>0&&this.value.indexOf(f)==-1?true:false;if(a!=8&&a!=9&&a!=13&&a!=35&&a!=36&&a!=37&&a!=39)return false;return true}else if(b.type=="email"){if(a==8||a==9||a==13||a>34&&a<38||a==39||a==45||a==46||a>64&&a<91||a>96&&a<123||a==95)return true;if(a==64&&this.value.indexOf("@")==-1)return true;return false}else if(b.type=="phone-number"){if(a==
45&&this.value.length==0)return false;if(a==8||a==9||a==13||a>34&&a<38||a==39||a==45)return true;return false}else if(b.type=="alphabet"){if(a==8||a==9||a==13||a>34&&a<38||a==39||a>64&&a<91||a>96&&a<123)return true}else return false;else return b.type=="alphabet"?false:true}).blur(function(){if(b.type=="email")formatter.isEmail(this)||c.apply(this);else e(this).is(":regex("+formatter.getRegex(b)+")")||c.apply(this)}).focus(function(){e(this).select()});b.autofix&&this.keyup(function(){e(this).data("old-value")!=
e(this).val()&&formatter.formatString(this,b)});return this}})(jQuery);

