var LANG_ANY = "Any";var url = "http://www.veritashomes.co.uk/";var LANG_SEARCH_URL = "search";var LANG_SEARCH_REF_URL = "reference-search";var LANG_PRINT_PROP_URL = "print-property";var LANG_START_SS = "Start<br />Slideshow";var LANG_PAUSE_SS = "Pause<br />Slideshow";var LANG_INDEX_OF = "Pause";var LANG_SHOW_MAP = "Aerial Picture";var LANG_HIDE_MAP = "Hide Map";var LANG_HIDE_ENQUIRE = "Hide Contact Form";var LANG_ENQUIRE = "Request More Information About This Property";var LANG_PROP_SEARCH_SALERENT_SALE_VAL = "sale";var LANG_PROP_SEARCH_SALERENT_RENT_VAL = "rent";var LANG_ANY_VAL = "any";var LANG_ANY = "Any";var LANG_OVER_2_THOUSAND = "Over 2,000";var LANG_OVER_1_MILLION = "Over 1,000,000";var LANG_CURRENCY_SEP = ".";var LANG_ADV_HIDE_SEARCH = "Hide<br />Advanced";var LANG_ADV_SEARCH = "Advanced Search";$(document).ready(function(){$("#weatherDisplay").cycle({fx: 'scrollUp',timeoutFn: calculateTimeout});$("#province").change(function() {var searchProvince = $("#province").val();$.ajax({type: "GET",url: "/searchPopulate.php",data: 'searchProvince=' + searchProvince,dataType: "xml",success: function(xml) {var selectMenu = $('#city');$("#city > option").remove();var menuTitle = $(xml).find('menuTitle').text();selectMenu.append("<option value='" + LANG_ANY_VAL + "'>" + menuTitle + "</option>");$(xml).find('menuItem').each(function(){var itemCityVal = $(this).attr('value');var itemCity = $(this).text();selectMenu.append("<option value='" + itemCityVal + "'>" + itemCity + "</option>");});getSearchURL();}});});$("#saleRent").change(function(){var saleRent = $("#saleRent").val();changePrices(saleRent);});$('#searchForm select').change(function(){getSearchURL();});$("#callUs img").click(function() {var currentCBDisplay = $("#callBackRequest").css('margin-top');if (currentCBDisplay == "-115px") {$("#callBackRequest").animate({marginTop: "0"}, 'slow');} else {$("#callBackRequest").animate({marginTop: "-115px"}, 'slow');}});$("#sendCallBackRequest").click(function(){$("#callBackResponse").fadeOut('slow');$("#sendCallBackRequest").fadeOut('slow', function(){if ($("#callBackWaiting").css('display') == 'block') {$("#callBackWaiting").fadeOut('slow');}$("#callBackWaiting").fadeIn('slow');});var callBackName = $("#callBackName").val();var callBackTel = $("#callBackTel").val();var callBackTime = $("#callBackTime").val();$.getJSON("/callback-request.php?callBackName=" + encodeURIComponent(callBackName) + "&callBackTel=" + encodeURIComponent(callBackTel)  + "&callBackTime=" + encodeURIComponent(callBackTime), function(data){	var responseType = data.responseType;if (responseType == 'valid') {$("#callBackWaiting").fadeOut('slow');$("#callBackForm h4").html(data.contactTitle);("#callBackDisplay").html(data.contactResponse);} else {$("#callBackWaiting").fadeOut('slow');$("#callBackResponse").html(data.contactResponse);$("#callBackResponse").delay(1500).fadeIn('slow');$("#sendCallBackRequest").delay(1500).fadeIn('slow');}});});$("#closeCallBack").click(function() {$("#callBackRequest").animate({marginTop: "-115px"}, 'slow');});$(".socialEmail").click(function() {var currentCBDisplay = $("#emailThisPage").css('margin-top');if (currentCBDisplay == "-115px") {$("#emailThisPage").animate({marginTop: "0"}, 'slow');} else {$("#emailThisPage").animate({marginTop: "-115px"}, 'slow');}});$("#sendEmailToFriend").click(function(){$("#emailPageResponse").fadeOut('slow');$("#sendEmailToFriend").fadeOut('slow', function(){if ($("#emailPageWaiting").css('display') == 'block') {$("#emailPageWaiting").fadeOut('slow');}$("#emailPageWaiting").fadeIn('slow');});var senderName = $("#senderName").val();var senderEmail = $("#senderEmail").val();var friendEmail = $("#friendEmail").val();$.getJSON("/email-to-friend.php?senderName=" + encodeURIComponent(senderName) + "&senderEmail=" + encodeURIComponent(senderEmail)  + "&friendEmail=" + encodeURIComponent(friendEmail) + "&pageToSend=" + encodeURIComponent(pageToSend), function(data){var responseType = data.responseType;if (responseType == 'valid') {$("#emailPageWaiting").fadeOut('slow');$("#emailPageForm h4").html(data.contactTitle);$("#emailPageDisplay").html(data.contactResponse);} else {$("#emailPageWaiting").fadeOut('slow');$("#emailPageResponse").html(data.contactResponse);$("#emailPageResponse").delay(1500).fadeIn('slow');$("#sendEmailToFriend").delay(1500).fadeIn('slow');}});});$("#closeEmailPage").click(function() {$("#emailThisPage").animate({marginTop: "-115px"}, 'slow');});$("#sendNewsletterSignup").click(function(){$("#sendNewsletterSignup").fadeOut('slow');var newsletterEmail = $("#newsletterEmail").val();$.getJSON("/newsletterSignup.php?newsletterEmail=" + encodeURIComponent(newsletterEmail), function(data){var responseType = data.responseType;if (responseType == 'valid') {$("#newsletterForm").fadeOut('slow');$("#newsletterResponse").html(data.contactResponse);$("#newsletterResponse").delay(600).fadeIn('slow');} else {$("#newsletterForm").fadeOut('slow');$("#sendNewsletterSignup").delay(800).fadeIn('slow');$("#newsletterResponse").html(data.contactResponse);$("#newsletterResponse").delay(600).fadeIn('slow');$("#newsletterResponse").delay(3900).fadeOut('slow');$("#newsletterForm").delay(4500).fadeIn('slow');}});});$('#refNo').keyup(function() {var refSearchVal = $('#refNo').val();if (refSearchVal == "") {getSearchURL();} else {var searchHref = url + LANG_SEARCH_REF_URL + "#refNo=" + refSearchVal;$("#searchForm").attr('action',searchHref);}});function calculateTimeout(currElement, nextElement, opts, isForward) {var currSlide = opts.currSlide;if (currSlide == 0 || currSlide == 14) {return 3000;} else {return 8000;}}function getSearchURL() {var searchHref = url + LANG_SEARCH_URL;selectInputs = {"list-type" : "saleRent", "province" : "province", "city" : "city", "type" : "propertyType", "priceMin" : "priceMin", "priceMax" : "priceMax", "beds" : "beds", "baths" : "baths" };$.each(selectInputs, function(key, value) {var searchVar = $("#" + value).val();if (searchVar == null || searchVar == "") {searchVar = "any";}if (key == "list-type") {searchHref = searchHref + "#" + key + "=" + searchVar;} else {if (key == "province" || key == "city") {searchHref = searchHref + "&" + key + "=" + searchVar;} else {searchHref = searchHref + "&" + key + "=" + encodeURIComponent(searchVar);}}});$("#searchForm").attr('action',searchHref);}	function changePrices(saleRent) {var priceMinList = document.getElementById('priceMin');priceMinList.options.length = 0;var priceMaxList = document.getElementById('priceMax');priceMaxList.options.length = 0;priceMinList.options[priceMinList.options.length] = new Option(LANG_ANY,LANG_ANY_VAL);priceMaxList.options[priceMaxList.options.length] = new Option(LANG_ANY,LANG_ANY_VAL);var minPrice;var maxPrice;var priceInc;if (saleRent ==  LANG_PROP_SEARCH_SALERENT_SALE_VAL) {minPrice = 10000;maxPrice = 1100000;priceInc = 10000;} else {minPrice = 100;maxPrice = 2100;priceInc = 100;}for (i = 0; i < maxPrice; i+=priceInc) {priceMinList.options[priceMinList.options.length] = new Option(toCurrency(i) + "€", i);}for (i = minPrice; i < maxPrice; i+=priceInc) {priceMaxList.options[priceMaxList.options.length] = new Option(toCurrency(i) + "€", i);}if (saleRent ==  LANG_PROP_SEARCH_SALERENT_SALE_VAL) {priceMaxList.options[priceMaxList.options.length] = new Option(LANG_OVER_1_MILLION + "€",'200000000');} else {priceMaxList.options[priceMaxList.options.length] = new Option(LANG_OVER_2_THOUSAND + "€",'200000');}}	function toCurrency(num) {var sign;var cents;var i;num = num.toString().replace(/\$|\,/g, '');if (isNaN(num)) {num = "0";}sign = (num == (num = Math.abs(num)));num = Math.floor(num * 100 + 0.50000000001);cents = num % 100;num = Math.floor(num / 100).toString();if (cents < 10) {cents = '0' + cents;}for (i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++) {num = num.substring(0, num.length - (4 * i + 3)) + LANG_CURRENCY_SEP + num.substring(num.length - (4 * i + 3));}return (((sign) ? '' : '-') + num);}});
