function SetDropDowns(id) 
{
	if (id == 1)
	{
		var zeroindex = document.quoteform.model.selectedIndex;
		if (zeroindex == -1)
		{
			var car = new Array();
			var obj = new ActiveXObject("Microsoft.XMLHTTP");
			var url = location.protocol + "//" + location.host + "/includes/GetSessionVars.asp?id=" + id;
			//alert(url);
			obj.open("POST",url, false);
			obj.send();
			var response = obj.responseText;
			//alert(response);
			car = response.split(','); // car[0]-make, car[1]-model, car[2]-trim
			setModelList(car[0], "");
			if (car[2] != "")
				setTrim(car[0], car[1], "", car[2]);
			
			for (var i = 1; i < document.quoteform.model.length; i++)
			{
			   if (document.quoteform.model.options[i].text == car[1])
			   {
			      document.quoteform.model.options[i].selected = true;
			      break;
			   }
			}
		}
	}
	else if (id == 2)
	{
		var zeroindex1 = document.quoteform.model1.selectedIndex;
		var zeroindex2 = document.quoteform.model2.selectedIndex;
		if (zeroindex1 == -1 || zeroindex2 == -1)
		{	
			var car = new Array();
			var obj = new ActiveXObject("Microsoft.XMLHTTP");
			var url = location.protocol + "//" + location.host + "/includes/GetSessionVars.asp?id=" + id;
			//alert(url);
			obj.open("POST",url, false);
			obj.send();
			var response = obj.responseText;
			//alert(response);
			car = response.split(','); 
			
			// car[0]-make1, car[1]-model1, car[2]-trim1, car[3]-make2, car[4]-model2, car[5]-trim2

			setModelList(car[0], "1");
			setModelList(car[3], "2");
			if (car[2] != "")
				setTrim(car[0], car[1], "1", car[2]);
			if (car[5] != "")
				setTrim(car[3], car[4], "2", car[5]);
			
			for (var i = 1; i < document.quoteform.model1.length; i++)
			{
			   if (document.quoteform.model1.options[i].text == car[1])
			   {
			      document.quoteform.model1.options[i].selected = true;
			      break;
			   }
			}
			for (var j = 1; j < document.quoteform.model2.length; j++)
			{
			   if (document.quoteform.model2.options[j].text == car[4])
			   {
			      document.quoteform.model2.options[j].selected = true;
			      break;
			   }
			}
		}
	}
}

function setTrim (item, model, id, trim)
{
	var oXMLHTTP = xmlHttpRequest_init();
	if (oXMLHTTP) 
	{
		// Prepare the XMLHTTP object for a HTTP POST to our validation ASP page
		// Due to security reason, the domain of the URL request destination must be 
		// the same as the one that serves up the page containing the script.
		var sURL = location.protocol + "//" + location.host + "/includes/createList.asp?make=" + escape(item) + "&model=" + escape(model) + "&id=" + id;
		oXMLHTTP.open("GET", sURL, true);
		
		// With IE browser, data are being cached in the client's system. 
		// Changing the header would allow the application to reset.
		oXMLHTTP.setRequestHeader('If-Modified-Since','Mon, 20 Nov 1995 00:00:01 GMT');

		// Execute the request
		oXMLHTTP.send(null);

		// Determine the state change status
		oXMLHTTP.onreadystatechange=function()
		{
		    if (oXMLHTTP.readyState==4 && oXMLHTTP.status == 200) 
		    {
				document.getElementById("trimdiv"+id).innerHTML = oXMLHTTP.responseText;
				document.getElementById("slt"+id).style.width = "100px";
				if (id == 1)
				{
					for (var j = 1; j < document.quoteform.slt1.length; j++)
					{
					   if (document.quoteform.slt1.options[j].value == trim)
					   {
					      document.quoteform.slt1.options[j].selected = true;
					      break;
					   }
					}
				}
				else if (id == 2)
				{
					for (var j = 1; j < document.quoteform.slt2.length; j++)
					{
					   if (document.quoteform.slt2.options[j].value == trim)
					   {
					      document.quoteform.slt2.options[j].selected = true;
					      break;
					   }
					}				
				}
				else
				{
					for (var j = 1; j < document.quoteform.slt.length; j++)
					{
					   if (document.quoteform.slt.options[j].value == trim)
					   {
					      document.quoteform.slt.options[j].selected = true;
					      break;
					   }
					}				
				}
		    }
		}
    }
    else 
    {
		// For users with browsers that don't support XMLHttpRequest Object
		var formObj = document.quoteform;

		eval('formObj.modellist'+id+'.value=modelArray[item]');
		formObj.action=formObj.referer.value;
		formObj.submit();
	}
}