var xmlHttp


function showListings(str)
{ 
	if(str !=""){
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		  {
		  alert ("Your browser does not support AJAX!");
		  return;
		  } 
		var url="listhomes.php";
		url=url+"?"+str;
		url=url+"&sid="+Math.random();
		//alert (url);
		document.getElementById("loading").style.display = 'block';
				
		xmlHttp.onreadystatechange=stateChanged;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
		
	}
}




function stateChanged() 
{ 
	if (xmlHttp.readyState==4)
	{ 
		document.getElementById("resultcontent").innerHTML='';

		document.getElementById("resultcontent").innerHTML=xmlHttp.responseText;
		document.getElementById("loading").style.display = 'none';
		scroll(0,0);
	}
}

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 searchFirst(){
checkAll(document.myform.theTowns1);
	searchIt('0', 1, 500);
}


function searchIt(positioned, curr, startCost){

var minprice, maxprice, beds, baths, thestyle, thetype, tTown, tSort,tMls;
var urlstr;
var tClass;
var tCounty;

tClass = "";
thetype = "";
tCounty = "";

tMls = document.getElementById("mlsnum").value; 

if ( tMls !="" ){
	document.getElementById("mlsnum").value=''; 
    	document.location.href='http://www.vaodwyer.com/rental/rental.php?id='+ tMls;
}

if ( startCost === undefined ) {
    	minprice = document.getElementById("MinPrice").value; 
  	}else{
  		minprice = startCost; 
}

if ( document.getElementById("orderBy")== null) {
    	tSort = 'Price';
  	}else{
  		tSort = document.getElementById("orderBy").value;
	
}
//alert(document.getElementById("orderBy").value);

 maxprice = document.getElementById("MaxPrice").value; 
 beds = document.getElementById("form_beds").value; 
// baths = document.getElementById("form_baths").value; 
// thestyle = document.getElementById("form_style").value; 
// thetype = document.getElementById("form_type").value; 
 tTown = get_check_value(); //document.getElementById("form_towns").value; 
 tClass= tClass+"Ren"+"^";
 
   if (document.getElementById("Suffolk").checked == true){
	 	tCounty= tCounty+"Suffolk"+"^";
	 }
	/*  if (document.getElementById("Nassua").checked == true){
	 	tCounty= tCounty+"Nassua"+"^";
	 }
	*/

 
urlStr = "Town="+ tTown +"&MinPrice="+ minprice +"&MaxPrice="+ maxprice +"&beds="+ beds +"&position="+ positioned +"&Class="+ tClass +"&currpage="+ curr +"&sortby="+ tSort+"&tCounty="+ tCounty;

//alert(urlStr);
showListings(urlStr);

}
