dojo.require("dijit.form.Form");dojo.require("dijit.form.CheckBox");dojo.require("dijit.form.TextBox");dojo.require("dijit.form.ValidationTextBox");function handle_signup_error(a){tdlg("Service Currently Unavailable",a.message)}function handle_signup_response(a){if(!a.rc){tdlg("Signup Failed","Invalid server response");return}if(a.rc=="ok"){if(a.sid){set_sid(a.sid);document.location="suok.shtml?email="+dojo.byId("id_form_email_address").value}else{tdlg("Failed to Login","Invalid server response")}}else{if(a.rc=="errcaptcha"){tdlg("Signup Failed","Invalid verification code");dijit.byId("id_form_captcha_code").focus()}else{if(a.rc=="errun"){tdlg("Signup Failed","Invalid email address");dijit.byId("id_form_email_address").focus()}else{if(a.rc=="errpw"){tdlg("Signup Failed","Invalid password");dijit.byId("id_form_password").focus()}else{if(a.rc=="errdup"){tdlg("Signup Failed","An account with the same email address already exists");dijit.byId("id_form_email_address").focus()}else{tdlg("Signup Failed",rc_msg(a.rc))}}}}}}function get_plan_info(){var a=null;if(document.istat){a=document.istat.org.value}if(a==null||a=="(none)"){a=0}dojo.xhrGet({url:"hc/getPlanInfo.action",content:{cc:dojo.byId("id_form_coupon_code").value,planid:1,org:a},handleAs:"json",preventCache:true,load:handle_get_plan_info_response})}function submit_form(){var c=null;if(document.istat){c=document.istat.org.value}if(c!=null&&c==100){if(!dijit.byId("id_form_i_agree").checked){tdlg("Notice","You must agree to the End User License Agreement to continue");return}show_dlg_loading();var a=null;if(document.istat){a=document.istat.sdt.value}if(a==null||a=="(none)"){a=""}dojo.xhrPost({url:"hc/signUpNewUser.action",content:{mdEmail:(dijit.byId("id_form_md_to_email").checked?"true":"false"),mdPhone:(dijit.byId("id_form_md_to_phone").checked?"true":"false"),org:c,cc:dojo.byId("id_form_coupon_code").value,sdt:a},handleAs:"json",error:function(d){hide_dlg_loading();handle_signup_error(d)},load:function(d){hide_dlg_loading();handle_signup_response(d)}});return}if(dijit.byId("id_signup_form").validate()){if(dojo.byId("id_form_gender").value==""){tdlg("Notice","Please select your gender.");return}if(dojo.byId("id_form_year_of_birth").value==""){tdlg("Notice","Please select your year of birth.");return}if(!dijit.byId("id_form_i_agree").checked){tdlg("Notice","You must agree to the End User License Agreement to continue");return}if(c==null||c=="(none)"){c=0}var b=dojo.byId("id_form_coupon_code").value;dojo.xhrGet({url:"hc/getPlanInfo.action",content:{cc:b,planid:1,org:c},handleAs:"json",preventCache:true,load:function(d){if(d.rc=="ok"){dojo.xhrPost({url:"hc/signUpNewUser.action",content:{email:dojo.byId("id_form_email_address").value.toUpperCase(),captchaCode:dojo.byId("id_form_captcha_code").value,suid:dojo.byId("id_form_session_id").value,password:dojo.byId("id_form_password").value,firstName:dojo.byId("id_form_first_name").value,lastName:dojo.byId("id_form_last_name").value,gender:dojo.byId("id_form_gender").value,yob:dojo.byId("id_form_year_of_birth").value,country:get_country_name(dojo.byId("id_form_country").value),timeZone:dojo.byId("id_form_timezone").value,countryCode:dojo.byId("id_form_country_code").value,mobileNo:dojo.byId("id_form_mobile_no").value,mdEmail:(dijit.byId("id_form_md_to_email").checked?"true":"false"),mdPhone:(dijit.byId("id_form_md_to_phone").checked?"true":"false"),cc:b,org:c},handleAs:"json",error:function(e){hide_dlg_loading();handle_signup_error(e)},load:function(e){hide_dlg_loading();handle_signup_response(e)}})}else{tdlg("Notice","This promotion code is not valid. Please confirm you entered the code correctly.");dojo.byId("id_form_coupon_code").focus()}}})}}function handle_signup_session_error(a){tdlg("Failed to Get Validation Code",a.message)}function handle_get_plan_info_error(a){tdlg("Failed to get plan info, error:",a.message)}function handle_signup_session_response(a){if(a.suid&&a.cpid){dojo.byId("id_new_vc").disabled=false;dojo.byId("id_form_session_id").value=a.suid;dojo.byId("id_form_captcha_image").src="hc/getSignUpCaptchaImg.action?email="+dojo.byId("id_form_email_address").value.toUpperCase()+"&suid="+a.suid+"&cpid="+a.cpid}else{tdlg("Failed to get validation code","Unexpected response from server")}}function set_text_decoration(b,a){dojo.style(dojo.byId(b),{textDecoration:a})}function set_visibility(b,a){dojo.style(dojo.byId(b),{visibility:a})}function set_innerHTML(b,a){document.getElementById(b).innerHTML=a}function clean_coupon_code_style(){set_innerHTML("id_new_storage","");set_innerHTML("id_new_storage_bytes","");set_innerHTML("id_new_credits","");set_text_decoration("id_storage","none");set_text_decoration("id_storage_bytes","none");set_text_decoration("id_credits","none")}function handle_get_plan_info_response(a){if(a.rc=="ok"){var c=document.getElementById("id_storage").innerHTML;var b=document.getElementById("id_credits").innerHTML;if(c!=fmt_num(a.storage)){if(c==""){set_innerHTML("id_storage",fmt_num(a.storage))}else{set_text_decoration("id_storage","line-through");set_text_decoration("id_storage_bytes","line-through");set_innerHTML("id_new_storage",fmt_num(a.storage));set_visibility("id_new_storage_bytes","visible")}}else{set_text_decoration("id_storage","none");set_text_decoration("id_storage_bytes","none");set_innerHTML("id_new_storage","");set_visibility("id_new_storage_bytes","hidden")}if(b!=a.credits){if(b==""){set_innerHTML("id_credits",a.credits)}else{set_text_decoration("id_credits","line-through");set_innerHTML("id_new_credits",a.credits)}}else{set_text_decoration("id_credits","none");set_innerHTML("id_new_credits","")}}else{if(a.rc=="errcc"){tdlg("Notice","Sorry, this is not a valid coupon. (WRONG CODE)");clean_coupon_code_style()}else{if(a.rc=="errexp"){tdlg("Notice","Sorry, this coupon expired.");clean_coupon_code_style()}else{if(a.rc=="errrdm"){tdlg("Notice","Sorry, this coupon is no longer valid. (FULLY USED).");clean_coupon_code_style()}else{if(a.rc=="errdia"){tdlg("Notice","The Coupon Code is currently not in use.");clean_coupon_code_style()}else{tdlg("Apply coupon code failure","Sorry, an error occur when apply coupon code, please contact us for assistant.")}}}}}}function update_validation_code(){dojo.xhrGet({url:"hc/getSignUpSession.action",content:{email:dojo.byId("id_form_email_address").value.toUpperCase()},handleAs:"json",preventCache:true,error:handle_signup_session_error,load:handle_signup_session_response})}function clear_form(){var a=["id_form_captcha_code","id_form_email_address","id_form_email_address2","id_form_password","id_form_password2","id_form_mobile_no","id_form_first_name","id_form_last_name"];dojo.forEach(a,function(b){dijit.byId(b).setValue("")})}function init_signup(){set_active_tab("signup");init_year_of_birth(false);if(document.istat&&document.istat.org.value=="100"){dojo.byId("id_org_logo").innerHTML='<img src="res/img/logo_tata.gif"/>'}if(document.istat&&document.istat.org.value=="200"){dojo.byId("id_org_logo").innerHTML='<img src="res/img/logo_rogers.jpg"/>'}init_country_list();update_timezones();get_plan_info();dojo.byId("id_form_email_address").focus();dojo.byId("id_form_email_address").onblur=dojo.byId("id_form_email_address2").onblur=function(){if(!dijit.byId("id_form_email_address").validate()||!dijit.byId("id_form_email_address2").validate()){dojo.byId("id_new_vc").disabled=true;return}dojo.byId("id_new_vc").disabled=false;var b=dojo.byId("id_form_email_address").value.toUpperCase();var d=dojo.byId("id_form_email_address2").value.toUpperCase();var c=dojo.byId("id_old_email").value;if(b!=""&&b==d){if(b!=c){update_validation_code()}dojo.byId("id_old_email").value=b}};dijit.byId("id_form_before_1960").onChange=function(){init_year_of_birth(dijit.byId("id_form_before_1960").checked)};dijit.byId("id_form_email_address").invalidMessage="Invalid email address";dijit.byId("id_form_email_address").isValid=function(){var b=dojo.byId("id_form_email_address").value;return b!=""&&b.match(/.+@.+/)};dijit.byId("id_form_email_address2").isValid=function(){var b=dojo.byId("id_form_email_address").value.toUpperCase();if(b==""){return true}return b==dojo.byId("id_form_email_address2").value.toUpperCase()};dijit.byId("id_form_email_address2").invalidMessage="It doesn't match with the email above";dijit.byId("id_form_password").invalidMessage="Password can't be empty";dijit.byId("id_form_password").isValid=function(){return dojo.byId("id_form_password").value!=""};dijit.byId("id_form_password2").isValid=function(){return dojo.byId("id_form_password").value==dojo.byId("id_form_password2").value};dijit.byId("id_form_password2").invalidMessage="It doesn't match with the password above";dijit.byId("id_form_first_name").invalidMessage="First name can't be empty";dijit.byId("id_form_first_name").isValid=function(){return dojo.byId("id_form_first_name").value!=""};dijit.byId("id_form_last_name").invalidMessage="Last name can't be empty";dijit.byId("id_form_last_name").isValid=function(){return dojo.byId("id_form_last_name").value!=""};var a=null;if(document.istat){a=document.istat.org.value}dojo.byId("id_form_country_code").readOnly=true;dojo.byId("id_form_country").onchange=on_country_changed;if(a!=null&&a==100){dojo.byId("id_form_country_code").value="91";dojo.query(".cls_vendor_hidden").forEach(function(b){b.style.display="none"})}if(a==200){dojo.byId("id_form_country").value="CA";dojo.byId("id_form_country").onchange()}else{if(a!="100"){dojo.byId("id_form_country").value="US";dojo.byId("id_form_country").onchange()}}dijit.byId("id_form_mobile_no").invalidMessage="Invalid mobile number";dijit.byId("id_form_mobile_no").isValid=function(){var b=dojo.byId("id_form_mobile_no").value;return b!=""&&b.match(/[0-9]+/)};dijit.byId("id_form_captcha_code").invalidMessage="Validation code can't be empty";dijit.byId("id_form_captcha_code").isValid=function(){var b=dojo.byId("id_form_captcha_code").value;return b!=""&&b.match(/[0-9]+/)}}dojo.addOnLoad(init_signup);