$(document).ready(function(){$("a[rel=image_gallery]").fancybox({speedIn:"900",transitionIn:"elastic",transitionOut:"none",titlePosition:"outside",opacity:"true",padding:"10"});var b=window.location.pathname;$("#searchBox").each(function(){var a=this.value;$(this).focus(function(){if(this.value==a)this.value=""});$(this).blur(function(){if(this.value=="")this.value=a})});$("#searchBtn").click(function(){var a=$("#searchBox").val();(a=="Enter a town, postcode or street"||a=="Enter a town or postcode"||
a=="Enter a town or city"||a=="Enter an estate agent, town/city or a postcode"||a=="Enter a town, region or country")&&$("#searchBox").val("")});if(b.indexOf("/profile")==-1){$("#telephone_number").hide();$("#processing").hide();$("#response").hide();var d=400;$("#charLeft").text(d);$("#print").click(function(){window.print()});$("#submit").click(function(){$("#contactform").hide();$("#processing").show()});$("#show_telephone_number").click(function(){$("#show_telephone_number").hide();$("#telephone_number").slideDown();
var a=$(this).attr("href");$.post(a);return!1});$("#saveLink").click(function(){var a=$(this).attr("href")+"&js=1";$("#save").empty();$("#save").append('<span class="saved">Property Saved</span>');$.post(a);return!1});$("#message").keyup(function(){var a=this.value.length;if(a>=d)this.value=this.value.substring(0,d);a=d-a;a<0?$("#charLeft").text("0"):$("#charLeft").text(a)});$("#contactform").submit(function(){var a=$(this).attr("action");$.post(a,{m:$("#m").val(),pid:$("#pid").val(),aid:$("#aid").val(),
uid:$("#uid").val(),name:$("#name").val(),email:$("#email").val(),telephone:$("#telephone").val(),message:$("#message").val()},function(a){$("#contactform #submit").attr("disabled","");$("#response").empty();$("#response").append(a);$("#response").show();a=="Thank you, your message has been sent!"?($("#name").val(""),$("#email").val(""),$("#telephone").val(""),$("#message").val("")):$("#contactform #submit").removeAttr("disabled");$("#processing").hide();$("#contactform").show()});return!1})}b.indexOf("/profile")!=
-1&&($("#processing").hide(),$("#response").hide(),d=400,$("#charLeft").text(d),$("#print").click(function(){window.print()}),$("#submit").click(function(){$("#contactform").hide();$("#processing").show()}),$("#saveLink").click(function(){var a=$(this).attr("href")+"&js=1";$("#save").empty();$("#save").append('<span class="saved">Profile Saved</span>');$.post(a);return!1}),$("#message").keyup(function(){var a=this.value.length;if(a>=d)this.value=this.value.substring(0,d);a=d-a;a<0?$("#charLeft").text("0"):
$("#charLeft").text(a)}),$("#contactform").submit(function(){var a=$(this).attr("action");$.post(a,{m:$("#m").val(),username:$("#username").val(),subject:$("#subject").val(),message:$("#message").val()},function(a){$("#contactform #submit").attr("disabled","");$("#response").empty();$("#response").append(a);$("#response").show();a=="Thank you, your message has been sent!"?($("#subject").val(""),$("#message").val("")):$("#contactform #submit").removeAttr("disabled");$("#processing").hide();$("#contactform").show()});
return!1}));if(b.indexOf("/register")!=-1){b.indexOf("/register/agent")!=-1&&$("#tp").hide();$("#agent").hide();var c=$("#type").val();c=="private"?$("#agent").hide():c=="agent"&&$("#agent").slideDown();$("#type").change(function(){var a=$("#type").val();a=="private"?$("#agent").hide():a=="agent"&&$("#agent").show()})}if(b.indexOf("/my-ads")!=-1){var e;$("#loading").hide();e=$("#filter option:selected").text()=="All Ads"?"My Ads":$("#filter option:selected").text();$("h1").text(e);$("#filter").change(function(){e=
$("#filter option:selected").text()=="All Ads"?"My Ads":$("#filter option:selected").text();$("h1").text(e);$("#ads").empty();$("#loading").show();$.post("get_ads.php",{filter:$("#filter").val(),searchstring:$("#searchstring").val()},function(a){$("#ads").append(a)});$("#loading").hide()});$("#search_ads").click(function(){$("#ads").empty();$("#loading").show();$.post("get_ads.php",{filter:$("#filter").val(),searchstring:$("#searchstring").val()},function(a){$("#ads").append(a)});$("#loading").hide();
return!1});$(".delete").click(function(){if(confirm("Are you sure you wish to delete this ad?")){$(this).parent().parent().remove();var a=$(this).attr("href")+"&js=1";$.post(a)}return!1})}b.indexOf("/message")!=-1&&($("#processing_2").hide(),$("#message_sent").hide(),d=600,$("#charLeft").text(d),$("#submit").click(function(){$("#reply_message").hide();$("#processing_2").show()}),$("#message").keyup(function(){var a=this.value.length;if(a>=d)this.value=this.value.substring(0,d);a=d-a;a<0?$("#charLeft").text("0"):
$("#charLeft").text(a)}),$("#reply_message").submit(function(){var a=$(this).attr("action");$.post(a,{m:$("#m").val(),mid:$("#mid").val(),subject:$("#subject").val(),message:$("#message").val()},function(a){$("#reply_message #submit").attr("disabled","");a=="Thank you, your message has been sent!"?($("#subject").val(""),$("#message").val(""),$("#processing_2").hide(),$("#reply_message").hide(),$("#message_sent").fadeIn("slow")):($("#reply_message #submit").removeAttr("disabled"),$("#processing_2").hide(),
$("#reply_message").show());$("#response").empty();$("#response").append(a);$("#response").show()});return!1}));b.indexOf("/favourites")!=-1&&($(".delete").click(function(){$(this).parent().parent().parent().hide();var a=$(this).attr("href")+"&js=1";$.post(a);return!1}),$(".delete2").click(function(){$(this).parent().parent().hide();var a=$(this).attr("href")+"&js=1";$.post(a);return!1}));b.indexOf("/step1")!=-1&&($("#tennancy_details").hide(),$("#existing_household").hide(),$("#tennant_suitability").hide(),
$("#rent").hide(),$("#broadband").hide(),c=$("#category").val(),c==""?($("#property_features").show(),$("#tennancy_details").hide(),$("#existing_household").hide(),$("#tennant_suitability").hide(),$("#new_dev").show(),$("#rent").hide(),$("#room_type").hide(),$("#broadband").hide(),$("#fixed").show(),$("#offer").show()):c=="buy"?($("#property_features").show(),$("#tennancy_details").hide(),$("#existing_household").hide(),$("#tennant_suitability").hide(),$("#new_dev").show(),$("#rent").hide(),$("#room_type").hide(),
$("#broadband").hide(),$("#fixed").show(),$("#offer").show()):c=="rent"?($("#property_features").show(),$("#tennancy_details").show(),$("#existing_household").hide(),$("#tennant_suitability").hide(),$("#new_dev").hide(),$("#fixed").hide(),$("#rent").show(),$("#let_rent_frequency").hide(),$("#room_type").hide(),$("#broadband").hide(),$("#offer").hide()):c=="share"&&($("#property_features").hide(),$("#tennancy_details").show(),$("#existing_household").show(),$("#tennant_suitability").show(),$("#new_dev").hide(),
$("#fixed").hide(),$("#rent").show(),$("#let_rent_frequency").show(),$("#room_type").show(),$("#broadband").show(),$("#offer").hide()),$("#category").change(function(){var a=$("#category").val();a==""?($("#property_features").show(),$("#tennancy_details").hide(),$("#existing_household").hide(),$("#tennant_suitability").hide(),$("#new_dev").show(),$("#rent").hide(),$("#room_type").hide(),$("#broadband").hide(),$("#fixed").show(),$("#offer").show()):a=="buy"?($("#property_features").show(),$("#tennancy_details").hide(),
$("#existing_household").hide(),$("#tennant_suitability").hide(),$("#new_dev").show(),$("#rent").hide(),$("#room_type").hide(),$("#broadband").hide(),$("#fixed").show(),$("#offer").show()):a=="rent"?($("#property_features").show(),$("#tennancy_details").show(),$("#existing_household").hide(),$("#tennant_suitability").hide(),$("#new_dev").hide(),$("#fixed").hide(),$("#rent").show(),$("#let_rent_frequency").hide(),$("#room_type").hide(),$("#broadband").hide(),$("#offer").hide()):a=="share"&&($("#property_features").hide(),
$("#tennancy_details").show(),$("#existing_household").show(),$("#tennant_suitability").show(),$("#new_dev").hide(),$("#fixed").hide(),$("#rent").show(),$("#let_rent_frequency").show(),$("#room_type").show(),$("#broadband").show(),$("#offer").hide())}));b.indexOf("/step2")!=-1&&($("#loading1").hide(),$("#loading2").hide(),$("#loading3").hide(),$("#loading4").hide(),$("#loading5").hide(),$("#loading6").hide(),c={beforeSubmit:function(){$("#loading1").show()},success:function(a){$("#loading1").hide();
$("#image_error1").empty();a=="image already exists"?($("#image_error1").append("Please delete the existing image before uploading a new one"),$("#image_error1").hide(),$("#image_error1").fadeIn("slow")):a.match("img")!=null?($("#uploaded_image1").empty(),$("#uploaded_image1").append(a),$("#uploaded_image1").hide(),$("#uploaded_image1").fadeIn("slow")):a=="no image to delete"?($("#image_error1").append("There is no image to delete."),$("#image_error1").hide(),$("#image_error1").fadeIn("slow")):a==
"delete successful"?($("#uploaded_image1").empty(),$("#uploaded_image1").append('<img src="images/no_image.gif" class="image"/>'),$("#uploaded_image1").hide(),$("#uploaded_image1").fadeIn("slow")):($("#image_error1").append(a),$("#image_error1").hide(),$("#image_error1").fadeIn("slow"))}},$("#image_upload_form1").ajaxForm(c),$("#image_upload_form2").ajaxForm({beforeSubmit:function(){$("#loading2").show()},success:function(a){$("#loading2").hide();$("#image_error2").empty();a=="image already exists"?
($("#image_error2").append("Please delete the existing image before uploading a new one"),$("#image_error2").hide(),$("#image_error2").fadeIn("slow")):a.match("img")!=null?($("#uploaded_image2").empty(),$("#uploaded_image2").append(a),$("#uploaded_image2").hide(),$("#uploaded_image2").fadeIn("slow")):a=="no image to delete"?($("#image_error2").append("There is no image to delete."),$("#image_error2").hide(),$("#image_error2").fadeIn("slow")):a=="delete successful"?($("#uploaded_image2").empty(),$("#uploaded_image2").append('<img src="images/no_image.gif" class="image"/>'),
$("#uploaded_image2").hide(),$("#uploaded_image2").fadeIn("slow")):($("#image_error2").append(a),$("#image_error2").hide(),$("#image_error2").fadeIn("slow"))}}),$("#image_upload_form3").ajaxForm({beforeSubmit:function(){$("#loading3").show()},success:function(a){$("#loading3").hide();$("#image_error3").empty();a=="image already exists"?($("#image_error3").append("Please delete the existing image before uploading a new one"),$("#image_error3").hide(),$("#image_error3").fadeIn("slow")):a.match("img")!=
null?($("#uploaded_image3").empty(),$("#uploaded_image3").append(a),$("#uploaded_image3").hide(),$("#uploaded_image3").fadeIn("slow")):a=="no image to delete"?($("#image_error3").append("There is no image to delete."),$("#image_error3").hide(),$("#image_error3").fadeIn("slow")):a=="delete successful"?($("#uploaded_image3").empty(),$("#uploaded_image3").append('<img src="images/no_image.gif" class="image"/>'),$("#uploaded_image3").hide(),$("#uploaded_image3").fadeIn("slow")):($("#image_error3").append(a),
$("#image_error3").hide(),$("#image_error3").fadeIn("slow"))}}),$("#image_upload_form4").ajaxForm({beforeSubmit:function(){$("#loading4").show()},success:function(a){$("#loading4").hide();$("#image_error4").empty();a=="image already exists"?($("#image_error4").append("Please delete the existing image before uploading a new one"),$("#image_error4").hide(),$("#image_error4").fadeIn("slow")):a.match("img")!=null?($("#uploaded_image4").empty(),$("#uploaded_image4").append(a),$("#uploaded_image4").hide(),
$("#uploaded_image4").fadeIn("slow")):a=="no image to delete"?($("#image_error4").append("There is no image to delete."),$("#image_error4").hide(),$("#image_error4").fadeIn("slow")):a=="delete successful"?($("#uploaded_image4").empty(),$("#uploaded_image4").append('<img src="images/no_image.gif" class="image"/>'),$("#uploaded_image4").hide(),$("#uploaded_image4").fadeIn("slow")):($("#image_error4").append(a),$("#image_error4").hide(),$("#image_error4").fadeIn("slow"))}}),$("#image_upload_form5").ajaxForm({beforeSubmit:function(){$("#loading5").show()},
success:function(a){$("#loading5").hide();$("#image_error5").empty();a=="image already exists"?($("#image_error5").append("Please delete the existing image before uploading a new one"),$("#image_error5").hide(),$("#image_error5").fadeIn("slow")):a.match("img")!=null?($("#uploaded_image5").empty(),$("#uploaded_image5").append(a),$("#uploaded_image5").hide(),$("#uploaded_image5").fadeIn("slow")):a=="no image to delete"?($("#image_error5").append("There is no image to delete."),$("#image_error5").hide(),
$("#image_error5").fadeIn("slow")):a=="delete successful"?($("#uploaded_image5").empty(),$("#uploaded_image5").append('<img src="images/no_image.gif" class="image"/>'),$("#uploaded_image5").hide(),$("#uploaded_image5").fadeIn("slow")):($("#image_error5").append(a),$("#image_error5").hide(),$("#image_error5").fadeIn("slow"))}}),$("#image_upload_form6").ajaxForm({beforeSubmit:function(){$("#loading6").show()},success:function(a){$("#loading6").hide();$("#image_error6").empty();a=="image already exists"?
($("#image_error6").append("Please delete the existing image before uploading a new one"),$("#image_error6").hide(),$("#image_error6").fadeIn("slow")):a.match("img")!=null?($("#uploaded_image6").empty(),$("#uploaded_image6").append(a),$("#uploaded_image6").hide(),$("#uploaded_image6").fadeIn("slow")):a=="no image to delete"?($("#image_error6").append("There is no image to delete."),$("#image_error6").hide(),$("#image_error6").fadeIn("slow")):a=="delete successful"?($("#uploaded_image6").empty(),$("#uploaded_image6").append('<img src="images/no_image.gif" class="image"/>'),
$("#uploaded_image6").hide(),$("#uploaded_image6").fadeIn("slow")):($("#image_error6").append(a),$("#image_error6").hide(),$("#image_error6").fadeIn("slow"))}}));b.indexOf("/step3");b.indexOf("/payment")!=-1&&$("#payment").submit();b.indexOf("/update-profile")!=-1&&($("#loading7").hide(),c={beforeSubmit:function(){$("#loading7").show()},success:function(a){$("#loading7").hide();$("#image_error1").empty();a=="image already exists"?($("#image_error1").append("Please delete the existing image before uploading a new one"),
$("#image_error1").hide(),$("#image_error1").fadeIn("slow")):a.match("img")!=null?($("#uploaded_avatar").empty(),$("#uploaded_avatar").append(a),$("#uploaded_avatar").hide(),$("#uploaded_avatar").fadeIn("slow")):a=="no image to delete"?($("#image_error1").append("There is no image to delete"),$("#image_error1").hide(),$("#image_error1").fadeIn("slow")):a=="delete successful"?($("#uploaded_avatar").empty(),$("#uploaded_avatar").append('<img src="images/noavatar.jpg"/>'),$("#uploaded_avatar").hide(),
$("#uploaded_avatar").fadeIn("slow")):($("#image_error1").append(a),$("#image_error1").hide(),$("#image_error1").fadeIn("slow"))}},$("#image_upload_form1").ajaxForm(c));b.indexOf("/agent-profile")!=-1&&($("#loading7").hide(),c={beforeSubmit:function(){$("#loading7").show()},success:function(a){$("#loading7").hide();$("#image_error1").empty();a=="image already exists"?($("#image_error1").append("Please delete the existing image before uploading a new one"),$("#image_error1").hide(),$("#image_error1").fadeIn("slow")):
a.match("img")!=null?($("#uploaded_avatar").empty(),$("#uploaded_avatar").append(a),$("#uploaded_avatar").hide(),$("#uploaded_avatar").fadeIn("slow")):a=="no image to delete"?($("#image_error1").append("There is no image to delete"),$("#image_error1").hide(),$("#image_error1").fadeIn("slow")):a=="delete successful"?($("#uploaded_avatar").empty(),$("#uploaded_avatar").append('<img src="images/noavatar.jpg"/>'),$("#uploaded_avatar").hide(),$("#uploaded_avatar").fadeIn("slow")):($("#image_error1").append(a),
$("#image_error1").hide(),$("#image_error1").fadeIn("slow"))}},$("#image_upload_form1").ajaxForm(c));b.indexOf("/contact")!=-1&&($("#processing").hide(),$("#message_sent").hide(),$("#response").hide(),$("#char_left").text(400),$("#message").keyup(function(){var a=this.value.length;if(a>=400)this.value=this.value.substring(0,400);a=400-a;a<0?$("#char_left").text("0"):$("#char_left").text(a)}),$("#contact_form").submit(function(){var a=["name","email","telephone","message"],b=$(this).attr("action"),
d=a.length-1,c="";$.each(a,function(a,b){c=c+b+"="+$("#"+b).val();a!=d&&(c+="&");$("#"+b).removeClass("highlight_error");$("#"+b+"_error").text("")});$("#submit").attr("disabled","disabled");$("#contact_form").hide();$("#processing").show();$.ajax({url:b,type:"POST",dataType:"json",data:c,success:function(a){a.status=="success"?($("#name").val(""),$("#email").val(""),$("#telephone").val(""),$("#message").val(""),$("#processing").hide(),$("#contact_form").hide(),$("#message_sent").fadeIn("slow")):
($.each(a.errors,function(a,b){$("#"+a+"_error").text(b);$("#"+a).addClass("highlight_error")}),$("#submit").removeAttr("disabled"),$("#processing").hide(),$("#contact_form").fadeIn("slow"))}});return!1}))});
