	var tmpstr = "";
	var xmlHttp;

function showRegions()
{ 
	document.getElementById("searchtbl").style.backgroundColor = "#ff8800";	

	var suburb = document.getElementById("arealist").value;

	document.getElementById("searchtbl").style.backgroundColor = "#ffff00";	

	var btype = document.getElementById("btype").value;

	document.getElementById("searchtbl").style.backgroundColor = "#ffff00";	

	var region = document.getElementById("regionlist").value;

	document.getElementById("searchtbl").style.backgroundColor = "#ff00ff";	

	var showdays = document.getElementById("showdays").value;
	
	document.getElementById("searchtbl").style.backgroundColor = "#888800";	

	var sv = document.getElementById("sv").value;

	document.getElementById("searchtbl").style.backgroundColor = "#008888";	

	xmlHttparea=GetXmlHttpObject();
	if (xmlHttparea==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	} 
	var url="/include/getRegions.asp";
	url=url+"?region="+region;
	url=url+"&btype="+btype;
	url=url+"&showdays=0"+showdays;
	url=url+"&sv=0"+sv;
	url=url+"&sid="+Math.random();
	xmlHttparea.onreadystatechange=stateChangedarea ;
	xmlHttparea.open("GET",url,true);
	xmlHttparea.send(null);
	document.getElementById("searchtbl").style.backgroundColor = "#1F2325";	
}

function showAreas()
{ 
	document.getElementById("searchtbl").style.backgroundColor = "#ff8800";	

	var suburb = document.getElementById("arealist").value;

	document.getElementById("searchtbl").style.backgroundColor = "#ffff00";	

	var btype = document.getElementById("btype").value;

	document.getElementById("searchtbl").style.backgroundColor = "#ff0000";	

	var region = document.getElementById("regionlist").value;

	document.getElementById("searchtbl").style.backgroundColor = "#ff00ff";	

	var showdays = document.getElementById("showdays").value;
	
	document.getElementById("searchtbl").style.backgroundColor = "#888800";	

	var sv = document.getElementById("sv").value;

	document.getElementById("searchtbl").style.backgroundColor = "#008888";	

	xmlHttparea=GetXmlHttpObject();
	if (xmlHttparea==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	} 
	var url="/include/getAreas.asp";
	url=url+"?q="+suburb;
	url=url+"&region="+region;
	url=url+"&btype="+btype;
	url=url+"&showdays=0"+showdays;
	url=url+"&sv=0"+sv;
	url=url+"&sid="+Math.random();
	xmlHttparea.onreadystatechange=stateChangedarea ;
	xmlHttparea.open("GET",url,true);
	xmlHttparea.send(null);
	document.getElementById("searchtbl").style.backgroundColor = "#1F2325";	
}

function showAreas2(thissuburb)
{ 
	document.getElementById("searchtbl").style.backgroundColor = "#ff0000";	

	var suburb = document.getElementById("arealist").value;
	var region = document.getElementById("regionlist").value;
	document.getElementById("searchtbl").style.backgroundColor = "#0000ff";	
	var btype = document.getElementById("btype").value;
	document.getElementById("searchtbl").style.backgroundColor = "#00ff00";	
	var pricefrom = document.getElementById("pricefrom").value;
	var priceto = document.getElementById("priceto").value;
	var norooms = document.getElementById("norooms").value;
	document.getElementById("searchtbl").style.backgroundColor = "#ffff00";	
	var showdays = document.getElementById("showdays").value;
	var sv = document.getElementById("sv").value;

	xmlHttparea=GetXmlHttpObject();
	if (xmlHttparea==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	} 
	var url="/include/getAreas.asp";
	url=url+"?q="+suburb;
	url=url+"&region="+region;
	url=url+"&btype="+btype;
	url=url+"&size=1";
	url=url+"&showdays=0"+showdays;
	url=url+"&sv=0"+sv;
	url=url+"&selected="+thissuburb;
	url=url+"&sid="+Math.random();
	xmlHttparea.onreadystatechange=stateChangedarea ;
	xmlHttparea.open("GET",url,true);
	xmlHttparea.send(null);
	document.getElementById("searchtbl").style.backgroundColor = "#1F2325";	
}

function stateChangedarea() 
{ 
	if (xmlHttparea.readyState==4 || xmlHttparea.readyState=="complete")
	{ 
		document.getElementById("txtAreas").innerHTML=xmlHttparea.responseText;
	} 
} 

function showRooms(defrooms)
{ 
	document.getElementById("searchtbl").style.backgroundColor = "#00ff00";	
	var suburb = document.getElementById("arealist").value;
	var region = document.getElementById("regionlist").value;
	var btype = document.getElementById("btype").value;
	var pricefrom = document.getElementById("pricefrom").value;
	var priceto = document.getElementById("priceto").value;
	var norooms = document.getElementById("norooms").value;
	var showdays = document.getElementById("showdays").value;
	var sv = document.getElementById("sv").value;

	xmlHttprm=GetXmlHttpObject();
	if (xmlHttprm==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	} 
	var url="/include/getNoRooms.asp";
	url=url+"?pricefrom="+pricefrom;
	url=url+"&priceto="+priceto;
	url=url+"&btype="+btype;
	url=url+"&suburb="+suburb;
	url=url+"&region="+region;
	if(sv.length>0)
	{
	url=url+"&sv=0"+sv;
	}
	if(showdays.length>0)
	{
	url=url+"&showdays=0"+showdays;
	}
	if(defrooms*1>0)
	{
	url=url+"&defrooms=0"+defrooms;
	}
	url=url+"&sid="+Math.random();
	xmlHttprm.onreadystatechange=stateChangedrm ;
	xmlHttprm.open("GET",url,true);
	xmlHttprm.send(null);
	document.getElementById("searchtbl").style.backgroundColor = "#1F2325";	
}

