var xmlHttp

function getSuburbs(str)
	{ 
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 
	var url="showsuburbs.asp";
	url=url+"?districtid="+escape(document.getElementById("districtid").value);
	url=url+"&suburb_id="+escape(document.getElementById("suburb_id").value);
	url=url+"&selectedsuburbid="+escape(document.getElementById("suburbid").value);
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChangedSuburbs;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	//alert('called');
	}	
	
function stateChangedSuburbs() 
{ 
if (xmlHttp.readyState==4)
	{
	document.getElementById("suburbresults").innerHTML=xmlHttp.responseText;
	//document.getElementById("selectedsuburbid").value+=document.getElementById("selectedids").value;
	}
}

function clearsubs()
{
document.getElementById("suburbid").value="";
document.getElementById("suburb_id").value="";
getSuburbs();
}

function updateSuburbs(str) 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("suburb_id").value = document.getElementById("suburbid").value;
}
}

function addFav(propid,custid)
	{ 
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 
	var url="myfav_ajax.asp";
	url=url+"?propertysellid="+escape(propid);
	url=url+"&customerid="+escape(custid);
	url=url+"&typeid=1";
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChangedAddFav;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	
	}	
	
function stateChangedAddFav() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("statusaddfav").innerHTML=xmlHttp.responseText;

}
}

function removeFav(propid,custid)
	{ 
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 
	var url="myfav_ajax.asp";
	url=url+"?propertysellid="+escape(propid);
	url=url+"&customerid="+escape(custid);
	url=url+"&typeid=2";
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChangedRemoveFav;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	
	}	
	
function stateChangedRemoveFav() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("showstatusremovefav").innerHTML=xmlHttp.responseText;
window.location.reload();

}
}

function saveSearch(custid)
	{ 
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 
	var url="mysavedsearches_ajax.asp";
	url=url+"?customerid="+escape(custid);
	url=url+"&districtid="+escape(document.getElementById("districtid").value);
	url=url+"&suburbid="+escape(document.getElementById("suburbid").value);
	url=url+"&propertytype="+escape(document.getElementById("propertytype").value);
	url=url+"&bedroomsfrom="+escape(document.getElementById("bedroomsfrom").value);
	url=url+"&bedroomsto="+escape(document.getElementById("bedroomsto").value);
	url=url+"&pricefrom="+escape(document.getElementById("pricefrom").value);
	url=url+"&priceto="+escape(document.getElementById("priceto").value);
	url=url+"&searchtitle="+escape(document.getElementById("searchtitle").value);
	url=url+"&typeid=1";
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChangedSaveSearch;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	
	}	
	
function stateChangedSaveSearch() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("statussavesearch").innerHTML=xmlHttp.responseText;
showSearch(document.getElementById("custupdateid").value);
}
}

function showSearch(custid)
	{ 
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 
	var url="mysavedsearches_ajax.asp";
	url=url+"?customerid="+escape(custid);
	url=url+"&typeid=2";
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChangedShowSearches;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	}	
	
function stateChangedShowSearches() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("statusshowsearches").innerHTML=xmlHttp.responseText;

}
}

function removeSearch()
	{ 
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 
	var url="mysavedsearches_ajax.asp";
	url=url+"?id="+escape(document.getElementById("showsearchselect").value);
	url=url+"&custid="+escape(document.getElementById("custupdateid").value);
	url=url+"&typeid=3";
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChangedShowRemove;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	
	}	
	
function stateChangedShowRemove() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("statusshowremove").innerHTML=xmlHttp.responseText;

showSearch(document.getElementById("custupdateid").value);
}
}

function openSearchResults()
	{ 
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 
	var url="mysavedsearches_ajax.asp";
	url=url+"?id="+escape(document.getElementById("showsearchselect").value);
	url=url+"&custid="+escape(document.getElementById("custupdateid").value);
	url=url+"&typeid=4";
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChangedOpenSearchResults;
	xmlHttp.open("get",url,true);
	xmlHttp.send(null);
s	
	}	
	
function stateChangedOpenSearchResults() 
{ 
if (xmlHttp.readyState==4)
{ 
//showSearch(document.getElementById("custupdateid").value);
}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}