$(document).ready(function(){var F={};var E={};var H=0;var D=0;E.mobileNumber=true;$("#username").focus(function(){if(this.value.length==0){$("#usernameInfo").show().removeClass("signupSuccess").removeClass("signupError").addClass("signupInfo").html("Your public ChaCha name, at least 3 letters, numbers, or underscores, starting with a letter")}}).blur(function(){var I={};I.username=this.value;ChaCha.ajax.sendRequest("/ajax/checkUsername","jsonInput="+JSON.stringify(I),"POST",function(J){if(J.usernameCheck==true){$("#usernameInfo").show().removeClass("signupInfo").removeClass("signupError").addClass("signupSuccess").html("");F.username=true}else{$("#usernameInfo").show().removeClass("signupInfo").removeClass("signupSuccess").addClass("signupError").html(J.usernameCheckMessage)}},function(J){},null)});var C=function(){var I={};I.birthdayMonth=$("#birthdayMonth").val();I.birthdayDay=$("#birthdayDay").val();I.birthdayYear=$("#birthdayYear").val();ChaCha.ajax.sendRequest("/ajax/checkBirthday","jsonInput="+JSON.stringify(I),"POST",function(J){if(J.birthdayCheck==true){$("#birthdayInfo").show().removeClass("signupInfo").removeClass("signupError").addClass("signupSuccess").html("");F.birthday=true}else{$("#birthdayInfo").show().removeClass("signupInfo").removeClass("signupSuccess").addClass("signupError").html(J.birthdayCheckMessage);F.birthday=false}},function(J){},null)};var G=function(){var I={};I.birthdayMonth=$("#birthdayMonth").val();I.birthdayDay=$("#birthdayDay").val();I.birthdayYear=$("#birthdayYear").val();if((I.birthdayMonth.length>0)&&(I.birthdayYear.length>0)){ChaCha.ajax.sendRequest("/ajax/getBirthdayDayOptions","jsonInput="+JSON.stringify(I),"POST",function(J){if(J.dayOptions.length>0){$("#birthdayDay").html(J.dayOptions)}},function(J){},null)}};$("#birthdayMonth,#birthdayDay,#birthdayYear").focus(function(){if(F.birthday!=true){if(H){clearTimeout(H)}$("#birthdayInfo").show().removeClass("signupSuccess").removeClass("signupError").addClass("signupInfo").html("Your birthday is required")}}).change(function(){if(($("#birthdayMonth").val().length>0)&&($("#birthdayDay").val().length>0)&&($("#birthdayYear").val().length>0)){if(H){clearTimeout(H)}H=setTimeout(C,100)}else{F.birthday=false;$("#birthdayInfo").show().removeClass("signupSuccess").removeClass("signupError").addClass("signupInfo").html("Your birthday is required")}}).blur(function(){if(H){clearTimeout(H)}H=setTimeout(C,200)});$("#birthdayMonth,#birthdayYear").change(function(){if(D){clearTimeout(D)}D=setTimeout(G,100)});$("#emailSignup").focus(function(){if(this.value.length==0){$("#emailInfo").show().removeClass("signupSuccess").removeClass("signupError").addClass("signupInfo").html("A valid email address is required")}}).blur(function(){var I={};I.email=this.value;ChaCha.ajax.sendRequest("/ajax/checkEmail","jsonInput="+JSON.stringify(I),"POST",function(J){if(J.emailCheck==true){$("#emailInfo").show().removeClass("signupInfo").removeClass("signupError").addClass("signupSuccess").html("");F.email=true}else{$("#emailInfo").show().removeClass("signupInfo").removeClass("signupSuccess").addClass("signupError").html(J.emailCheckMessage);F.email=false}},function(J){},null)});$("#passwordSignup").focus(function(){if(this.value.length==0){$("#passwordInfo").show().removeClass("signupSuccess").removeClass("signupError").addClass("signupInfo").html("Minimum of 6 character for security")}}).blur(function(){if(this.value.length<6){$("#passwordInfo").show().removeClass("signupInfo").removeClass("signupSuccess").addClass("signupError").html("Minimum of 6 characters for security");F.password=false}}).keyup(function(){if(this.value.length>5){$("#passwordInfo").show().removeClass("signupInfo").removeClass("signupError").addClass("signupSuccess").html("");F.password=true}else{$("#passwordInfo").show().removeClass("signupSuccess").removeClass("signupError").addClass("signupInfo").html("Minimum of 6 character for security");F.password=false}});$("#signupPhone").focus(function(){if(this.value.length==0){$("#phoneInfo").show().removeClass("signupSuccess").removeClass("signupError").addClass("signupInfo").html("Enter your 10-digit mobile number to take advantage of ChaCha's great mobile services")}}).blur(function(){if(E.mobileNumber==true){E.mobileNumber=false;var I={};I.mobileNumber=this.value;ChaCha.ajax.sendRequest("/ajax/checkMobileNumber","jsonInput="+JSON.stringify(I),"POST",function(J){if(J.mobileNumberCheck==true){$("#phoneInfo").show().removeClass("signupInfo").removeClass("signupError").addClass("signupSuccess").html("");F.phone=true;E.mobileNumber=true}else{$("#phoneInfo").show().removeClass("signupInfo").removeClass("signupSuccess").addClass("signupError").html(J.mobileNumberCheckMessage);F.phone=false;E.mobileNumber=true}},function(J){E.mobileNumber=true},null)}}).keydown(function(I){if(((I.which>=48)&&(I.which<=57))||((I.which>=96)&&(I.which<=105))){return true}else{if((I.which==8)||(I.which==9)||(I.which==13)||(I.which==37)||(I.which==38)||(I.which==0)){return true}else{return false}}}).keyup(function(){if(this.value.length==10){if(E.mobileNumber==true){E.mobileNumber=false;var I={};I.mobileNumber=this.value;ChaCha.ajax.sendRequest("/ajax/checkMobileNumber","jsonInput="+JSON.stringify(I),"POST",function(J){if(J.mobileNumberCheck==true){$("#phoneInfo").show().removeClass("signupInfo").removeClass("signupError").addClass("signupSuccess").html("");F.phone=true;E.mobileNumber=true}else{$("#phoneInfo").show().removeClass("signupInfo").removeClass("signupSuccess").addClass("signupError").html(J.mobileNumberCheckMessage);F.phone=false;E.mobileNumber=true}},function(J){E.mobileNumber=true},null)}}});$("#gender").focus(function(){if($("#gender").val()==""){$("#genderInfo").show().removeClass("signupSuccess").removeClass("signupError").addClass("signupInfo").html("Your gender is required")}}).change(function(){if($("#gender").val()!=""){$("#genderInfo").show().removeClass("signupInfo").removeClass("signupError").addClass("signupSuccess").html("");F.gender=true}else{$("#genderInfo").show().removeClass("signupSuccess").removeClass("signupError").addClass("signupInfo").html("Your gender is required");F.gender=false}}).blur(function(){if($("#gender").val()!=""){$("#genderInfo").show().removeClass("signupInfo").removeClass("signupError").addClass("signupSuccess").html("");F.gender=true}else{$("#genderInfo").show().removeClass("signupSuccess").removeClass("signupInfo").addClass("signupError").html("Your gender is required");F.gender=false}});var A=new RegExp("^[0-9]{5}(-[0-9]{4})?$");$("#zipCode").focus(function(){if(this.value.length==0){$("#zipCodeInfo").show().removeClass("signupSuccess").removeClass("signupError").addClass("signupInfo").html("A valid zip code is required")}}).blur(function(){if(A.test(this.value)){$("#zipCodeInfo").show().removeClass("signupInfo").removeClass("signupError").addClass("signupSuccess").html("");F.zipCode=true}else{$("#zipCodeInfo").show().removeClass("signupSuccess").removeClass("signupInfo").addClass("signupError").html("A valid zip code is required");F.zipCode=false}}).keydown(function(K){if(((K.which>=48)&&(K.which<=57))||((K.which>=96)&&(K.which<=105))){if(this.value.length==5){var I=K.which;if(I>=96){I=I-48}var J=this.value;$("#zipCode").val(J+"-"+String.fromCharCode(I));return false}return true}else{if((K.which==8)||(K.which==9)||(K.which==13)||(K.which==37)||(K.which==38)||(K.which==0)){return true}else{return false}}}).keyup(function(){if(A.test(this.value)){$("#zipCodeInfo").show().removeClass("signupInfo").removeClass("signupError").addClass("signupSuccess").html("");F.zipCode=true}else{$("#zipCodeInfo").show().removeClass("signupSuccess").removeClass("signupError").addClass("signupInfo").html("A valid zip code is required");F.zipCode=false}});$("#termsAndConditions").change(function(){if($("#termsAndConditions:checked").val()!=null){F.termsAndConditions=true}else{F.termsAndConditions=false}});$("#signupForm").submit(function(){if(F.termsAndConditions!=true){$("#submitInfo").addClass("signupInfo").html("You must agree to the <strong>terms of use</strong> and <strong>privacy policy</strong> before signing up");return false}else{if(F.username!=true||F.email!=true||F.password!=true||F.phone!=true||F.zipCode!=true||F.gender!=true||F.birthday!=true){$("#submitInfo").addClass("signupInfo").html("Please fix the errors above before submitting your information")}else{$("#submitInfo").hide()}}return true});var B=window.location.href;if(B.substring(B.length-5).toLowerCase()=="login"){$("#email").focus()}else{$("#username").focus()}});