// JavaScript Document// JavaScript Document
var xmlHttpresult;
var start;
function wantadsearch(nextstart,val){
	start = nextstart;
	var result = document.getElementById("result");
	var option = document.getElementById("selectpropertytype");
	var selectwanttype = document.getElementById('selectwanttype');
	var selectpriceoperator = document.getElementById('selectpriceoperator');
	var txtprice = document.getElementById('price');
	var txtkeywords = document.getElementById('searchfor');
	var selectdistrict = document.getElementById('selectdistrict');
	var selectcity = document.getElementById('selectcity');
	var url = "Scripts/wantsearch.php";
	
	var type = option.value;
		url += "?type="+type;
	var wanttype = selectwanttype.value;
		url += "&wanttype="+wanttype;
	var priceoperator = selectpriceoperator.value;
		url += "&priceoperator="+priceoperator;
	var price = txtprice.value;
		url += "&price="+price;
	var searchkeywords = txtkeywords.value;
		url += "&searchkeywords="+searchkeywords;
	var district = selectdistrict.value;
		url += "&district="+district;
	if(val == 'fmsubmit'){
		var city = selectcity.value;
		url += "&city="+city
	}
		
		
		url += "&start="+start+"&sid="+Math.random();
	
	//result.innerHTML = '<table height="100%" cellspacing="2"><tr><td><img src="images/ajax-loader.gif" alt="Please Wait"/></td><td></td></tr></table>';

	xmlHttpresult = getXmlHttpObject();

	if (xmlHttpresult == null){
		alert ("Browser Does not Support AJAX");
		return;
		}

  xmlHttpresult.onreadystatechange=state_Changeresult;
  xmlHttpresult.open("GET",url,true);
  xmlHttpresult.send(null);

	}
	
	
function state_Changeresult(){
	if(xmlHttpresult.readyState == 4){
	var result = document.getElementById("result");
	result.innerHTML = xmlHttpresult.responseText;
	window.location = "#results"; 
	var selectpagination = document.getElementById('selectpagination');
	if(selectpagination.value != ''){
		
	var pagination = document.getElementById('paginationvalue');
	var	paginationvalue = pagination.value;
		selectnumber = (start/paginationvalue); 
		selectpagination.options[selectnumber].selected = true;
		}}
	
	}
	

