$(document).ready(function(){$("div.show_hide fieldset").hide();showHideInit();if(typeof loginInit=="function"){loginInit()}if(typeof doAutocomplete=="function"&&$("#jobTitle").length>0){doAutocomplete({id:"jobTitle",list:ac_complist},{delay:10,minChars:1,matchSubset:1,maxItemsToShow:15,header:"Search suggestions",closeButton:true,width:250})}if($("#locationJobTown").length>0){$("#locationJobTown").blur(function(){searchForLocation("#upload","locationJobTown",false)})}$("#fullJobDescription").blur(function(){if($("#summaryJobDescription").val()==""){$("#summaryJobDescription").val($("#fullJobDescription").val().substring(0,239))}})});function validateIndustySectors(){var a=0;$("input[@name='industrySectorIds']:checked").each(function(){a++});if(a>5){$("#industryErrorMessage").css("color","red");$("#industryErrorMessage").html("You can choose a maximum of 5 sectors (Please deselect some of the sectors)")}else{$("#industryErrorMessage").css("color","#333333");$("#industryErrorMessage").html("You can choose a maximum of 5 sectors ("+(5-a)+" left)")}}function deselectAllCheckboxes(a){$("#"+a).find("input[type=checkbox]").each(function(){this.checked=false});$("#industryErrorMessage").css("color","#333333");$("#industryErrorMessage").html("You can choose a maximum of 5 sectors (5 left)")}function fillAdFields(){var c=[];$("input:checkbox[name=industrySectorIds]:checked").each(function(d){c[d]=$(this).attr("title")});var b=c[0];for(var a=1;a<c.length;a++){b+=", "+c[a]}$(".preview_jobtitle").html($("#jobTitle").val()+(($("#jobTitle").val()!=""&&$("#locationJobTown").val()!="")?", ":"")+$("#locationJobTown").val());($("#salaryText").val()!=""||$("#benefits").val()!="")?($(".preview_salary").html("Salary - ")):($(".preview_salary").html(""));$(".preview_salarytext").html($("#salaryText").val()+(($("#salaryText").val()!=""&&$("#benefits").val()!="")?", ":"")+$("#benefits").val());$(".preview_workhours").html($("#workingHoursId option:selected").text());$(".preview_type").html($("#jobTypeId option:selected").text());$(".preview_sectors").html(b);$(".preview_description").html(("\n"+$("#fullJobDescription").val()).replaceAll("\n","<br />"))}function showFieldset(a){$("#"+a).show();$("#"+a).prev("h4").addClass("collapse")}function fillPhoneNumber(){if($("#contactTelephone").val()==""){$("#contactTelephone").val($("#tel").val())}}function searchForLocation(d,a,c){var b=true;if($("#"+a).val().length>2){if($("#areaId").length>0&&$("#areaId").val()!=""&&$("#locationCheck").val()==$("#locationJobTown").val()){b=false}if(b){$.ajax({type:"POST",url:sChooseLocationURL,data:"locationName="+$("#"+a).val(),success:function(e){if(e!="fail"){$(".chooseLocationBox").html(e);$("#locationCheck").val($("#"+a).val());if($(".location_radio").length>0){$(".chooseLocationBox").show()}else{if(c&&$(d).valid()){$(d).submit()}}}else{$("#"+a).addClass("error_msg");$(".locationName_error").show()}}})}else{if(c&&$(d).valid()){$(d).submit()}}}else{if(c){$(d).submit()}else{$("#"+a).addClass("error_msg");$(".locationName_error").show()}}$("#"+a).focus(function(){if($(".locationName_error").is(":visible")){$("#"+a).removeClass("error_msg");$(".locationName_error").hide()}if($(".location_radio:checked").length>0&&$("#areaId").val()!=""&&$("#"+a).val().length<3){$(".chooseLocationBox").html("")}})}$().ready(function(){if($(".amend_adform").length>0){$(".amend_adform").validate({errorClass:"error_msg",errorElement:"span",rules:{tel:{required:true,phoneUK:true},address:{required:true},postcode:{required:true,postcodeUK:true},jobTitle:{required:true},jobTypeId:{required:true},workingHoursId:{required:true},fullJobDescription:{required:true},industrySectorIds:"required",minSalary:{digits:true,required:true},maxSalary:{digits:true,greaterThan:"#minSalary"},locationJobTown:{required:function(a){if($("input[name=radioAreaId]").length>0){$("input[name=radioAreaId]").rules("add",{required:true,messages:{required:"Please choose one or amend your search"}})}},enoughLocationCharacters:true},contactEmail:{required:true,email:true},applicationURL:{url:true},directURL:{url:true},summaryJobDescription:{required:true,maxlength:240},startDate:{required:true,date:true},terms:"required"},messages:{industrySectorIds:"You have to choose at least 1 sector",terms:"You have to accept the terms and conditions to continue"}})}});