var xmlHttp

function showstate(str,page)
{
var today = new Date();
var year = today.getYear();
var month = today.getMonth();
var day = today.getDay();

var hours = today.getHours();
var minutes = today.getMinutes();
var seconds = today.getSeconds();
var time_holder=year+'/'+month+'/'+day+':'+hours+'-'+minutes+'-'+seconds;

//alert('ok');
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
 var sid="";
 if(str=="all")
 {
	//sid=randomnumber();
	sid=1;
	document.getElementById("state").value="all";
 }
 else
 {
	document.getElementById("state").value=str;
	sid=str; 
 }
var url="fetch_property.php" //Change to the file that calls the database
url=url+"?sid="+sid
url=url+"&page="+page
url=url+"&time_holder="+time_holder
//alert(url);
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
xmlHttp.onreadystatechange=function()
			{
				if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
				 { 
				 document.getElementById("txtHint").innerHTML=xmlHttp.responseText
				 showproperty(sid,'new');
				 } 
			}

}

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;
}

function randomnumber()
{
	var rand=Math.random()*51;
	if(rand==0)
	{
		randomnumber();
	}
	return (rand);
}

function showproperty(propertyid,type)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	 var url="fetch_propertydetails.php" //Change to the file that calls the database
	url=url+"?propertyid="+propertyid
	url=url+"&type="+type
	//alert(url);
	xmlHttp.onreadystatechange=stateChangedProperty 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function stateChangedProperty() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 {
	 //alert(xmlHttp.responseText );
 document.getElementById("property").innerHTML=xmlHttp.responseText 
 } 
}