function stateChangedrm() 
{ 
	if (xmlHttprm.readyState==4 || xmlHttprm.readyState=="complete")
	{ 
		document.getElementById("txtNoRooms").innerHTML=xmlHttprm.responseText;
	} 
} 


function showPriceRange(p1,p2)
{ 
	document.getElementById("searchtbl").style.backgroundColor = "#ffff00";	

	var suburb = document.getElementById("arealist").value;
	var region = document.getElementById("regionlist").value;
	var btype = document.getElementById("btype").value;
	var priceField = document.getElementById("pricetype").value*1;
	var showdays = document.getElementById("showdays").value;
	var sv = document.getElementById("sv").value;
	


	xmlHttppr=GetXmlHttpObject();
	if (xmlHttppr==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	} 
	var url="/include/getPriceRange.asp";
	url=url+"?q="+btype;
	url=url+"&r1="+region;
	url=url+"&q1="+suburb;
	url=url+"&t1="+ priceField;
	url=url+"&s1="+ p1;
	url=url+"&s2="+ p2;
	url=url+"&showdays=0"+showdays;
	url=url+"&sv=0"+sv;
	url=url+"&sid="+Math.random();
	xmlHttppr.onreadystatechange=stateChangedPR;
	xmlHttppr.open("GET",url,true);
	xmlHttppr.send(null);
	document.getElementById("searchtbl").style.backgroundColor = "#1F2325";	
}

function stateChangedPR() 
{ 
	if (xmlHttppr.readyState==4 || xmlHttppr.readyState=="complete")
	{ 
		document.getElementById("txtPriceRange").innerHTML=xmlHttppr.responseText;
	} 
}

function showNoResults()
{ 
	var suburb = document.getElementById("arealist").value;
	var region = document.getElementById("regionlist").value;
	var btype = document.getElementById("btype").value;
	var pricefrom = document.getElementById("pricefrom").value;
	var priceto = document.getElementById("priceto").value;
	var norooms = document.getElementById("norooms").value;
	var extras = "";
	var priceField = document.getElementById("pricetype").value*1;
	var showdays = document.getElementById("showdays").value;
	var sv = document.getElementById("sv").value;
	
	for(i=0; i<document.forms['thesearchform'].elements.length; i++){
if(document.forms['thesearchform'].elements[i].name=='amenities')
	{
		if(document.forms['thesearchform'].elements[i].checked==true)
		{
		   extras = extras + document.forms['thesearchform'].elements[i].value + "|";
		}
    }
   }

	
	xmlHttpnr=GetXmlHttpObject();
	
	if (xmlHttpnr==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	} 
	var url="/include/getNoResults.asp";
	url=url+"?suburb="+suburb;
	url=url+"&pregion="+region;
	url=url+"&pcategory="+btype;
	url=url+"&pricefrom="+pricefrom;
	url=url+"&priceto="+priceto;
	url=url+"&norooms="+norooms;
	url=url+"&showdays=0"+showdays;
	url=url+"&sv=0"+sv;
	url=url+"&pt="+priceField;
	url=url+"&extras="+extras;
	url=url+"||&sid="+Math.random();
	xmlHttpnr.onreadystatechange=stateChangedNR;
	xmlHttpnr.open("GET",url,true);
	xmlHttpnr.send(null);

	xmlHttpnrA=GetXmlHttpObject();
	
	if (xmlHttpnrA==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	} 

	url="/include/getNoResults.asp";
	url=url+"?suburb="+suburb;
	url=url+"&pregion="+region;
	url=url+"&pcategory="+btype;
	url=url+"&pricefrom="+pricefrom;
	url=url+"&priceto="+priceto;
	url=url+"&showdays=0"+showdays;
	url=url+"&sv=0"+sv;
	url=url+"&norooms="+norooms;
	url=url+"&pt="+priceField;
	url=url+"&extras="+extras;
	url=url+"&ps=1&sid="+Math.random();
	xmlHttpnrA.onreadystatechange=stateChangedNRud;
	xmlHttpnrA.open("GET",url,true);
	xmlHttpnrA.send(null);
}

