var loadingImg=null;$(document).ready(function(a){d=new Date();yr=d.getFullYear();d.setFullYear(yr-21,0,1);$("#dob").datepicker({altFormat:"yy-mm-dd",dateFormat:"D d M yy",changeYear:true,changeMonth:true,yearRange:"1900 : "+yr,defaultDate:d});$("#dob").datepicker("setDate",d);$("#bus_dob").datepicker({altFormat:"yy-mm-dd",dateFormat:"D d M yy",changeYear:true,changeMonth:true,yearRange:"1900 : "+yr,defaultDate:d});$("#bus_dob").datepicker("setDate",d);$("#convert_dob").datepicker({altFormat:"yy-mm-dd",dateFormat:"D d M yy",changeYear:true,changeMonth:true,yearRange:"1900 : "+yr,defaultDate:d});$("#convert_dob").datepicker("setDate",d);if(typeof(default_category)!="undefined"){$("#bus_type").val(default_category)}});function autologin(){waitElement("btn_login");if($("#autologin").is(":checked")){auto=1}else{auto=0}$.post("/ci/users/login/",{autologuser:$("#autologuser").val(),autologin:auto},function(a){restoreElement("btn_login");if(!a.result){$("#autologuser").val("0");$("#auth_password").val("");inlineMsg("btn_login","Auto log in authorization has failed, please reenter your password.",5);return}postLogin(a)},"json")}function login(){if($("#autologuser").length&&$("#autologuser").val()==1){autologin();return}if($("#auth_username").length&&$.trim($("#auth_email").val())==""){altlogin();return}if(trim($("#auth_email").val())==""){inlineMsg("auth_email","Enter your user name.",4)}else{if(trim($("#auth_password").val())==""){inlineMsg("auth_password","Enter your password.",4)}else{waitElement("btn_login",loadingImg);var a=0;if($("#autologin").length&&$("#autologin").is(":checked")){a=1}$.post("/ci/users/login/",{auth_email:$("#auth_email").val(),auth_password:$("#auth_password").val(),autologin:a},function(b){restoreElement("btn_login");postLogin(b)},"json")}}}function postLogin(a){if(a.result){if($("#callfunction").length){aftersignup()}else{if($.trim($("#redirect").val())!=""){document.location.href="/ci/"+$("#redirect").val()+"/"}else{document.location.href="/ci/map/"}}}else{if(a.confirmation){$.blockUI({message:$("#email_confirmation"),css:{cursor:"default",width:"524px",position:"absolute"},overlayCSS:{cursor:"default"}})}else{inlineMsg("btn_login","User name or password incorrect.")}}}function altlogin(){if($.trim($("#auth_email").val())==""&&$.trim($("#auth_username").val())==""){inlineMsg("auth_email","Enter your email address or user name.",4)}else{if(trim($("#auth_password").val())==""){inlineMsg("auth_password","Enter your password.",4)}else{waitElement("btn_login",loadingImg);var a=0;if($("#autologin").length&&$("#autologin").is(":checked")){a=1}$.post("/ci/users/login/",{auth_username:$("#auth_username").val(),auth_email:$("#auth_email").val(),auth_password:$("#auth_password").val(),autologin:a},function(b){restoreElement("btn_login");if(b.result){if(!b.params.need_convert){inlineMsg("auth_username",'<img width="10" src="/img/home/icon_close.gif" onclick="hideMsg(this);" id="form_err_msg_close"/>This account has been converted to the new login method. Please use your email address and password to login.',5)}else{doBBConvert(b.params)}}else{if(b.confirmation){$.blockUI({message:$("#email_confirmation"),css:{cursor:"default",width:"524px",position:"absolute"},overlayCSS:{cursor:"default"}})}else{inlineMsg("btn_login","User name or password incorrect.")}}},"json")}}}function resendverification(){if($.trim($("#auth_email").val())==""){inlineMsg("auth_email",'<img width="10" src="/img/home/icon_close.gif" onclick="hideMsg(this);" id="form_err_msg_close"/>Ensure your email address is listed here.',5);return}$.post("/ci/welcome/resendVerification/",{email:$("#auth_email").val()},function(a){if(a.result){$("#mapmy_ok_alert .dialog_img_info").replaceWith('<p class="dialog_img_info">'+_("We have sent you a new welcome email, this email will contain instructions on how to activate your account.")+"</p>");$("#mapmy_ok_alert").dialog("open")}else{inlineMsg("auth_email",'<img width="10" src="/img/home/icon_close.gif" onclick="hideMsg(this);" id="form_err_msg_close"/>This email address is not currently registered with us. Please ensure your email address is the same as the one you used to register and try again.',5)}},"json")}function checkemail(a){switch(a){case 1:email=$("#suemail").val();break;case 2:email=$("#bus_email").val();break;case 3:email=$("#convert_email").val();break}if(email.search(/^[A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4}$/i)!=-1){$.post("/ci/welcome/checkemail",{email:email},function(b){to=null;if(b.available){switch(a){case 1:$("#available").show();$("#unavailable").hide();break;case 2:$("#bus_available").show();$("#bus_unavailable").hide();break;case 3:$("#convert_available").show();$("#convert_unavailable").hide();break}}else{switch(a){case 1:$("#available").hide();$("#unavailable").show();break;case 2:$("#bus_available").hide();$("#bus_unavailable").show();break;case 3:$("#convert_available").hide();$("#convert_unavailable").show();break}}},"json")}else{switch(a){case 1:$("#available").hide();$("#unavailable").show();break;case 2:$("#bus_available").hide();$("#bus_unavailable").show();break;case 3:$("#convert_available").hide();$("#convert_unavailable").show();break}}}function sendNewPassword(){waitElement("sendNewPassword");if($("#forgot_email").val()==""){$("#mapmy_ok_alert .dialog_img_info").replaceWith('<p class="dialog_img_info">'+_("Please enter your email address so we can reset your password.")+"</p>");$("#mapmy_ok_alert").dialog("open");restoreElement("sendNewPassword")}else{$.post(WEB_URL+"ci/email/sendForgotPassword/",{e:$("#forgot_email").val()},function(a){restoreElement("sendNewPassword");$("#forgot_email").val("");if(a.result=="TRUE"){$("#mapmy_ok_alert .dialog_img_info").replaceWith('<p class="dialog_img_info">'+_("We have sent you an email with instructions on how to reset your password.  Your password reset request will expire in 30 minutes.")+"</p>");$("#mapmy_ok_alert").dialog("open")}else{$("#mapmy_ok_alert .dialog_img_info").replaceWith('<p class="dialog_img_info">'+_("We could not find your account.  Please create a mapmy account and join the community.")+"</p>");$("#mapmy_ok_alert").dialog("open")}},"json")}}var subopts={beforeSubmit:showWait,success:showResponse,dataType:"json"};var busopts={beforeSubmit:showWait2,success:showResponse2,dataType:"json"};function showWait(){waitElement("btn_join")}function showWait2(){waitElement("bus_signup_btn")}function showResponse(a){clearSignup();restoreElement("btn_join");if(a.result){$(".pop_close").click();if(a.require_confirmation){$.blockUI({message:$("#email_confirmation"),css:{cursor:"default",width:"524px",position:"absolute"},overlayCSS:{cursor:"default"}})}else{if($("#callfunction").length){aftersignup()}else{if($.trim($("#redirect").val())!=""){document.location.href="/ci/"+$("#redirect").val()+"/"}else{document.location.href="/ci/map/"}}}}else{Recaptcha.reload();if(a.error=="captcha_error"){inlineMsg("recaptcha_response_field","Security code incorrect, please try again.",4)}else{inlineMsg("btn_join","Could not create account at this time.  Please try again later.",4)}}}function clearSignup(){$("#auth_signup_form input:text").each(function(a,b){if(!$(this).hasClass("hasDatepicker")){$(this).val("")}});$("#auth_signup_form input:checkbox").each(function(a,b){$(this).removeAttr("checked")})}function showResponse2(a){restoreElement("bus_signup_btn");if(a.result){if(a.require_confirmation){$.blockUI({message:$("#email_confirmation"),css:{cursor:"default",width:"524px",position:"absolute"},overlayCSS:{cursor:"default"}});$(".btnLogin").click()}else{if($.trim($("#redirect").val())!=""){document.location.href="/ci/"+$("#redirect").val()+"/"}else{document.location.href="/ci/map/"}}}else{Recaptcha.reload();if(a.error=="captcha_error"){inlineMsg("recaptcha_response_field","Security code incorrect, please try again.",4)}else{inlineMsg("bus_signup_btn","Could not create account at this time.  Please try again later.",4)}}}function validateSubmit(){hideMsg(document.getElementById("form_error_msg"));errors=false;if(trim($("#first_name").val())==""){inlineMsg("first_name",'<img width="10" src="/img/home/icon_close.gif" onclick="hideMsg(this);" id="form_err_msg_close"/>Enter your given name.',5);document.getElementById("first_name").focus();errors=true}if(!errors&&trim($("#last_name").val())==""){inlineMsg("last_name",'<img width="10" src="/img/home/icon_close.gif" onclick="hideMsg(this);" id="form_err_msg_close"/>Enter your surname.',5);document.getElementById("last_name").focus();errors=true}if($("#postcode").length){if(!errors&&$.trim($("#postcode").val())==""){inlineMsg("postcode",'<img width="10" src="/img/home/icon_close.gif" onclick="hideMsg(this);" id="form_err_msg_close"/>Please enter your postcode.',5);document.getElementById("postcode").focus();errors=true}}em=trim($("#suemail").val());if(!errors&&em==""){inlineMsg("suemail",'<img width="10" src="/img/home/icon_close.gif" onclick="hideMsg(this);" id="form_err_msg_close"/>Enter your email address. This will be used as your unique user name.',5);document.getElementById("suemail").focus();errors=true}if(!errors&&em.search(/^[A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4}$/i)===-1){inlineMsg("suemail",'<img width="10" src="/img/home/icon_close.gif" onclick="hideMsg(this);" id="form_err_msg_close"/>This does not seem to be a valid email address.',5);document.getElementById("suemail").focus();errors=true}p=trim($("#supassword").val());if(!errors&&p==""){inlineMsg("supassword",'<img width="10" src="/img/home/icon_close.gif" onclick="hideMsg(this);" id="form_err_msg_close"/>Enter the password for your account.',5);document.getElementById("supassword").focus();errors=true}if(!errors&&p.length<6){inlineMsg("supassword",'<img width="10" src="/img/home/icon_close.gif" onclick="hideMsg(this);" id="form_err_msg_close"/>Password must be at least 6 characters.',5);document.getElementById("supassword").focus();errors=true}if(!errors&&!($("#dob").datepicker("getDate"))){inlineMsg("dob",'<img width="10" src="/img/home/icon_close.gif" onclick="hideMsg(this);" id="form_err_msg_close"/>Please enter your date of birth.',5);document.getElementById("dob").focus();errors=true}if($("#mapmy_confirm").length){if(!errors&&!$("#mapmy_confirm").is(":checked")){inlineMsg("mapmy_confirm",'<img width="10" src="/img/home/icon_close.gif" onclick="hideMsg(this);" id="form_err_msg_close"/>You must agree to our terms and conditions to be a member.',5);document.getElementById("mapmy_confirm").focus();errors=true}}if($("#google_confirm").length){if(!errors&&!$("#google_confirm").is(":checked")){inlineMsg("google_confirm",'<img width="10" src="/img/home/icon_close.gif" onclick="hideMsg(this);" id="form_err_msg_close"/>You must agree to Google\'s terms and conditions to be a member.',5);document.getElementById("google_confirm").focus();errors=true}}if($("#recaptcha_response_field").length){if(!errors&&$.trim($("#recaptcha_response_field").val())==""){inlineMsg("recaptcha_response_field",'<img width="10" src="/img/home/icon_close.gif" onclick="hideMsg(this);" id="form_err_msg_close"/>You must enter the security code as it appears in the picture.',5);document.getElementById("recaptcha_response_field").focus();errors=true}}if(!errors){waitElement("btn_join");$.post("/ci/welcome/checkemail",{email:$("#suemail").val()},function(a){restoreElement("btn_join");if(a.available){if($("#postcode").length){geocoder=new GClientGeocoder();address=$("#postcode").val()+" "+$.trim($("#country :selected").text());geocoder.getLatLng(address,function(b){if(b){$("#sulatitude").val(b.lat());$("#sulongitude").val(b.lng())}else{inlineMsg("postcode","This does not seem to be a valid postcode.",5);return}geocoder.getLocations(new GLatLng(b.lat(),b.lng()),function(c){if(c.Status.code==200){if(c.Placemark[0].AddressDetails.Country.AdministrativeArea!=undefined){loc=c.Placemark[0].AddressDetails.Country.AdministrativeArea;$("#state").val(loc.AdministrativeAreaName);if(loc.SubAdministrativeArea!==undefined){if(loc.SubAdministrativeArea.Locality!==undefined){$("#suburb").val(loc.SubAdministrativeArea.Locality.LocalityName)}else{$("#suburb").val(loc.subAdministrativeArea.SubAdministrativeAreaName)}}else{if(loc.Locality!==undefined){$("#suburb").val(loc.Locality.LocalityName)}}}}else{inlineMsg("btn_join","Could not find this location.  Please ensure it is accurate so we can find people near to you.",5);return false}$("#auth_signup_form").ajaxSubmit(subopts)})})}else{$("#auth_signup_form").ajaxSubmit(subopts)}}else{inlineMsg("suemail","This email address is already registered",5)}},"json")}}function validateBusiness(){hideMsg(document.getElementById("form_error_msg"));if(trim($("#bus_first_name").val())==""){inlineMsg("bus_first_name",'<img width="10" src="/img/home/icon_close.gif" onclick="hideMsg(this);" id="form_err_msg_close"/>Enter your given name.',5);document.getElementById("bus_first_name").focus();return}if(trim($("#bus_last_name").val())==""){inlineMsg("bus_last_name",'<img width="10" src="/img/home/icon_close.gif" onclick="hideMsg(this);" id="form_err_msg_close"/>Enter your surname.',5);document.getElementById("bus_last_name").focus();return}em=trim($("#bus_email").val());if(em==""){inlineMsg("bus_email",'<img width="10" src="/img/home/icon_close.gif" onclick="hideMsg(this);" id="form_err_msg_close"/>Enter your email address. This will be used as your unique user name.',5);document.getElementById("bus_email").focus();return}if(em.search(/^[A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4}$/i)===-1){inlineMsg("bus_email",'<img width="10" src="/img/home/icon_close.gif" onclick="hideMsg(this);" id="form_err_msg_close"/>This does not seem to be a valid email address.',5);document.getElementById("bus_email").focus();return}p=trim($("#bus_password").val());if(p==""){inlineMsg("bus_password",'<img width="10" src="/img/home/icon_close.gif" onclick="hideMsg(this);" id="form_err_msg_close"/>Enter the password for your account.',5);document.getElementById("bus_password").focus();return}if(p.length<6){inlineMsg("bus_password",'<img width="10" src="/img/home/icon_close.gif" onclick="hideMsg(this);" id="form_err_msg_close"/>Password must be at least 6 characters.',5);document.getElementById("bus_password").focus();return}if(!($("#bus_dob").datepicker("getDate"))){inlineMsg("bus_dob",'<img width="10" src="/img/home/icon_close.gif" onclick="hideMsg(this);" id="form_err_msg_close"/>Please enter your date of birth.',5);document.getElementById("bus_dob").focus();return}if(trim($("#bus_name").val())==""){inlineMsg("bus_name",'<img width="10" src="/img/home/icon_close.gif" onclick="hideMsg(this);" id="form_err_msg_close"/>Please enter the name of your business.',5);document.getElementById("bus_name").focus();return}if($("#bus_type").val()==0){inlineMsg("bus_type",'<img width="10" src="/img/home/icon_close.gif" onclick="hideMsg(this);" id="form_err_msg_close"/>Select the type that best describes you business.',5);document.getElementById("bus_type").focus();return}if($("#bus_subtype").val()==0){inlineMsg("bus_subtype",'<img width="10" src="/img/home/icon_close.gif" onclick="hideMsg(this);" id="form_err_msg_close"/>Select the category that best describes your business.',5);document.getElementById("bus_subtype").focus();return}if(!$("#bus_mapmy_confirm").is(":checked")){inlineMsg("bus_mapmy_confirm",'<img width="10" src="/img/home/icon_close.gif" onclick="hideMsg(this);" id="form_err_msg_close"/>You must agree to our terms and conditions to be a member.',5);document.getElementById("bus_mapmy_confirm").focus();return}if(!$("#bus_google_confirm").is(":checked")){inlineMsg("bus_google_confirm",'<img width="10" src="/img/home/icon_close.gif" onclick="hideMsg(this);" id="form_err_msg_close"/>You must agree to Google\'s terms and conditions to be a member.',5);document.getElementById("bus_google_confirm").focus();return}if($("#recaptcha_response_field").length&&$.trim($("#recaptcha_response_field").val())==""){inlineMsg("recaptcha_response_field",'<img width="10" src="/img/home/icon_close.gif" onclick="hideMsg(this);" id="form_err_msg_close"/>You must enter the security code as it appears in the picture.',5);document.getElementById("recaptcha_response_field").focus();return}waitElement("bus_signup_btn");$.post("/ci/welcome/checkemail",{email:$("#bus_email").val()},function(a){restoreElement("bus_signup_btn");if(a.available){$("#bus_signup_frm").ajaxSubmit(busopts)}else{inlineMsg("bus_email",'<img width="10" src="/img/home/icon_close.gif" onclick="hideMsg(this);" id="form_err_msg_close"/>This email address is already in use, please try another.',5)}},"json")}function getSubs(){if($("#bus_type").val()!=0){$.post("/ci/welcome/getBusinessCategories/",{parent:$("#bus_type").val()},function(a){$("#bus_subtype").empty().append("<option value='0'>Select Category</option>");$.each(a.cats,function(b,c){$("#bus_subtype").append("<option value='"+c.type_id+"'>"+c.descr+"</option>")});if(typeof(default_category)!="undefined"&&typeof(default_subcategory)!="undefined"){if($("#bus_type").val()==default_category){$("#bus_subtype").val(default_subcategory)}}},"json")}else{$("#bus_subtype").empty().append("<option value='0'>Select a type first</option>")}};
