// JavaScript Document

var xmlHttp

var params
 
var pcheck = true;

var error;

function fromto(pricerange) {
	
	switch (pricerange) {
		case "<1000":
 			document.getElementById("pricefrom").value = "0";
			document.getElementById("priceto").value = "1000";
 			break;
		case "1-2000":
  			document.getElementById("pricefrom").value = "1000";
			document.getElementById("priceto").value = "2000";
 			break;
		case "2-3000":
  			document.getElementById("pricefrom").value = "2000";
			document.getElementById("priceto").value = "3000";
  			break;
		case "3-5000":
  			document.getElementById("pricefrom").value = "3000";
			document.getElementById("priceto").value = "5000";
  			break;
		case "5-7000":
  			document.getElementById("pricefrom").value = "5000";
			document.getElementById("priceto").value = "7000";
  			break;
		case ">7000":
  			document.getElementById("pricefrom").value = "7000";
			document.getElementById("priceto").value = "no max";
  			break;
		default:
  			document.getElementById("pricefrom").value = "";
			document.getElementById("priceto").value = "";
	}

	
	
}


function getTrailerResults(start, numpages) {
	
		
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
  		{
  		alert ("Your browser does not support AJAX!");
  		return;
  		} 
		params = "search=" + document.getElementById("search").value + 
				"&trailertype=" + document.getElementById("trailertype").value +
				"&suitablefor=" + document.getElementById("suitablefor").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="trailerresultshtml.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;
}
