// JavaScript Document
function getHTTPObject()
{
  if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");
  else if (window.XMLHttpRequest) return new XMLHttpRequest();
  else {
	  alert("Your browser does not support AJAX.");
	  return null;
  }
}

// this for sorting of new cars
function newSetOutput() {
	if(httpObject.readyState == 4) {
	document.getElementById("newModel").innerHTML = httpObject.responseText;
	}
}

function newCars(categoryid,pageAction,classification,output,elementName) {	  					
	  httpObject = getHTTPObject();
	  //alert("index.php?/setoutput/" + classification + "/" + pageAction + '/' + categoryid.value);
	  if (httpObject != null) {
		httpObject.open("POST", "index.php?/setoutput/" + classification + "/" + pageAction + '/' + categoryid.value + '/' + elementName , true);
		httpObject.send(null);
		httpObject.onreadystatechange = newSetOutput;
	  }		
}	

// this for sorting of used cars
function usedSetOutput() {
	if(httpObject.readyState == 4) {
	document.getElementById("usedModel").innerHTML = httpObject.responseText;
	}
}

function usedCars(categoryid,pageAction,classification,output,elementName) {	  					
	  //alert("index.php?/setoutput/" + classification + "/" + pageAction + '/' + categoryid.value);
	  httpObject = getHTTPObject();
	  //alert("index.php?/setoutput/" + classification + "/" + pageAction + '/' + categoryid.value);
	  if (httpObject != null) {
		httpObject.open("POST", "index.php?/setoutput/" + classification + "/" + pageAction + '/' + categoryid.value + '/' + elementName , true);
		httpObject.send(null);
		httpObject.onreadystatechange = usedSetOutput;
	  }		
}	
