HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ns3133907 6.8.0-86-generic #87-Ubuntu SMP PREEMPT_DYNAMIC Mon Sep 22 18:03:36 UTC 2025 x86_64
User: cssnetorguk (1024)
PHP: 8.2.28
Disabled: NONE
Upload Files
File: /home/mykensington.co.uk/public_html/js/searchPod.js
function setPriceListVisibility()
{
	// Default the buying list to inline and the rental lists to display: none
	setDisplay('minBuyPrice', 'inline');
	setDisplay('minRentPriceWeekly', 'none');
	setDisplay('minRentPriceMonthly', 'none');
	setDisplay('maxBuyPrice', 'inline');
	setDisplay('maxRentPriceWeekly', 'none');
	setDisplay('maxRentPriceMonthly', 'none');
	
	// Override if the user selects rental as the tenure type
	if (getTenureType() == 'rent')
	{
		setRentalPriceListVisibility();
	}
	// Also sort out the display of the weekly/monthly switch
	displayRentalPeriodSwitch();
}

function setRentalPriceListVisibility()
{
	// Default to monthly
	var rentWeeklyListDisplay = 'none';
	var rentMonthlyListDisplay = 'inline';
	
	if (getRentalPeriod() == 'weekly')
	{
		// Make the weekly list inline
		rentWeeklyListDisplay = 'inline';
		rentMonthlyListDisplay = 'none';
	}

	setDisplay('minBuyPrice', 'none');
	setDisplay('minRentPriceWeekly', rentWeeklyListDisplay);
	setDisplay('minRentPriceMonthly', rentMonthlyListDisplay);
	setDisplay('maxBuyPrice', 'none');
	setDisplay('maxRentPriceWeekly', rentWeeklyListDisplay);
	setDisplay('maxRentPriceMonthly', rentMonthlyListDisplay);
}

function setLocationInputVisibility()
{
	// Default to visible
	var locationInputDisplay;
	var mapInputDisplay;
	var el;
	
	if (getDisplayResults() != 'list')
	{
		locationInputDisplay = 'none';
		mapInputDisplay = 'block';
		
		// Lower the UK region map image to expose the image map and make it clickable
		if (el = findDOM('ukRegionsImg', 1))
		{
			el.zIndex = 0;
		}
	}
	else
	{
		locationInputDisplay = 'block';
		mapInputDisplay = 'none';
		
		// Raise the UK region map image to cover the image map and make it non-clickable
		if (el = findDOM('ukRegionsImg', 1))
		{
			el.zIndex = 10;
		}
	}
	setDisplay('locationInput', locationInputDisplay);
	setDisplay('mapInput', mapInputDisplay);
}

function displayRentalPeriodSwitch()
{
	var weeklyDisplay;
	var monthlyDisplay;
	
	if (getTenureType() == 'rent')
	{
		
		if (getRentalPeriod() == 'weekly')
		{
			weeklyDisplay = 'inline';
			monthlyDisplay = 'none';
		}
		else
		{
			weeklyDisplay = 'none';
			monthlyDisplay = 'inline';
		}
	}
	else
	{
		weeklyDisplay = 'none';
		monthlyDisplay = 'none';
	}
	
	setDisplay('rentalPeriodSwitchWeekly', weeklyDisplay);
	setDisplay('rentalPeriodSwitchMonthly', monthlyDisplay);
}

function getDisplayResults()
{
	return radioActive(findDOM('searchByAreaForm', 0).displayResults);
}

function getTenureType()
{
	return radioActive(findDOM('searchByAreaForm', 0).tenureType);
}

function getRentalPeriod()
{
	return findDOM('searchByAreaForm', 0).rentalPeriod.value;
}

function setRentalPeriod(period)
{
	findDOM('searchByAreaForm', 0).rentalPeriod.value = period;
}

function getMinRentPriceMonthly()
{
	if(findDOM('searchByAreaForm', 0).minRentPriceMonthly)
	{
		return findDOM('searchByAreaForm', 0).minRentPriceMonthly.value;
	}
	else
	{
		return 0;
	}
}

function getMaxRentPriceMonthly()
{
	if(findDOM('searchByAreaForm', 0).maxRentPriceMonthly)
	{
		return findDOM('searchByAreaForm', 0).maxRentPriceMonthly.value;
	}
	else
	{
		return 99999999;
	}
}

