function updateMakes(input, response)
{
	var _make = document.getElementById('make');
	var _model = document.getElementById('model');
	var _engine = document.getElementById('engine');

	if (input == '')
	{
		if (response == null) return;
		
		var i = 0;
		
		/* clear out the current items from select box (_make) */
		for (i = (_make.options.length-1); i>=0; i--)
			_make.options[i] = null;
		_make.options.selectedIndex = -1;

		for (i = (_model.options.length-1); i>=0; i--)
			_model.options[i] = null;
		_model.options.selectedIndex = -1;
		
		/* clear out the current items from select box (_engine) */
		for (i = (_engine.options.length-1); i>=0; i--)
			_engine.options[i] = null;
		_engine.options.selectedIndex = -1;

		/* parse the XML data and populate the select box (_make) */
		var idx = 0;
		_make.options[idx++] = new Option('MAKE','-1');
		_model.options[0] = new Option('','-1');
		_engine.options[0] = new Option('','-1');
		for (i=0; i<response.length; i++)
		{
			/* Netscape considers the empty text node between two tags as the first child of the parent.
			   Since these nodes are only a nuisance, we have to check if the nodeType of the childNode
			   is 1 (= it's a tag). If it isn't, continue with the next child:
			   from: http://www.quirksmode.org/dom/importxml.html */
			if (response.item(i).nodeType != 1) continue;
			var name = response.item(i).firstChild.data;
			_make.options[idx++] = new Option(name,name);
		}
		document.getElementById('year').disabled = false;
		document.getElementById('make').disabled = false;
		document.getElementById('model').disabled = false;
		document.getElementById('engine').disabled = false;
	} else {
		var url = 'prodsearch_getvehicles.php?t=mk&q=' + input;
		document.getElementById('year').disabled = true;
		document.getElementById('make').disabled = true;
		document.getElementById('model').disabled = true;
		document.getElementById('engine').disabled = true;
		loadXMLDoc(url);
	}
}

function updateModels(input, response)
{
	var _year = document.getElementById('year');
	var _make = document.getElementById('make');
	var _model = document.getElementById('model');
	var _engine = document.getElementById('engine');

	if (input == '')
	{
		if (response == null) return;
		
		var i = 0;
		
		for (i = (_model.options.length-1); i>=0; i--)
			_model.options[i] = null;
		_model.options.selectedIndex = -1;
		
		/* clear out the current items from select box (_engine) */
		for (i = (_engine.options.length-1); i>=0; i--)
			_engine.options[i] = null;
		_engine.options.selectedIndex = -1;

		/* parse the XML data and populate the select box (_make) */
		var idx = 0;
		_model.options[idx++] = new Option('MODEL','-1');
		_engine.options[0] = new Option('','-1');
		for (i=0; i<response.length; i++)
		{
			/* Netscape considers the empty text node between two tags as the first child of the parent.
			   Since these nodes are only a nuisance, we have to check if the nodeType of the childNode
			   is 1 (= it's a tag). If it isn't, continue with the next child:
			   from: http://www.quirksmode.org/dom/importxml.html */
			if (response.item(i).nodeType != 1) continue;
			var name = response.item(i).firstChild.data;
			var val = response.item(i).getAttribute("val");
			_model.options[idx++] = new Option(name, val);
		}
		document.getElementById('year').disabled = false;
		document.getElementById('make').disabled = false;
		document.getElementById('model').disabled = false;
		document.getElementById('engine').disabled = false;
	} else {
		var url = 'prodsearch_getvehicles.php?t=md&yr=' + _year.options[_year.options.selectedIndex].value + '&q=' + input;
		document.getElementById('year').disabled = true;
		document.getElementById('make').disabled = true;
		document.getElementById('model').disabled = true;
		document.getElementById('engine').disabled = true;
		loadXMLDoc(url);
	}
}

function updateEngines(input, response)
{
	var _year = document.getElementById('year');
	var _make = document.getElementById('make');
	var _model = document.getElementById('model');
	var _engine = document.getElementById('engine');

	if (input == '')
	{
		if (response == null) return;
		
		var i = 0;
		
		/* clear out the current items from select box (_engine) */
		for (i = (_engine.options.length-1); i>=0; i--)
			_engine.options[i] = null;
		_engine.options.selectedIndex = -1;

		/* parse the XML data and populate the select box (_make) */
		var idx = 0;
		_engine.options[idx++] = new Option('ENGINE','-1');
		for (i=0; i<response.length; i++)
		{
			/* Netscape considers the empty text node between two tags as the first child of the parent.
			   Since these nodes are only a nuisance, we have to check if the nodeType of the childNode
			   is 1 (= it's a tag). If it isn't, continue with the next child:
			   from: http://www.quirksmode.org/dom/importxml.html */
			if (response.item(i).nodeType != 1) continue;
			var name = response.item(i).firstChild.data;
			var vid = response.item(i).getAttribute("val");
			_engine.options[idx++] = new Option(name,vid);
		}
		document.getElementById('year').disabled = false;
		document.getElementById('make').disabled = false;
		document.getElementById('model').disabled = false;
		document.getElementById('engine').disabled = false;
	} else {
		var url = 'prodsearch_getvehicles.php?t=eg&yr=' + _year.options[_year.options.selectedIndex].value + '&mk=' + _make.options[_make.options.selectedIndex].value + '&q=' + input;
		document.getElementById('year').disabled = true;
		document.getElementById('make').disabled = true;
		document.getElementById('model').disabled = true;
		document.getElementById('engine').disabled = true;
		loadXMLDoc(url);
	}
}