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 getCustSuburbs(str)
	{ 
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 
	var url="custshowsuburbs.asp";
	url=url+"?custdistrictid="+escape(document.getElementById("custdistrictid").value);
	url=url+"&custsuburb_id="+escape(document.getElementById("custsuburb_id").value);
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChangedCustSuburbs;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	//alert('called');
	}	
	
function stateChangedCustSuburbs() 
{ 
if (xmlHttp.readyState==4)
	{
	document.getElementById("custsuburbresults").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 updateCustSuburbs(str) 
{ 
if (xmlHttp.readyState==4)
{ 
//alert(document.getElementById("custsuburbid").value);
//document.getElementById("custsuburb_id").value = document.getElementById("custsuburbid").value;
}
}

var mypropid = null;



function addFav(propid,custid)
	{ 
	mypropid = propid;

	document.getElementById("propstatus"+escape(mypropid)).innerHTML='<div class="loading">Please wait...</div>';
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 
	var url="ajax_watchlist_functions.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(propid) 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("propstatus"+escape(mypropid)).innerHTML=xmlHttp.responseText;

}
}

function removeFav(propid,custid)
	{ 
	mypropid = propid;
	
	document.getElementById("propstatus"+escape(mypropid)).innerHTML='<div class="loading">Please wait...</div>';
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 
	var url="ajax_watchlist_functions.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("propstatus"+escape(mypropid)).innerHTML=xmlHttp.responseText;

}
}

function removeMyFav(propid,custid)
	{ 
	mypropid = propid;
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 
	var url="ajax_watchlist_functions.asp";
	url=url+"?propertysellid="+escape(propid);
	url=url+"&customerid="+escape(custid);
	url=url+"&typeid=3";
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChangedRemoveMyFav;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	
	}	
	
function stateChangedRemoveMyFav() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("propstatus"+escape(mypropid)).innerHTML=xmlHttp.responseText;

//$("#my_fav_pane").load("./ajax_my_favourites.asp", 'Loading...');
reloadTab(1);


}
}

function saveSearch(custid,requeststring)
	{ 
	
	
	
	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("propertytypeid").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+"&searchstring="+escape(requeststring);
	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(custid,searchid)
	{ 
	document.getElementById("statussavesearch").innerHTML='<div class="loading">Please wait...</div>';
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 
	var url="mysavedsearches_ajax.asp";
	url=url+"?id="+escape(searchid);
	url=url+"&customerid="+escape(custid);
	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("statussavesearch").innerHTML=xmlHttp.responseText;


}
}

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;
}