// JavaScript Document
var ajax = new sack();
var make_count = 0;
function loadMakeSelect(root)
{
	var oVehicleYear = document.getElementById('vehicle_year');
	var vehicle_year = oVehicleYear.options[oVehicleYear.selectedIndex].value;
	
	var oVehicleMake = document.getElementById('vehicle_make');
	
	oVehicleMake.options.length = 0;	// Empty vehicle_make select box
	if(vehicle_year.length > 0)
	{
		oVehicleMake.options[oVehicleMake.options.length] = new Option('Select','');

		var path = root + 'media/ajax/chain_select/vehicle_make.php?vehicle_year=' + vehicle_year;
		//alert(path);
		ajax.requestFile = path;					// Specifying which file to get
		ajax.onCompletion = loadMakeOptions;	// Specify function that will be executed after file has been found
		ajax.runAJAX();								// Execute AJAX function
	}
	else
	{
		
		//oVehicleMake.style.visibility='hidden';
		//document.getElementById('vehicle_make_label').style.visibility='hidden';
		
		oVehicleMake.options[oVehicleMake.options.length] = new Option('^','');
		if(make_count++ < 10)
		{
			//oError = document.getElementById('Error2');
			//oError.innerHTML = oError.innerHTML  + count + "<br />";
			setTimeout('loadMakeSelect(\'' + root + '\')',500);
		}
	}
}

function loadMakeOptions()
{
	var obj = document.getElementById('vehicle_make');	
	var response = ajax.response;
	//alert(response);
	eval(response);	// Executing the response from Ajax as Javascript code	
	
	//document.getElementById('vehicle_make_label').style.visibility='visible';
	//obj.style.visibility='visible';
}