;ConfirmMobileManager=function(){var timer=null;var init=function(){};var sendAuthCode=function(){var phone=PhoneController.GetPhone();$("#getCodeAgainButton").addClass("disable");Poster.SaveMobilePhone({phone:phone},sendAuthCodeCallback);};var sendAuthCodeAgain=function(){$("#getCodeAgainButton, #sendCodeButton").addClass("disable");var phone=PhoneController.GetPhone();Poster.SendSmsCodeAgain({phone:phone},sendAuthCodeCallback);};var sendAuthCodeCallback=function(result){var results=new Array();if(!result||result.status!="success"){results.push({error:'smsEmptyCode',message:result.message});RegisterPortal.PrintErrors(results);}
if(timer==null){timerCodeStart(31);}};var validateAuthCode=function(){var code=$('#txtSignUpCode').val();var results=new Array();if(code&&code.trim().length){Poster.ValidateSmsCode({phone:PhoneController.GetPhone(),code:code},function(response){if(!response||response.status!="success"){switch(response.message){case"emptyCode":results.push({error:'smsEmptyCode',message:errorMessage.GetMessageByType('smsEmptyCode')});break;case"SmsTooMuchError":results.push({error:'smsTooMuchError',message:errorMessage.GetMessageByType('smsTooMuchError')});break;case"SmsAuthenticationTimeout":results.push({error:'smsAuthenticationTimeout',message:errorMessage.GetMessageByType('smsAuthenticationTimeout')});break;case"SmsAuthenticationMessageError":results.push({error:'smsAuthenticationMessageError',message:errorMessage.GetMessageByType('smsAuthenticationMessageError')});break;default:}
RegisterPortal.PrintErrors(results);return;}
RegisterPortal.CreatePortal();});}else{results.push({error:'smsEmptyCode',message:errorMessage.GetMessageByType('smsEmptyCode')});RegisterPortal.PrintErrors(results);return;}};var timerCodeStart=function(){timerCode(31);};var timerCode=function(start){var span="#getCodeAgainButton span#time";var time=(start||$(span).data("time"))|0;time-=1;if(time>0){$(span).text(" ("+time+")").data("time",time);timer=setTimeout(timerCode,1000);}else{clearInterval(timer);timer=null;$(span).text("");$("#getCodeAgainButton").removeClass("disable");}};return{init:init,sendAuthCode:sendAuthCode,sendAuthCodeAgain:sendAuthCodeAgain,validateAuthCode:validateAuthCode};}();(function(){$(function(){$(".formSteps").on("click","#getCodeAgainButton:not(.disable)",function(){ConfirmMobileManager.sendAuthCodeAgain();return false;});$(".formSteps").on("click",".sbmtSignUp:not(.disable)",function(){if(window.MessagingEnabled)ConfirmMobileManager.validateAuthCode();return false;});});})();