function getMinRentPriceWeekly()
{
	if(findDOM('searchByAreaForm', 0).minRentPriceWeekly)
	{
		return findDOM('searchByAreaForm', 0).minRentPriceWeekly.value;
	}
	else
	{
		return 0;
	}
}

function getMaxRentPriceWeekly()
{	
	if(findDOM('searchByAreaForm', 0).maxRentPriceWeekly)
	{
		return findDOM('searchByAreaForm', 0).maxRentPriceWeekly.value;
	}
	else
	{
		return 99999999;
	}
}

function setMinRentPrice(price)
{
	if(findDOM('searchByAreaForm', 0).minRentPrice) findDOM('searchByAreaForm', 0).minRentPrice.value = price;
	if(findDOM('searchByAreaForm', 0).minRentPriceWeekly) findDOM('searchByAreaForm', 0).minRentPriceWeekly.value = price;
	if(findDOM('searchByAreaForm', 0).minRentPriceMonthly) findDOM('searchByAreaForm', 0).minRentPriceMonthly.value = price;
}

function setMaxRentPrice(price)
{	
	if(findDOM('searchByAreaForm', 0).maxRentPrice) findDOM('searchByAreaForm', 0).maxRentPrice.value = price;
	if(findDOM('searchByAreaForm', 0).maxRentPriceWeekly) findDOM('searchByAreaForm', 0).maxRentPriceWeekly.value = price;
	if(findDOM('searchByAreaForm', 0).maxRentPriceMonthly) findDOM('searchByAreaForm', 0).maxRentPriceMonthly.value = price;
}

function setWeeklyRentalPeriod()
{
	setRentalPeriod('weekly');
	setPriceListVisibility();
}

function setMonthlyRentalPeriod()
{
	setRentalPeriod('monthly');
	setPriceListVisibility();
}

function setRentalPrices()
{
	var minPrice;
	var maxPrice;
	if (getRentalPeriod() == 'weekly') {
		minPrice = getMinRentPriceWeekly();
		maxPrice = getMaxRentPriceWeekly();
	} else {
		minPrice = getMinRentPriceMonthly();
		maxPrice = getMaxRentPriceMonthly();
	}
	setMinRentPrice(minPrice);
	setMaxRentPrice(maxPrice);
}

function clearPartyFormElements()
{
	var form = document.getElementById("PartySearchForm");
	if(form != null)
	{
		form.searchString.value = "";
		form.nameSearchString.value = "";
	}
}
		
function init()
{
	setPriceListVisibility();
	/** TODO: Remove once UI is finalised
	setLocationInputVisibility();
	*/
	addEvent('buyRadio', 'change', setPriceListVisibility, false);
	addEvent('buyRadio', 'click', setPriceListVisibility, false);
	addEvent('rentRadio', 'change', setPriceListVisibility, false);
	addEvent('rentRadio', 'click', setPriceListVisibility, false);
	addEvent('searchByAreaForm', 'submit', setRentalPrices, false);
	/** TODO: Remove once UI is finalised
	addEvent('mapRadio', 'change', setLocationInputVisibility, false);
	addEvent('mapRadio', 'click', setLocationInputVisibility, false);
	addEvent('listRadio', 'change', setLocationInputVisibility, false);
	addEvent('listRadio', 'click', setLocationInputVisibility, false);
	// Required for Safari
	addEvent('buyRadio', 'mouseup', function() { setTimeout("setPriceListVisibility()", 0) }, false);
	addEvent('rentRadio', 'mouseup', function() { setTimeout("setPriceListVisibility()", 0) }, false);
	addEvent('mapRadio', 'mouseup', function() { setTimeout("setLocationInputVisibility()", 0) }, false);
	addEvent('listRadio', 'mouseup', function() { setTimeout("setLocationInputVisibility()", 0) }, false);
	*/
	clearPartyFormElements();
}

// Add the onload safely
/* if(typeof window.onload == "function")
{
   	var previousOnload = window.onload;

	window.onload = function()
		{
			previousOnload();
			init();
		}
}
else
{
	window.onload = init;
}*/
function makeDoubleDelegate(function1, function2) {
    return function() {
        if (function1)
            function1();
        if (function2)
            function2();
    }
}

window.onload = makeDoubleDelegate(window.onload, init )