Type.registerNamespace("rb");rb.Signup=function(a){rb.Signup.initializeBase(this);this._locked=false;this._delegates={onSignupSuccessDelegate:Function.createDelegate(this,this._onSignupSuccess),onSMSSuccessDelegate:Function.createDelegate(this,this._onSMSSuccess)}};rb.Signup.prototype={_onLoad:function(b,a){rb.Signup.callBaseMethod(this,"_onLoad");this._getControl("txtCellPhone").focus();$addHandlers(this._getControl("button_btnEmail"),{click:this._onEmailClick},this);$addHandlers(this._getControl("emailEntry"),{keypress:this._onEmailKeyPress},this);$addHandlers(this._getControl("button_btnSms"),{click:this._onSmsClick},this);$addHandlers(this._getControl("smsEntry"),{keypress:this._onSmsKeyPress},this);rb.Recording.RecordPage("Sign Up")},submitEmail:function(){if(this._locked){return}var a=[{ctl:this._getControl("txtEmail"),type:"Email",required:true}];var b=rb.Validate.validateForm(a,this.Res);if(b.length==0){var c={email:this._getControl("txtEmail").value};this.lock();rb.Ajax.invoke("Account","SignupForPromos","",c,this._delegates.onSignupSuccessDelegate,this._baseDelegates.onPMFailDelegate)}else{rb.Validate.showErrors(b,this._getControl("emailErrorDialog"))}},submitSms:function(){if(this._locked){return}var a=[{ctl:this._getControl("txtCellPhone"),type:"Phone",required:true},{ctl:this._getControl("txtCellPhoneConfirm"),type:"Phone",required:true,error:"InvalidPhoneConfirm",sameValue:this._getControl("txtCellPhone").value},{ctl:this._getControl("ddlMobileCarrier"),required:true}];var b=(rb.Validate.validateForm(a,this.Res));if(b.length==0){var c={cellphonenum:this._getControl("txtCellPhone").value,cellphonenum_repeat:this._getControl("txtCellPhoneConfirm").value,carrier:rb.Util.getComboValue(this._getControl("ddlMobileCarrier"))};this.lock();rb.Ajax.invoke("Account","SubmitPhoneNumber","",c,this._delegates.onSMSSuccessDelegate,this._baseDelegates.onPMFailDelegate)}else{rb.Validate.showErrors(b,this._getControl("smsErrorDialog"))}},_validFormData:function(c,d){var f={};var a=true;var e=[];for(var b in c){if(c[b].tagName.toLowerCase()=="input"&&c[b].value.length==0){f[b]=true;a=false}if(c[b].tagName.toLowerCase()=="select"&&rb.Util.getComboValue(c[b])==0){f[b]=true;a=false}}if(a==false){e.push(this.Res.InvalidRequiredField)}if(c.Email!=null&&rb.Validate.Email(c.Email.value)==false){f.Email=true;e.push(this.Res.InvalidEmail)}if(c.Phone!=null&&rb.Validate.Phone(c.Phone.value)==false){f.Phone=true;e.push(this.Res.InvalidPhone)}if(c.PhoneConfirm!=null&&(rb.Validate.Phone(c.PhoneConfirm.value)==false||c.Phone.value!=c.PhoneConfirm.value)){f.PhoneConfirm=true;e.push(this.Res.InvalidPhone)}this._displayErrors(e,d);for(var b in c){this._updateEntryCss(c[b],f[b]==true)}return e.length==0},_onEmailClick:function(b,a){this.submitEmail()},_onSmsClick:function(b,a){this.submitSms()},_onEmailKeyPress:function(b,a){if(b.charCode==Sys.UI.Key.enter){this.submitEmail();b.preventDefault()}},_onSmsKeyPress:function(b,a){if(b.charCode==Sys.UI.Key.enter){this.submitSms();b.preventDefault()}},lock:function(){this._locked=true;this._getControl("progressBar").style.display=""},unlock:function(){this._locked=false;this._getControl("progressBar").style.display="none"},_onSignupSuccess:function(a,b){this.unlock();this._showError(a.message,this._getControl("emailErrorDialog"),!a.success);if(a.success){this._getControl("emailEntry").style.display="none";rb.Recording.RecordAction("Signed Up For Email",null,["event16"])}},_onSMSSuccess:function(a,b){this.unlock();this._showError(a.message,this._getControl("smsErrorDialog"),!a.success);if(a.success){this._getControl("smsEntry").style.display="none";rb.Recording.RecordAction("Signed Up For SMS",null,["event17"])}},_showError:function(b,c,a){if(a){c.className="errorDialog"}else{c.className="instruction"}c.style.display="";c.innerHTML=b},dispose:function(){this._delegates=null;rb.Signup.callBaseMethod(this,"dispose")}};rb.Signup.registerClass("rb.Signup",rb.ClientBase);