function stateChangedNR() 
{ 
	if (xmlHttpnr.readyState==4 || xmlHttpnr.readyState=="complete")
	{ 
		document.getElementById("txtNoResults").innerHTML=xmlHttpnr.responseText;
		if(document.getElementById("txtNoResults").innerHTML*1==0)
		{
			document.getElementById("srchbut").src="/images/btn_ViewResultsDisabled2.gif";
			document.getElementById("srchbut").disabled=true;
		}
		else
		{
			document.getElementById("srchbut").src="/images/btn_ViewResults2.gif";
			document.getElementById("srchbut").disabled=false;
		}
		
		if(document.getElementById("txtNoResults").innerHTML*1==9999999999999)
		{
			document.getElementById("txtNoResults").innerHTML="n/a";
			document.getElementById("rscnt").style.display="none";
		}
		else
		{
			document.getElementById("rscnt").style.display="";
		}
	} 
} 

function stateChangedNRud() 
{ 
	var idlist = "";
	var idarr = new Array();
	var prodarr = new Array();
	var idstr = "";
	
	var pid = 0;
	var ptitle = "";
	var pdetails = "";
	var pcategory = "";
	var pnorooms = "";
	var psalesprice = "";
	var prentalprice = "";
	var pimg = "";
	var asuburb = "";
	
	if (xmlHttpnrA.readyState==4 || xmlHttpnrA.readyState=="complete")
	{ 
		idlist=xmlHttpnrA.responseText;
		idarr = idlist.split('|');

		for(i=0; i<idarr.length; i++){
		
		prodarr = idarr[i].split(',');
		
		if(1==2)
		{
				if(prodarr[0]*1>0)
				{
					pid = prodarr[0];
					ptitle =  prodarr[1];
					pdetails =  "<strong>Bedrooms:</strong> " + prodarr[2] + "<br>";
					psalesprice =  prodarr[3];
					prentalprice =  prodarr[4];
					pcategory =  prodarr[5];
					pimg =  "url(/UserFiles/Image/Properties/t_" + pid + "-" + prodarr[6] + ")";
					asuburb =  prodarr[7];
					
					if(pcategory=="Sales")
					{
						pdetails = pdetails + "<strong>Area:</strong> " + asuburb + "<br>";
						pdetails = pdetails + "<strong>Purchase Price:</strong> R" + FormatNumber(psalesprice,0,0,0,1) + "<br>";
					}
					else
					{
						pdetails = pdetails + "<strong>Area:</strong> " + asuburb + "<br>";
						pdetails = pdetails + "<strong>Rental Price:</strong> R" + FormatNumber(prentalprice,0,0,0,1) + "<br>";
					}
					
					idstr = "" + (i*1+1);

					document.getElementById("p" + idstr + "pic").style.backgroundImage=pimg;
					document.getElementById("p" + idstr + "title").innerHTML=ptitle;
					document.getElementById("p" + idstr + "details").innerHTML=pdetails;
			    }
				else if(i<3)
				{
					idstr = "" + (i*1+1);
					
					document.getElementById("p" + idstr + "pic").style.backgroundImage="";
					document.getElementById("p" + idstr + "title").innerHTML="";
					document.getElementById("p" + idstr + "details").innerHTML="";
				}
		}
	} 
} 
}

function GetXmlHttpObject()
{ 
var objXMLHttp=null;

	if (window.XMLHttpRequest)
	{
		objXMLHttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
return objXMLHttp;
}

function FormatNumber(num,decimalNum,bolLeadingZero,bolParens,bolCommas)
/**********************************************************************
	IN:
		NUM - the number to format
		decimalNum - the number of decimal places to format the number to
		bolLeadingZero - true / false - display a leading zero for
										numbers between -1 and 1
		bolParens - true / false - use parenthesis around negative numbers
		bolCommas - put commas as number separators.
 
	RETVAL:
		The formatted number!
 **********************************************************************/
{ 
        if (isNaN(parseInt(num))) return "NaN";

	var tmpNum = num;
	var iSign = num < 0 ? -1 : 1;		// Get sign of number
	
	// Adjust number so only the specified number of numbers after
	// the decimal point are shown.
	tmpNum *= Math.pow(10,decimalNum);
	tmpNum = Math.round(Math.abs(tmpNum))
	tmpNum /= Math.pow(10,decimalNum);
	tmpNum *= iSign;					// Readjust for sign
	
	
	// Create a string object to do our formatting on
	var tmpNumStr = new String(tmpNum);

	// See if we need to strip out the leading zero or not.
	if (!bolLeadingZero && num < 1 && num > -1 && num != 0)
		if (num > 0)
			tmpNumStr = tmpNumStr.substring(1,tmpNumStr.length);
		else
			tmpNumStr = "-" + tmpNumStr.substring(2,tmpNumStr.length);
		
	// See if we need to put in the commas
	if (bolCommas && (num >= 1000 || num <= -1000)) {
		var iStart = tmpNumStr.indexOf(".");
		if (iStart < 0)
			iStart = tmpNumStr.length;

		iStart -= 3;
		while (iStart >= 1) {
			tmpNumStr = tmpNumStr.substring(0,iStart) + "," + tmpNumStr.substring(iStart,tmpNumStr.length)
			iStart -= 3;
		}		
	}

	// See if we need to use parenthesis
	if (bolParens && num < 0)
		tmpNumStr = "(" + tmpNumStr.substring(1,tmpNumStr.length) + ")";

	return tmpNumStr;		// Return our formatted string!
}

