/*    HTTP Host:  b.static.ak.fbcdn.net                                        */
/*    Generated:  June 29th 2009 12:18:51 PM PDT                               */
/*      Machine:  10.16.140.105                                                */
/*       Source:  Global Cache                                                 */
/*     Location:  js/mobile/activation.js h:edo33s2x                           */
/*       Locale:  nu_ll                                                        */
/*         Path:  js/mobile/activation.js                                      */


function mobile_activation_show_carriers(){var prev_country=$('selected_country').value;var curr_country=$('carrier_country').value;if(prev_country){hide($(prev_country+'_carrier_select'));}
$('selected_country').value=curr_country;$('selected_carrier').value=0;show($(curr_country+'_carrier_select'));}
function mobile_activation_update_carrier(){var carrier_select_name=$('selected_country').value+'_carrier_select';$('selected_carrier').value=$(carrier_select_name).value;}
function MobileSmsActivationController(id,source,misc){copy_properties(this,{profile_id:id,parent:parent,source:source,misc:misc,carrier:null,AJAX_URI:'/ajax/mobile/activation.php',redirect_uri:null});this.start();MobileSmsActivationController.instance=this;}
MobileSmsActivationController.instance={};MobileSmsActivationController.getInstance=function(){return MobileSmsActivationController.instance;}
copy_properties(MobileSmsActivationController.prototype,{goStep:function(step){if(step==2){this.getShortCode();return;}else if(step==3){this.getConfirmCode();return;}
this.start();},start:function(error){new AsyncRequest().setURI(this.AJAX_URI).setData({'profile_id':this.profile_id,'get_carriers':1,'source':this.source,'misc':this.misc,'error':error}).setHandler(this.showCarriers.bind(this)).send();},showCarriers:function(asyncResponse){var response=asyncResponse.getPayload();new Dialog().setTitle(response['title']).setBody(response['html']).setHandler(this.getShortCode.bind(this)).setButtons([Dialog.NEXT,Dialog.CANCEL]).show();},getShortCode:function(){if(!this.carrier){this.carrier=parseInt($('selected_carrier').value);if(!this.carrier){this.start(true);return false;}}
Dialog.getCurrent().setButtonsMessage('<img src="/images/loaders/indicator_blue_small.gif" />');new AsyncRequest().setURI(this.AJAX_URI).setData({'profile_id':this.profile_id,'get_shortcode':1,'carrier':this.carrier}).setHandler(this.showShortCode.bind(this)).send();return false;},showShortCode:function(asyncResponse){var response=asyncResponse.getPayload();new Dialog().setTitle(response['title']).setBody(response['html']).setHandler(this.getConfirmCode.bind(this)).setButtons([Dialog.NEXT,Dialog.CANCEL]).show();},getConfirmCode:function(foo,error){Dialog.getCurrent().setButtonsMessage('<img src="/images/loaders/indicator_blue_small.gif" />');new AsyncRequest().setURI(this.AJAX_URI).setData({'profile_id':this.profile_id,'get_code':1,'error':error}).setHandler(this.showConfirmCode.bind(this)).send();return false;},showConfirmCode:function(asyncResponse){var response=asyncResponse.getPayload();new Dialog().setTitle(response['title']).setBody(response['html']).setHandler(this.activate.bind(this)).setButtons([Dialog.CONFIRM,Dialog.CANCEL]).show();},activate:function(){var code=$('sms_code').value;var profile_add=ge('profile_add');profile_add=profile_add?profile_add.checked:null;if(!code){this.getConfirmCode(false,true);return false;}
new AsyncRequest().setURI(this.AJAX_URI).setData({'profile_id':this.profile_id,'confirm':1,'code':code,'profile_add':profile_add,'source':this.source,'misc':this.misc}).setHandler(this.confirmCode.bind(this)).send();},confirmCode:function(asyncResponse){var response=asyncResponse.getPayload();if(response['success']){if(response['redirect_now']){goURI(response['redirect']);return;}
this.redirect_uri=response['redirect'];new Dialog().setTitle(response['title']).setBody(response['html']).setHandler(this.redirect.bind(this)).setButtons([Dialog.OK]).show();}},redirect:function(){if(this.redirect_uri=='reload'){window.location.reload();}else{goURI(this.redirect_uri);}}});

if (window.Bootloader) { Bootloader.done(["js\/mobile\/activation.js"]); }
