// JavaScript Document

function gettype(caryear){
var theresponse
var url="../dealerfiles/ajax.asp";
url=url+"?getwhat=type";
url=url+"&caryear="+caryear;
new Ajax(url, {
		method: 'get',
		onComplete: function(theresponse){
				if (theresponse != ''){
					var x
					var theresponse_array = theresponse.split("|");
					document.search3.upholstry.options.length=theresponse_array.length+1;
					document.search3.upholstry.options[0].value="";
					document.search3.upholstry.options[0].text="-Select-";
					for (x in theresponse_array){
						var thevalue = theresponse_array[x];
						if (x < theresponse_array.length){
							document.search3.upholstry.options[parseInt(x)+1].value=thevalue;
							document.search3.upholstry.options[parseInt(x)+1].text=thevalue;
						}
					}
				}else{
					document.search3.upholstry.options.length=1;
					document.search3.upholstry.options[0].value="";
					document.search3.upholstry.options[0].text="-None Found-";
				}	
  }}).request();
}

function getmake(caryear,vehtype){
var theresponse
var url="../dealerfiles/ajax.asp";
url=url+"?getwhat=Make";
url=url+"&caryear="+caryear;
url=url+"&vehtype="+vehtype;
new Ajax(url, {
		method: 'get',
		onComplete: function(theresponse){
		if (theresponse != ''){
				var x
				var theresponse_array = theresponse.split("|");
				document.search3.make.options.length=theresponse_array.length+1;
				document.search3.make.options[0].value="";
				document.search3.make.options[0].text="-Select-";
				for (x in theresponse_array){
					var thevalue = theresponse_array[x];
					if (x < theresponse_array.length){
						document.search3.make.options[parseInt(x)+1].value=thevalue;
						document.search3.make.options[parseInt(x)+1].text=thevalue;
					}
				}	
        }else{
			document.search3.make.options.length=1;
			document.search3.make.options[0].value="";
			document.search3.make.options[0].text="-None Found-";
		}
     }}).request();
}

function gemodel(caryear,vehtype,make){
var theresponse
var url="../dealerfiles/ajax.asp";
url=url+"?getwhat=model";
url=url+"&caryear="+caryear;
url=url+"&vehtype="+vehtype;
url=url+"&make="+make;
new Ajax(url, {
		method: 'get',
		onComplete: function(theresponse){
		//alert(theresponse);
		if (theresponse != ''){
				if (theresponse.indexOf("|") > 0){
					var x
						var theresponse_array = theresponse.split("|");
						document.search3.model.options.length=theresponse_array.length+1;
						document.search3.model.options[0].value="";
						document.search3.model.options[0].text="-Select-";
						for (x in theresponse_array){
							var thevalue = theresponse_array[x];
							if (x < theresponse_array.length){
								document.search3.model.options[parseInt(x)+1].value=thevalue;
								document.search3.model.options[parseInt(x)+1].text=thevalue;
							}
						}
				}else{
					document.search3.model.options.length=2;
					document.search3.model.options[0].value="";
					document.search3.model.options[0].text="-Select-";
					document.search3.model.options[1].value=theresponse;
					document.search3.model.options[1].text=theresponse;
				}				
        }else{
			document.search3.model.options.length=1;
			document.search3.model.options[0].value="";
			document.search3.model.options[0].text="-None Found-";
		}
	 }}).request();
}
		
     
