$(function(){if($(".search-by-text").length){$(".search-by-text").validate({expression:"if($.trim(VAL).length>=3) return true; else return false;",message:language.search_nickname_error_message})}if($(".country-selector").length){bindContrySelectors()}if($("#message_Subject").length){bindMessageSubjectValidation()}if($(".password-field").length){bindPasswordStrength()}if($("#event_Description_Short").length){$("#event_Description_Short").validate({expression:"if($.trim(VAL).length>300) return false; else return true;",message:language.admin_event_short_description_validation})}if($(".message-compose-area").length){$(".message-to-reply").css("cursor","default");$(".message-to-reply").click(function(){$(".message-compose-area textarea").focus().effect("highlight",{},1000)})}if($(".any-checkbox").length){bindAnyCheckboxes()}if($(".has-children").length){bindHasChildren()}if($(".has-pets").length){bindHasPets()}if($("#userprofile_Professional_Income").length){createIncomeSlider()}if($(".register-box").length){bindRegisterValidation()}});function createIncomeSlider(){var a=$("#userprofile_Professional_Income").val();$("#career-slider-range").slider({range:"min",value:a,min:5000,max:200000,step:5000,slide:function(b,c){$("#userprofile_Professional_Income").val(c.value)}});$("#userprofile_Professional_Income").val($("#career-slider-range").slider("value"))}$.fn.ajaxCheckbox=function(){$(this).bind("click",function(){var a=$(this).parents(".checkbox-action").attr("rel");showLoader();var b=$(this).parents(".checkbox-action").find("input[type=checkbox]").attr("checked");$.post(a,{checked:b},hideLoader)})};function bindAccountSettings(){$(".account-settings-box .checkbox-action input").ajaxCheckbox()}function bindAjaxCheckbox(a){if(a){$(a).find(".checkbox-action input").ajaxCheckbox()}else{$(".checkbox-action input").ajaxCheckbox()}}$.fn.ajaxSelector=function(){$(this).bind("change",function(){var a=$(this).find(":selected").val();window.location.href=a})};function bindResultsView(){$("#results-view-selector").ajaxSelector()}$.fn.editableField=function(){return this.each(function(){var b=$(this).parents("table").attr("rel");var e=$(this).parents("tr").find(".editable-field");var a=$.trim(e.text());var d=$(this);function f(g,h,i){$.post(g,{id:h,new_word:i});a=i}function c(){var g=$("<a>"+language.save+"</a>").attr("class","save-field-value").attr("href","#save");var h=$("<a>"+language.cancel+"</a>").attr("class","cancel-field-value").attr("href","#cancel");var i=$("<input />").attr("type","text").attr("value",a);e.html("").append(i).append("&nbsp;").append(g).append(" | ").append(h);g.click(function(){f(b,e.attr("id"),i.val());e.html(i.val());e.click(c);d.show("fast");return false});h.click(function(){e.html(a);e.click(c);d.show("fast");return false});e.unbind("click");d.hide("fast");return false}e.attr("title",language.click_to_edit);d.click(c);e.click(c)})};function bindEditableFields(){$(".edit-handler").editableField()}$.fn.anyCheckbox=function(){return this.each(function(){$(this).click(function(){if($(this).attr("checked")){$(this).parents("li").find("input[type=checkbox]").attr("disabled",true).attr("checked",false);$(this).attr("disabled",false).attr("checked",true)}else{$(this).parents("li").find("input[type=checkbox]").attr("disabled",false)}});if($(this).is(":checked")){$(this).parents("li").find("input[type=checkbox]").attr("disabled",true).attr("checked",false);$(this).attr("disabled",false).attr("checked",true)}})};function bindAnyCheckboxes(){$(".any-checkbox").anyCheckbox()}function bindHasChildren(){if($(".has-children").find("input[type=radio]:first").attr("checked")){$(".number-of-children").show("fast");$(".number-of-children select").attr("disabled",false)}else{$(".number-of-children").hide("fast");$(".number-of-children select").attr("disabled",true)}$(".has-children").find("input[type=radio]").change(function(){if($(".has-children").find("input[type=radio]:first").attr("checked")){$(".number-of-children").show("fast");$(".number-of-children select").attr("disabled",false)}else{$(".number-of-children").hide("fast");$(".number-of-children select").attr("disabled",true)}})}function bindHasPets(){if($(".has-pets").find("input[type=radio]:first").attr("checked")){$(".pets-details").show("fast");$(".pets-details textarea").attr("disabled",false)}else{$(".pets-details").hide("fast");$(".pets-details textarea").attr("disabled",true)}$(".has-pets").find("input[type=radio]").change(function(){if($(".has-pets").find("input[type=radio]:first").attr("checked")){$(".pets-details").show("fast");$(".pets-details textarea").attr("disabled",false)}else{$(".pets-details").hide("fast");$(".pets-details textare").attr("disabled",true)}})}function bindPasswordStrength(){var a=$("#password-strength-lang").text();$(".password-field").jpassword({length:6,lang:{basic:a}})}$.fn.countrySelector=function(a){var b={childSelector:".county-selector",onReady:function(){}};var a=$.extend(b,a);return this.each(function(){$(this).change(function(){var d=this;var e=$(this);var f=e.parent().next("li").find(a.childSelector);var c=e.find("option:selected").attr("value");if(e.find("option:selected").attr("id")){c=e.find("option:selected").attr("id");$.post(e.attr("rel"),{id:c},function(g){g=$.trim(g);f.after(g).remove();a.onReady.call(d)})}else{$.post(e.attr("rel"),{code:c},function(g){g=$.trim(g);f.after(g).remove();a.onReady.call(d)})}})})};function bindContrySelectors(){$(".country-selector").countrySelector({onReady:function(){var a=$(this).parent().next("li");a.find(".county-selector").countrySelector({childSelector:".locality-selector",onReady:function(){if($(".register-box").length||$(".add-event-box").length||$(".edit-profile-content").length){var b=$(this).parent().next("li");bindLocalitySelector(b.find(".locality-selector"))}}});a.find(".county-selector").trigger("change")}});$(".county-selector").countrySelector({childSelector:".locality-selector",onReady:function(){if($(".register-box").length||$(".add-event-box").length||$(".edit-profile-content").length){var a=$(this).parent().next("li");bindLocalitySelector(a.find(".locality-selector"))}}});$(".country-selector").trigger("change")}function bindLocalitySelector(g){var b=$("<div></div>").attr("title",language.add_locality);var e=$("<label></label>").append(language.new_locality_name);var d=$("<input/>").attr("maxlength","20").addClass("text-field");var a=[];var c;var f=$("<option>"+language.add_locality+"</option>").attr("value","001").css({backgroundColor:"#BCDDFE",fontWeight:"bold"});b.append(e).append(d);g.append(f);g.bind("change",function(){if($(this).find("option:last").is(":selected")){$("body").append(b);g.find("option").each(function(){c=jQuery.trim($(this).text()).toLowerCase().replace(" ","").replace("_","").replace("-","");a.push(c)});b.dialog({bgiframe:true,height:150,width:300,modal:true,resizable:false,closeOnEscape:false,draggable:false,buttons:{Ok:function(){g.find(".any-locality").remove();var i=$(".locality-selector").attr("rel");var h=$(".county-selector option:selected").attr("id");var j="000";new_locality_val=jQuery.trim(d.val()).toLowerCase().replace(" ","").replace("_","").replace("-","");if(jQuery.inArray(new_locality_val,a)!=-1){alert(language.locality_already_exists);return false}$.post(i,{id:h,text:d.val()},function(k){j=k;g.prepend('<option value="'+j+'">'+d.val()+"</option>");g.find("option:first").attr("selected",true);b.dialog("destroy");d.val("")});$(".ui-dialog-buttonpane").remove()},Cancel:function(){g.find("option:first").attr("selected",true);$(this).dialog("destroy")}}});b.bgiframe();$(".ui-dialog-titlebar-close").remove()}})}function is_valid_email(a){return/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(a)}function has_only_letters(a){return/^[A-Za-z\s]+$/.test(a)}function has_only_numbers(a){return/^[0-9\s]+$/.test(a)}function bindRegisterValidation(){$("#inactiveusers_Email_Address").validate({expression:"if(is_valid_email(VAL)) return true; else return false;",message:language.registration_invalid_email});$("#inactiveusers_Password_Confirmation").validate({expression:"if(VAL==$('#inactiveusers_Password').val()) return true; else return false;",message:language.registration_choose_new_password});$("#inactiveusers_Nickname").validate({expression:"if($.trim(VAL).length==0) return false; else return true;",message:language.registration_empty_nickname});$("#inactiveusers_Nickname").validate({expression:"if($.trim(VAL).length > 20) return false; else return true;",message:language.registration_nickname_wrong_length});$("#inactiveusers_Nickname").validate({expression:"if(is_valid_email(VAL)) return false; else return true;",message:language.registration_nickname_not_email});$("#inactiveusers_Name_Last").validate({expression:"if($.trim(VAL).length==0) return false; else return true;",message:language.registration_last_name_required});$("#inactiveusers_Name_Last").validate({expression:"if(has_only_letters(VAL)) return true; else return false;",message:language.registration_last_name_only_letters});$("#inactiveusers_Name_Last").validate({expression:"if($.trim(VAL).length >20) return false; else return true;",message:language.registration_last_name_wrong_length});$("#inactiveusers_Name_First").validate({expression:"if($.trim(VAL).length==0) return false; else return true;",message:language.registration_first_name_required});$("#inactiveusers_Name_First").validate({expression:"if(has_only_letters(VAL)) return true; else return false;",message:language.registration_first_name_only_letters});$("#inactiveusers_Name_First").validate({expression:"if($.trim(VAL).length >20) return false; else return true;",message:language.registration_first_name_wrong_length});$("#inactiveusers_Live_Address").validate({expression:"if($.trim(VAL).length==0) return false; else return true;",message:language.registration_live_address_required});$("#inactiveusers_Live_Address").validate({expression:"if($.trim(VAL).length >45) return false; else return true;",message:language.registration_live_address_wrong_length});$("#inactiveusers_ZIP_Code").validate({expression:"if($.trim(VAL).length==0) return false; else return true;",message:language.registration_zip_required});$("#inactiveusers_ZIP_Code").validate({expression:"if($.trim(VAL).length > 15) return false; else return true;",message:language.registration_zip_wrong_length});$("#inactiveusers_Phone_Number").validate({expression:"if($.trim(VAL).length==0) return false; else return true;",message:language.registration_phone_required});$("#inactiveusers_Phone_Number").validate({expression:"if($.trim(VAL).length > 15) return false; else return true;",message:language.registration_phone_wrong_length});$("#inactiveusers_Phone_Number").validate({expression:"if(has_only_numbers(VAL)) return true; else return false;",message:language.registration_phone_only_numbers});$("#inactiveusers_Terms").validate({expression:"if($('#inactiveusers_Terms').is(':checked')) return true; else return false;",message:language.registration_terms_agree});$("#inactiveusers_Gender").validate({expression:"if(VAL=='') return false; else return true;",message:language.registration_choose_gender});$("#inactiveusers_Sought_Gender").validate({expression:"if(VAL=='') return false; else return true;",message:language.registration_choose_sought_gender});$("#inactiveusers_Year").validate({expression:"if($('#inactiveusers_Day').val()=='' || $('#inactiveusers_Month').val()=='' || $('#inactiveusers_Year').val()=='') return false; else return true;",message:language.registration_empty_birth_date})}function bindMessageSubjectValidation(){$("#message_Subject").validate({expression:"if(is_valid_email(VAL)) return false; else return true;",message:language.message_subject_error})};