// JavaScript Document

var xmlHttp

var params
 
var pcheck = true;

var error;

function fromto(pricerange) {
	
	switch (pricerange) {
		case "<5000":
 			document.getElementById("pricefrom").value = "0";
			document.getElementById("priceto").value = "5000";
 			break;
		case "5-10000":
  			document.getElementById("pricefrom").value = "5000";
			document.getElementById("priceto").value = "10000";
 			break;
		case "1-20000":
  			document.getElementById("pricefrom").value = "10000";
			document.getElementById("priceto").value = "20000";
  			break;
		case "2-30000":
  			document.getElementById("pricefrom").value = "20000";
			document.getElementById("priceto").value = "30000";
  			break;
		case "3-40000":
  			document.getElementById("pricefrom").value = "30000";
			document.getElementById("priceto").value = "40000";
  			break;
		case "4-50000":
  			document.getElementById("pricefrom").value = "40000";
			document.getElementById("priceto").value = "50000";
  			break;
		case ">50000":
  			document.getElementById("pricefrom").value = "50000";
			document.getElementById("priceto").value = "no max";
  			break;
		default:
  			document.getElementById("pricefrom").value = "";
			document.getElementById("priceto").value = "";
	}

	
	
}


function getHorseboxResults(start, numpages) {
	
		
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
  		{
  		alert ("Your browser does not support AJAX!");
  		return;
  		} 
		params = "size=" + document.getElementById("size").value + 
				"&search=" + document.getElementById("search").value + 
				"&nohorses=" + document.getElementById("nohorses").value +
				"&accommodation=" + document.getElementById("accommodation").value +
				"&county=" + document.getElementById("county").value +
				"&pricerange=" + document.getElementById("pricerange").value +
				"&pricefrom=" + document.getElementById("pricefrom").value +
				"&priceto=" + document.getElementById("priceto").value +
				"&seller=" + document.getElementById("seller").value +
				"&s=" + start +
				"&np=" + numpages;
		var url="horseboxresultshtml.php";
		xmlHttp.onreadystatechange=stateChanged;
		xmlHttp.open("POST",url,true);
		//Send the proper header information along with the request
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", params.length);
		xmlHttp.setRequestHeader("Connection", "close");
		xmlHttp.send(params);
		
		
} // End of function



function stateChanged() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("result_holder").innerHTML=xmlHttp.responseText;
hideLoader();
}
}

function showLoader(){
 document.getElementById('loader').style.display = 'block';
}
function hideLoader(){
 document.getElementById('loader').style.display = 'none';
}



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;
}

