<!--
arrSelected = new Array(-1,-1,-1,-1,-1,-1,-1,-1);
arrClasses = new Array(0,"For Sale",1,"Long Term Rental",2,"Short Term Rental");

intPropertyCount = 0;

arrPR1_0 = new Array(-1,'All',0,'0',150000,'150,000',300000,'300,000',500000,'500,000',800000,'800,000',1200000,'1,200,000',1500000,'1,500,000',2000000,'2,000,000',3500000,'3,500,000');
arrPR2_0 = new Array(300000,'300,000',500000,'500,000',800000,'800,000',1200000,'1,200,000',1500000,'1,500,000',2000000,'2,000,000',3500000,'3,500,000',5000000,'5,000,000',-2,'5,000,000+');
arrPR1_1 = new Array(-1,'All',0,'0',1000,'1,000',1500,'1,500',2000,'2,000',2500,'2,500',3000,'3,500',4000,'4,500',5000,'5,000',6000,'6,000',8000,'8,000',10000,'10,000',12500,'12,500',15000,'15,000',17500,'17,500',20000,'20,000');
arrPR2_1 = new Array(1500,'1,500',2000,'2,000',2500,'2,500',3000,'3,500',4000,'4,500',5000,'5,000',6000,'6,000',8000,'8,000',10000,'10,000',12500,'12,500',15000,'15,000',17500,'17,500',20000,'20,000',-2,'20,000+');
arrPR1_2 = new Array(-1,'All',0,'0',1000,'1,000',1500,'1,500',2000,'2,000',2500,'2,500',3000,'3,500',4000,'4,500',5000,'5,000',6000,'6,000',8000,'8,000',10000,'10,000',12500,'12,500',15000,'15,000',17500,'17,500',20000,'20,000');
arrPR2_2 = new Array(1500,'1,500',2000,'2,000',2500,'2,500',3000,'3,500',4000,'4,500',5000,'5,000',6000,'6,000',8000,'8,000',10000,'10,000',12500,'12,500',15000,'15,000',17500,'17,500',20000,'20,000',-2,'20,000+');

TP_arrPR1 = arrPR1_0;
TP_arrPR2 = arrPR2_0;

function Opt(strElement)
{
	this.intSelectedIndex = 0;
	this.objSelect = eval("document.frmQS." + strElement);
	this.strObject = "document.frmQS." + strElement + ".options";
	this.intLength = 0;
	this.intStart = 0;

	this.updateLength = function updateLength()
	{
		this.intLength = eval(this.strObject + ".length");
	}

	this.addItem = function addItem(intIndex,strName,strValue)
	{
		eval(this.strObject + "[intIndex] = new Option(strName,strValue)");
		this.updateLength();
	}
	this.removeItem = function removeItem(intIndex)
	{
		eval(this.strObject + "[intIndex] = null");
		this.updateLength();
	}

	this.createList = function createList(arrList,intStep,intSeek,strHeader)
	{
		this.checkHeader(strHeader);
		for ( i = 0, j = this.intStart; i < arrList.length; i += intStep )
		{
			if ( (intSeek == null) || ((intSeek != null) && (arrList[i+2] == intSeek)) )
			{
				this.addItem(j,arrList[i+1],arrList[i]);
				j++;
			}
		}
	}
	this.destroyList = function destroyList()
	{
		for ( i = (this.intLength - 1); i >= 0; i-- ) this.removeItem(i);
	}
	
	this.checkHeader = function checkHeader(strMsg)
	{
		if ( strMsg == null ) this.intStart = 0;
		else
		{
			this.addItem(0,strMsg,-1);
			this.intStart = 1;
		}
	}
	
	this.setAble = function setAble(booSwitch)
	{
		this.objSelect.disabled = !(booSwitch);
	}
	
	this.selectOption = function selectOption(intValue)
	{
		intIndex = 0;
		for ( i = 0; i < this.intLength; i++ )
		{
			eval("intChk = " + this.strObject + "[i].value");
			if ( intChk == intValue ) intIndex = i;
		}
		eval(this.strObject + "[intIndex].selected = true");
		this.intSelectedIndex = intValue;
	}
}

function initSelects()
{
	objClass = new Opt("c1ass");
	objClass.createList(arrClasses,2,null,"All");
	objType = new Opt("type");
	objType.addItem(0,"All",-1);
	objSubType = new Opt("subtype");
	objSubType.addItem(0,"All",-1);

	objProvince = new Opt("province");
	objProvince.createList(TP_arrProvinces,2,null,"All");
	objCityTown = new Opt("citytown");
	objCityTown.addItem(0,"All",-1);
	objSuburb = new Opt("suburb");
	objSuburb.addItem(0,"All",-1);
	
	objPriceRange1 = new Opt("pricemin");
	objPriceRange1.createList(TP_arrPR1,2,null,null);
	objPriceRange2 = new Opt("pricemax");
	objPriceRange2.createList(TP_arrPR2,2,null,null);
	
	updateCount(0,-1);
}

