Element.extend({serializeFormElements:function(_19){
var _1a=new Object();
_1a["formName"]=this.name;
var _1b=this.getFormElements();
_1b.each(function(el){
if(!el.disabled&&el.name){
var key=el.name;
if(isDefined(_19)){
if(_19.stripLeading!=null){
if(key.substring(0,_19.stripLeading.length)==_19.stripLeading){
key=key.substring(_19.stripLeading.length);
}
}
}
key=camelCaseObjName(key);
var _1e=el.getValue();
if(_1e!=null&&_1e!==false){
if(key in _1a){
if($type(_1a[key])!="array"){
_1a[key]=[_1a[key]];
}
_1a[key].push(_1e);
}else{
_1a[key]=_1e;
}
}
}
});
return _1a;
}});
var FormSubmitter=new Class({initialize:function(_1f,_20){
this.element=$(_1f);
this.buttons=new Array();
this.enabled=true;
this.element.addEvent("submit",function(_21){
_21=new Event(_21).stop();
if(this.isEnabled()){
this.doSubmit();
}
}.bind(this));
this.setOptions(_20);
if(this.options.initialize){
this.options.initialize.call(this);
}
this.setStateClear();
if(!isDefined(this.options.notifierOptions)){
this.options.notifierOptions={commonName:"Submit"};
}else{
if(!isDefined(this.options.notifierOptions.commonName)){
this.options.notifierOptions.commonName="Submit";
}
}
this.notifier=new NotificationIcon(this.options.notifierOptions);
},doSubmit:function(){
this.disableAllButtons();
this.notifier.showProcessing();
this.element.submit();
},buttons:null,disableAllButtons:function(){
if(this.isEnabled()){
this.buttons.each(function(_22,_23){
_22.disable();
}.bind(this));
this.enabled=false;
}
},enableAllButtons:function(){
if(this.enabled==false){
this.buttons.each(function(_24,_25){
_24.enable();
}.bind(this));
this.enabled=true;
}
},isEnabled:function(){
return this.enabled;
},registerButton:function(_26){
this.buttons.push(_26);
},options:{}});
FormSubmitter.implement(new Events,new Options,new ProcessingStates);
var ValidateFormSubmitter=FormSubmitter.extend({initialize:function(_27,_28){
this.parent(_27,_28);
this.fields=new Array();
},fields:null,doSubmit:function(){
if(this.isStateValid()){
this.parent();
}else{
if(this.isEnabled()){
this.disableAllButtons();
var _29=this.check();
}
}
},disableAllFields:function(){
this.setFieldsEnabled(false);
this.notifier.hide();
},enableAllFields:function(){
this.setFieldsEnabled(true);
},setFieldsEnabled:function(_2a){
this.fields.each(function(_2b,_2c){
_2b.setEnabled(_2a);
}.bind(this));
},registerFieldValidator:function(_2d){
this.fields.push(_2d);
},check:function(){
this.setStateClear();
var _2e=new Array();
this.fields.each(function(_2f,_30){
if(_2f.isEnabled()){
_2e.push(_2f);
}
}.bind(this));
if(_2e.length>0){
_2e.each(function(_31,_32){
_31.setStateClear();
}.bind(this));
_2e.each(function(_33,_34){
_33.checkImmediate(function(){
this.wakeCheck(_34);
}.bind(this));
}.bind(this));
}else{
this.wakeCheck();
}
if(this.isStateUndetermined()){
this.notifier.showProcessing();
}
return false;
},wakeCheck:function(_35){
var _36=0;
var _37=0;
var _38=0;
this.fields.each(function(_39,_3a){
if(_39.isEnabled()){
_36++;
if(_39.isStateDone()){
_37++;
if(_39.isStateError()){
_38++;
}
}
}
}.bind(this));
if(_37<_36){
return;
}
if(_38>0){
this.setStateInvalid();
this.notifier.showInvalid(this.options.defaultInvalidMessage,1);
this.enableAllButtons();
return;
}else{
this.setStateValid();
this.notifier.showProcessing(this.options.defaultValidMessage);
this.doSubmit();
return;
}
},options:{requestTimeout:5000,requestDelay:500,stickyTimeout:200,defaultValidMessage:"",defaultInvalidMessage:"Please correct errors.",timeoutCounter:0}});
var AjaxValidateFormSubmitter=ValidateFormSubmitter.extend({initialize:function(_3b,_3c){
this.parent(_3b,_3c);
if(isDefined(this.options.submitController)){
}else{
this.submitController=window[this.element.name+this.options.submitControllerNameExtension];
}
},doSubmit:function(){
if(this.isStateValid()){
this.serverErrors=0;
var _3d={callback:function(_3e){
this.handleSubmitResponse(_3e);
}.bind(this),errorHandler:function(_3f,_40){
this.handleSubmitError(_3f);
}.bind(this),exceptionHandler:function(_41,_42){
this.handleSubmitException(_41,_42);
}.bind(this),timeout:this.options.submitTimeout};
this.submitController.submitForm(this.element.serializeFormElements({stripLeading:this.options.stripLeading}),_3d);
return false;
}else{
if(this.isEnabled()){
this.disableAllButtons();
return this.check();
}
}
},handleSubmitError:function(msg,_44){
alert("handleSubmitError: "+msg);
this.serverErrors++;
},handleSubmitException:function(msg,_46){
alert("handleSubmitException: "+msg);
this.serverErrors++;
},handleSubmitResponse:function(_47){
if(_47.responseType==this.responseTypes.redirect){
window.location.href=_47.instruction;
this.notifier.showProcessing();
}else{
if(_47.responseType==this.responseTypes.failed){
setTimeout(function(){
this.notifier.showInvalid(_47.instruction,1);
}.bind(this),500);
this.setStateInvalid();
this.enableAllButtons();
}else{
if(_47.responseType==this.responseTypes.message){
setTimeout(function(){
var _48="175";
var _49="400";
if(_47.modalBoxHeight){
_48=_47.modalBoxHeight;
}
if(_47.modalBoxWidth){
_49=_47.modalBoxWidth;
}
if(_47.modalBoxUrl){
MOOdalBox.open(_47.modalBoxUrl,null,_49+" "+_48);
this.notifier.hide();
}else{
this.notifier.showValid(_47.instruction,1);
}
}.bind(this),500);
this.setStateClear();
this.enableAllButtons();
}else{
if(_47.responseType=this.responseTypes.systemError){
this.element.submit();
this.notifier.showProcessing();
}
}
}
}
},responseTypes:{message:"message",redirect:"redirect",failed:"failed",systemError:"system error"},options:{submitControllerNameExtension:"SubmitController",submitTimeout:0,maxServerErrors:2}});
var FormFieldValidator=new Class({initialize:function(_4a,_4b){
this.element=$(_4a);
var _4c=false;
if(_4c){
if(this.element.getTag()=="select"){
this.element.addEvent("change",function(_4d){
this.checkSoon();
}.bind(this));
this.element.addEvent("blur",function(_4e){
this.checkSoon();
}.bind(this));
}else{
this.element.addEvent("keyup",function(_4f){
this.checkTyping();
}.bind(this));
this.element.addEvent("blur",function(_50){
this.checkSoon();
}.bind(this));
}
}
this.setOptions(_4b);
if(this.options.initialize){
this.options.initialize.call(this);
}
this.setStateClear();
if(!isDefined(this.options.notifierOptions)){
this.options.notifierOptions={commonName:this.element.id};
}
this.notifier=new NotificationIcon(this.options.notifierOptions);
this.setEnabled(this.options.enabled);
},setEnabled:function(_51){
if(_51){
this.enable();
}else{
this.disable();
}
},enable:function(){
this.enabled=true;
},disable:function(){
this.notifier.hide();
this.enabled=false;
},isDisabled:function(){
return !this.enabled;
},isEnabled:function(){
return this.enabled;
},checkImmediate:function(_52){
this.check(true,_52);
},checkSoon:function(_53){
this.check("soon",_53);
},checkTyping:function(_54){
this.check("typing",_54);
},check:function(_55,_56){
this.setStateProcessing();
clearInterval(this.sendVerifyRequestPending);
if(_55===true||_55=="immediate"){
this.validationPendingCounter=0;
this.sendVerifyRequest(_56);
}else{
if(_55=="typing"){
this.sendVerifyRequestPending=setTimeout(function(){
this.sendVerifyRequest(_56);
}.bind(this),this.options.requestTypingDelay);
}else{
if(_55=="soon"){
this.sendVerifyRequestPending=setTimeout(function(){
this.sendVerifyRequest(_56);
}.bind(this),this.options.requestSoonDelay);
}else{
this.sendVerifyRequestPending=setTimeout(function(){
this.sendVerifyRequest(_56);
}.bind(this),this.options.requestDelay);
}
}
}
},sendVerifyRequest:function(_57){
this.setStateValid();
if(isDefined(_57)){
_57(this);
}
return true;
},options:{enabled:true,requestTimeout:5000,requestDelay:500,requestSoonDelay:50,requestTypingDelay:1000,stickyTimeout:200,submissionRetries:2,sMode:false},timeoutCounter:0,validationPendingCounter:0,validationRequestCounter:0,validationResponseCounter:0});
FormFieldValidator.implement(new Events,new Options,new ProcessingStates);
var RegexFormFieldValidator=FormFieldValidator.extend({options:{defaultValidMessage:"",defaultInvalidMessage:"Field invalid.",matchListDefault:[{regex:/^\s*$/,invert:true,invalidMessage:"This is a required field."}]},initialize:function(_58,_59){
this.options.matchList=this.options.matchListDefault.copy();
this.parent(_58,_59);
},addRegexEntry:function(_5a){
this.options.matchList.include(_5a);
},sendVerifyRequest:function(_5b){
var _5c=true;
var _5d=null;
this.options.matchList.each(function(_5e,_5f){
var _60=this.element.getValue();
var _61=_5e.regex.test(_60);
if(_5e.invert==true){
if(_61==true){
_5c=false;
if(_5d==null&&isDefined(_5e.invalidMessage)){
_5d=_5e.invalidMessage;
}
}
}else{
if(_61==false){
_5c=false;
if(_5d==null&&isDefined(_5e.invalidMessage)){
_5d=_5e.invalidMessage;
}
}
}
}.bind(this));
if(_5c){
if(_5d==null){
_5d=this.options.defaultValidMessage;
}
this.notifier.showValid(_5d,5);
this.setStateValid();
if(isDefined(_5b)){
_5b(this);
}
return true;
}else{
if(_5d==null){
_5d=this.options.defaultInvalidMessage;
}
this.notifier.showInvalid(_5d,1);
this.setStateInvalid();
if(isDefined(_5b)){
_5b(this);
}
return false;
}
}});
var CreditCardFormFieldValidator=FormFieldValidator.extend({options:{defaultValidMessage:"",defaultInvalidMessage:"Card number invalid.",matchList:[{regex:/^\s*$/,invert:true,invalidMessage:"This is a required field."},{regex:/^\d+$/,invert:false,invalidMessage:"Only digits allowed."}]},initialize:function(_62,_63){
this.parent(_62,_63);
},massageNumber:function(_64){
var _65=new String(_64);
var _66=new RegExp("[- ]","g");
var _67=_65.replace(_66,"");
return _67;
},isNumberValid:function(_68){
var sum=0;
var _6a=false;
for(var i=_68.length-1;i>=0;i--){
var n=parseInt(_68.substring(i,i+1));
if(_6a){
n*=2;
if(n>9){
n=(n%10)+1;
}
}
sum+=n;
_6a=!_6a;
}
var ret=(sum%10==0);
return ret;
},sendVerifyRequest:function(_6e){
var _6f=this.element.getValue();
var _70=this.massageNumber(_6f);
var _71=true;
var _72=null;
this.options.matchList.each(function(_73,_74){
var _75=_73.regex.test(_70);
if(_73.invert==true){
if(_75==true){
_71=false;
if(_72==null&&isDefined(_73.invalidMessage)){
_72=_73.invalidMessage;
}
}
}else{
if(_75==false){
_71=false;
if(_72==null&&isDefined(_73.invalidMessage)){
_72=_73.invalidMessage;
}
}
}
}.bind(this));
var _76=(this.options.cardNumberLastFour?this.options.cardNumberLastFour.value:null);
if(_71&&(_70.length==4)&&(_76!=null)&&(_76.length>0)){
if((_76!=null)&&(_76.length==4)&&(_76!=_70)){
_71=false;
_72="The last four digits don't match the current card. ("+_76+")";
}
}else{
if(_71&&!this.isNumberValid(_70)){
_71=false;
_72="The card number is invalid.";
}
}
if(_71){
if(_72==null){
_72=this.options.defaultValidMessage;
}
this.notifier.showValid(_72,5);
this.setStateValid();
if(isDefined(_6e)){
_6e(this);
}
return true;
}else{
if(_72==null){
_72=this.options.defaultInvalidMessage;
}
this.notifier.showInvalid(_72,1);
this.setStateInvalid();
if(isDefined(_6e)){
_6e(this);
}
return false;
}
}});
var EmailFormFieldValidator=FormFieldValidator.extend({options:{validationOn:true,defaultValidMessage:"",defaultInvalidMessage:"Field invalid.",matchList:[{regex:/^\s*$/,invert:true,invalidMessage:"This is a required field."},{regex:/@/,invert:false,invalidMessage:"Must contain the @ character"}]},initialize:function(_77,_78){
this.parent(_77,_78);
},sendVerifyRequest:function(_79){
if(!this.options.validationOn){
return;
}
var _7a=true;
var _7b=null;
this.options.matchList.each(function(_7c,_7d){
var _7e=this.element.getValue();
var _7f=_7c.regex.test(_7e);
if(_7c.invert==true){
if(_7f==true){
_7a=false;
if(_7b==null&&isDefined(_7c.invalidMessage)){
_7b=_7c.invalidMessage;
}
}
}else{
if(_7f==false){
_7a=false;
if(_7b==null&&isDefined(_7c.invalidMessage)){
_7b=_7c.invalidMessage;
}
}
}
}.bind(this));
if(this.options.maxLength&&(this.element.getValue().length>this.options.maxLength)){
_7a=false;
_7b="Must be less than 50 characters in length.";
}
if(_7a&&isDefined(this.options.matchEmail)){
if(this.element.getValue()==this.options.matchEmail.getValue()){
_7a=true;
}else{
_7b="Email fields must match.";
_7a=false;
}
this.options.validationOn=false;
this.options.matchEmail.validator.checkImmediate();
this.options.validationOn=true;
}
if(_7a){
if(_7b==null){
_7b=this.options.defaultValidMessage;
}
this.notifier.showValid(_7b,5);
this.setStateValid();
if(isDefined(_79)){
_79(this);
}
return true;
}else{
if(_7b==null){
_7b=this.options.defaultInvalidMessage;
}
this.notifier.showInvalid(_7b,1);
this.setStateInvalid();
if(isDefined(_79)){
_79(this);
}
return false;
}
}});
var PhoneNumberFormFieldValidator=FormFieldValidator.extend({options:{defaultValidMessage:"",defaultInvalidMessage:"Phone number invalid.",matchList:[{regex:/^\s*$/,invert:true,invalidMessage:"This is a required field."},{regex:/^\d{10}$/,invert:false,invalidMessage:"Must be a 10 digit number."}]},initialize:function(_80,_81){
this.parent(_80,_81);
},massageNumber:function(_82){
var _83=new String(_82);
var _84=new RegExp("[()\\- ]","g");
var _85=_83.replace(_84,"");
return _85;
},sendVerifyRequest:function(_86){
var _87=this.element.getValue();
var _88=this.massageNumber(_87);
var _89=true;
var _8a=null;
this.options.matchList.each(function(_8b,_8c){
var _8d=_8b.regex.test(_88);
if(_8b.invert==true){
if(_8d==true){
_89=false;
if(_8a==null&&isDefined(_8b.invalidMessage)){
_8a=_8b.invalidMessage;
}
}
}else{
if(_8d==false){
_89=false;
if(_8a==null&&isDefined(_8b.invalidMessage)){
_8a=_8b.invalidMessage;
}
}
}
}.bind(this));
if(_89){
if(_8a==null){
_8a=this.options.defaultValidMessage;
}
this.notifier.showValid(_8a,5);
this.setStateValid();
if(isDefined(_86)){
_86(this);
}
return true;
}else{
if(_8a==null){
_8a=this.options.defaultInvalidMessage;
}
this.notifier.showInvalid(_8a,1);
this.setStateInvalid();
if(isDefined(_86)){
_86(this);
}
return false;
}
}});
var CheckboxFormFieldValidator=FormFieldValidator.extend({options:{defaultValidMessage:"",defaultInvalidMessage:""},initialize:function(_8e,_8f){
this.parent(_8e,_8f);
},sendVerifyRequest:function(_90){
var _91=this.element.getValue();
var _92=this.element.checked;
var _93=this.options.invalidMessage;
if(_92){
if(_93==null){
_93=this.options.defaultValidMessage;
}
this.notifier.showValid(_93,5);
this.setStateValid();
if(isDefined(_90)){
_90(this);
}
return true;
}else{
if(_93==null){
_93=this.options.defaultInvalidMessage;
}
this.notifier.showInvalid(_93,1);
this.setStateInvalid();
if(isDefined(_90)){
_90(this);
}
return false;
}
}});
var MonthYearFieldsValidator=FormFieldValidator.extend({options:{validateExpirationDate:false,defaultValidMessage:"",defaultInvalidMessage:"This is a required field."},initialize:function(_94,_95){
this.parent(_94,_95);
},sendVerifyRequest:function(_96){
var _97=true;
var _98=null;
var _99=this.options.monthElement.getValue();
var _9a=this.options.yearElement.getValue();
if(!_99||!_9a){
_97=false;
}
if(this.options.validateExpirationDate){
var now=new Date();
var _9c=now.getMonth()+1;
var _9d=now.getFullYear();
if(_9a.toInt()==_9d.toInt()){
if(_99.toInt()<_9c.toInt()){
_97=false;
_98="Date must be in the future.";
}
}
}
if(_97){
if(_98==null){
_98=this.options.defaultValidMessage;
}
this.notifier.showValid(_98,5);
this.setStateValid();
if(isDefined(_96)){
_96(this);
}
return true;
}else{
if(_98==null){
_98=this.options.defaultInvalidMessage;
}
this.notifier.showInvalid(_98,1);
this.setStateInvalid();
if(isDefined(_96)){
_96(this);
}
return false;
}
}});
var MatchFormFieldValidator=FormFieldValidator.extend({options:{defaultValidMessage:"",defaultInvalidMessage:"Fields must match."},initialize:function(_9e,_9f){
this.parent(_9e,_9f);
},sendVerifyRequest:function(_a0){
var _a1=true;
var _a2=null;
if(isDefined(this.options.match)){
if(this.element.getValue()==this.options.match.getValue()){
_a1=true;
}else{
_a1=false;
}
}else{
_a1=true;
}
if(_a1){
if(_a2==null){
_a2=this.options.defaultValidMessage;
}
this.notifier.showValid(_a2,5);
this.setStateValid();
if(isDefined(_a0)){
_a0(this);
}
return true;
}else{
if(_a2==null){
_a2=this.options.defaultInvalidMessage;
}
this.notifier.showInvalid(_a2,1);
this.setStateInvalid();
if(isDefined(_a0)){
_a0(this);
}
return false;
}
}});
var ElementDisabler=new Class({initialize:function(_a3,_a4){
this.element=$(_a3);
this.fx=new Fx.Style(this.element,"opacity",{duration:250,transition:Fx.Transitions.Cubic.easeInOut,wait:false});
this.enable();
},click:function(){
this.disable();
},disable:function(){
this.enabled=false;
this.fx.start(0.25);
this.element.style.cursor="wait";
},enable:function(){
this.enabled=true;
this.fx.start(1);
this.element.style.cursor="auto";
}});
ElementDisabler.implement(new Events,new Options);
var ClickDisabler=ElementDisabler.extend({initialize:function(_a5,_a6){
this.parent(_a5,_a6);
this.element.addEvent("click",function(_a7){
if(this.enabled){
this.disable();
}else{
_a7=new Event(_a7).stop();
}
}.bind(this));
}});
var ZipcodeFormFieldValidator=FormFieldValidator.extend({options:{defaultValidMessage:"",defaultInvalidMessage:"Zip/Postal code invalid.",matchList:[{regex:/^\s*$/,invert:true,invalidMessage:"This is a required field."},{regex:/^\d{5}(\d{4})?$/,invert:false,invalidMessage:"Zip code must be a 5 or 9 digit number.",country:"US"},{regex:/^[A-Z][0-9][A-Z][0-9][A-Z][0-9]$/,invert:false,invalidMessage:"Not a valid postal code for this country.",country:"CA"},{regex:/^[A-Z][0-9][A-Z][0-9][A-Z][0-9]$/,invert:false,invalidMessage:"Not a valid postal code for this country.",country:"GB"}]},initialize:function(_a8,_a9){
this.parent(_a8,_a9);
},massageNumber:function(_aa){
var _ab=new String(_aa.toUpperCase());
var _ac=new RegExp("[()\\- ]","g");
var _ad=_ab.replace(_ac,"");
return _ad;
},sendVerifyRequest:function(_ae){
var _af=this.element.getValue();
var _b0=this.massageNumber(_af);
var _b1=true;
var _b2=null;
this.options.matchList.each(function(_b3,_b4){
var _b5=this.options.country;
if(_b3.country&&_b5&&_b3.country==_b5[_b5.selectedIndex].value){
var _b6=_b3.regex.test(_b0);
if(_b3.invert==true){
if(_b6==true){
_b1=false;
if(_b2==null&&isDefined(_b3.invalidMessage)){
_b2=_b3.invalidMessage;
}
}
}else{
if(_b6==false){
_b1=false;
if(_b2==null&&isDefined(_b3.invalidMessage)){
_b2=_b3.invalidMessage;
}
}
}
}
}.bind(this));
if(_b1){
if(_b2==null){
_b2=this.options.defaultValidMessage;
}
this.notifier.showValid(_b2,5);
this.setStateValid();
if(isDefined(_ae)){
_ae(this);
}
return true;
}else{
if(_b2==null){
_b2=this.options.defaultInvalidMessage;
}
this.notifier.showInvalid(_b2,1);
this.setStateInvalid();
if(isDefined(_ae)){
_ae(this);
}
return false;
}
}});
var InternationalPhoneNumberFormFieldValidator=FormFieldValidator.extend({options:{defaultValidMessage:"",defaultInvalidMessage:"Phone number invalid.",matchList:[{regex:/^\s*$/,invert:true,invalidMessage:"This is a required field."},{regex:/^\d{10}$/,invert:false,invalidMessage:"Must be a 10 digit number.",country:"US"},{regex:/^\d{10,11}$/,invert:false,invalidMessage:"Must be a 10 or 11 digit number excluding optional country code.",country:"GB"}]},initialize:function(_b7,_b8){
this.parent(_b7,_b8);
},massageNumber:function(_b9){
var _ba=new String(_b9);
var _bb=new RegExp("^\\+\\d{2,3} ","g");
var _bc=_ba.replace(_bb,"");
_bb=new RegExp("[()\\- ]","g");
_bc=_bc.replace(_bb,"");
return _bc;
},sendVerifyRequest:function(_bd){
var _be=this.element.getValue();
var _bf=this.massageNumber(_be);
var _c0=true;
var _c1=null;
this.options.matchList.each(function(_c2,_c3){
var _c4=this.options.country;
if(_c2.country&&_c4&&_c2.country==_c4[_c4.selectedIndex].value){
var _c5=_c2.regex.test(_bf);
if(_c2.invert==true){
if(_c5==true){
_c0=false;
if(_c1==null&&isDefined(_c2.invalidMessage)){
_c1=_c2.invalidMessage;
}
}
}else{
if(_c5==false){
_c0=false;
if(_c1==null&&isDefined(_c2.invalidMessage)){
_c1=_c2.invalidMessage;
}
}
}
}
}.bind(this));
if(_c0){
if(_c1==null){
_c1=this.options.defaultValidMessage;
}
this.notifier.showValid(_c1,5);
this.setStateValid();
if(isDefined(_bd)){
_bd(this);
}
return true;
}else{
if(_c1==null){
_c1=this.options.defaultInvalidMessage;
}
this.notifier.showInvalid(_c1,1);
this.setStateInvalid();
if(isDefined(_bd)){
_bd(this);
}
return false;
}
}});