function updateSelects(strSelect)
{
	intSelected = eval("document.frmQS." + strSelect + ".options[document.frmQS." + strSelect + ".selectedIndex].value");
	
	if ( strSelect == "c1ass" )
	{
		objClass.destroyList();
		objClass.createList(arrClasses,2,null,"All");
		objClass.selectOption(intSelected);
		objType.destroyList();
		objType.setAble(1);
		if ( TP_arrTypes[0] == null ) objType.addItem(0,"None",-1);
		else objType.createList(TP_arrTypes,3,intSelected,"All");
		objSubType.destroyList();
		if ( TP_arrSubTypes[0] == null ) objSubType.addItem(0,"None",0);
		else objSubType.addItem(0,"All");
		
		if ( intSelected == -1 )
		{
			objPriceRange1.setAble(0);
			objPriceRange2.setAble(0);
		}
		else
		{
			TP_arrPR1 = eval("arrPR1_" + intSelected);
			objPriceRange1.destroyList();
			objPriceRange1 = new Opt("pricemin");
			objPriceRange1.createList(TP_arrPR1,2,null,null);
			objPriceRange1.setAble(1);
			
			TP_arrPR2 = eval("arrPR2_" + intSelected);
			objPriceRange2.destroyList();
			objPriceRange2 = new Opt("pricemax");
			objPriceRange2.createList(TP_arrPR2,2,null,null);
			objPriceRange2.setAble(0);
		}
		intCriteria = 0;
	}
	else if ( strSelect == "type" )
	{
		objType.destroyList();
		objType.createList(TP_arrTypes,3,objClass.intSelectedIndex,"All");
		objType.selectOption(intSelected);
		objSubType.destroyList();
		objSubType.setAble(1);
		if ( TP_arrSubTypes[0] == null ) objSubType.addItem(0,"None",0);
		else objSubType.createList(TP_arrSubTypes,3,intSelected,"All");
		intCriteria = 1;
	}
	else if ( strSelect == "subtype" )
	{
		objSubType.destroyList();
		objSubType.createList(TP_arrSubTypes,3,objType.intSelectedIndex,"All");
		objSubType.selectOption(intSelected);
		intCriteria = 2;
	}
	else if ( strSelect == "province" )
	{
		objProvince.destroyList();
		objProvince.createList(TP_arrProvinces,2,null,"All");
		objProvince.selectOption(intSelected);
		objCityTown.destroyList();
		objCityTown.setAble(1);
		if ( TP_arrCityTowns[0] == null ) objCityTown.addItem(0,"None",-1);
		else objCityTown.createList(TP_arrCityTowns,3,intSelected,"All");
		objSuburb.destroyList();
		if ( TP_arrSuburbs[0] == null ) objSuburb.addItem(0,"None",0);
		else objSuburb.addItem(0,"All");
		intCriteria = 3;
	}
	else if ( strSelect == "citytown" )
	{
		objCityTown.destroyList();
		objCityTown.createList(TP_arrCityTowns,3,objProvince.intSelectedIndex,"All");
		objCityTown.selectOption(intSelected);
		objSuburb.destroyList();
		objSuburb.setAble(1);
		if ( TP_arrSuburbs[0] == null ) objSuburb.addItem(0,"None",0);
		else objSuburb.createList(TP_arrSuburbs,3,intSelected,"All");
		intCriteria = 4;
	}
	else if ( strSelect == "suburb" )
	{
		objSuburb.destroyList();
		objSuburb.createList(TP_arrSuburbs,3,objCityTown.intSelectedIndex,"All");
		objSuburb.selectOption(intSelected);
		intCriteria = 5;
	}
	else if ( strSelect == "pricemin" )
	{
		if ( document.frmQS.pricemin.options[0].selected ) objPriceRange2.setAble(0);
		else objPriceRange2.setAble(1);
		intCriteria = 6;
	}
	else if ( strSelect == "pricemax" )
	{
		if ( document.frmQS.pricemax.options[document.frmQS.pricemax.options.length - 1].selected ) objPriceRange1.setAble(0);
		else objPriceRange1.setAble(1);
		intCriteria = 7;
	}
	
	updateCount(intSelected,intCriteria);
}

function updateCount(intValue,intWhich)
{
	arrSelected[intWhich] = intValue;
	intCounter = 0;

	if ( intWhich == 6 )
	{
		if ( arrSelected[6] != -1 ) arrSelected[7] = document.frmQS.pricemax.options[document.frmQS.pricemax.selectedIndex].value;
		else arrSelected[7] = -1, intStart = 1;
	}
	if ( intWhich == 7 )
	{
		if ( arrSelected[7] != -1 ) arrSelected[6] = document.frmQS.pricemin.options[document.frmQS.pricemin.selectedIndex].value;
		else arrSelected[6] = -1;
	}

	for ( i = 0; i < TPL_arrQSProps.length; i += 8 )
	{
		if ( (arrSelected[0] != -1) && (TPL_arrQSProps[i] != arrSelected[0]) ) continue;	//	property c1ass
		if ( (arrSelected[1] != -1) && (TPL_arrQSProps[i+1] != arrSelected[1]) ) continue;	//	property type
		if ( (arrSelected[2] != -1) && (TPL_arrQSProps[i+2] != arrSelected[2]) ) continue;	//	property sub type
		if ( (arrSelected[3] != -1) && (TPL_arrQSProps[i+4] != arrSelected[3]) ) continue;	//	location - province
		if ( (arrSelected[4] != -1) && (TPL_arrQSProps[i+5] != arrSelected[4]) ) continue;	//	location - city/town
		if ( (arrSelected[5] != -1) && (TPL_arrQSProps[i+6] != arrSelected[5]) ) continue;	//	location - suburb

		if ( (arrSelected[6] != -1) && (TPL_arrQSProps[i+7] < arrSelected[6]) ) continue;
		if ( (arrSelected[7] != -1) && (arrSelected[7] != -2) && (TPL_arrQSProps[i+7] > arrSelected[7]) ) continue;

		if ( (arrSelected[7] != -1) && (arrSelected[7] == -2) && (TPL_arrQSProps[i+7] <= TP_arrPR2[TP_arrPR2.length-4]) ) continue;
	
		intCounter++;
	}
	
	document.frmQS.elements[9].value = "Properties: " + intCounter;
	intPropertyCount = intCounter;
}

function checkResults()
{
	if ( intPropertyCount ) return true;
	else
	{
		alert('There are no results to display.');
		return false;
	}
}
//-->