var ajax = new sack();

function getManufacturer(sel)
{
	var manufacturer = sel.options[sel.selectedIndex].value;
		document.getElementById('model').options.length = 0;
		document.getElementById('year').options.length = 0;
		document.getElementById('model_variant').options.length = 0;
	
		
	if (manufacturer != ""){
		// Execute AJAX function
		var type = document.getElementById('cat_type').value;
		ajax.requestFile = 'getData.php?manufacturer='+manufacturer+'&type='+type;	// Specifying which file to get
		ajax.onCompletion = createModel;	// Specify function that will be executed after file has been found
		ajax.runAJAX();		// Execute AJAX function	
	}
	else{
		document.getElementById('model').options.length = 0;
		document.getElementById('year').options.length = 0;
		document.getElementById('model_variant').options.length = 0;
	
	}
}

function getRacingseries(sel)
{
	var manufacturer = sel.options[sel.selectedIndex].value;
		
		document.getElementById('model').options.length = 0;
	
		
	if (manufacturer != ""){
		// Execute AJAX function
		ajax.requestFile = 'getData.php?racingseries='+manufacturer;	// Specifying which file to get
		ajax.onCompletion = createModel;	// Specify function that will be executed after file has been found
		ajax.runAJAX();		// Execute AJAX function	
	}
	else{

		document.getElementById('model').options.length = 0;
	
	}
}


function getManufacturerOff(sel)
{
	var manufacturer = sel.options[sel.selectedIndex].value;
		document.getElementById('model').options.length = 0;

	
		
	if (manufacturer != ""){
		// Execute AJAX function
		var type = document.getElementById('cat_type').value;
		ajax.requestFile = 'getData.php?manufacturer='+manufacturer+'&type='+type;	// Specifying which file to get
		ajax.onCompletion = createModel;	// Specify function that will be executed after file has been found
		ajax.runAJAX();		// Execute AJAX function	
	}
	else{
		document.getElementById('model').options.length = 0;

	
	}
}

function createModel()
{
	var obj = document.getElementById('model');
	eval(ajax.response);	// Executing the response from Ajax as Javascript code	
}

function getModel(sel)
{
	var model = sel.options[sel.selectedIndex].value;
	var manufacturer = document.getElementById("manufacturer").options[document.getElementById("manufacturer").selectedIndex].value;		
		document.getElementById('year').options.length = 0;
		document.getElementById('model_variant').options.length = 0;
		
		
	if (model != ""){
		// Execute AJAX function
		var type = document.getElementById('cat_type').value;
		ajax.requestFile = 'getData.php?manufacturer2='+manufacturer+'&model='+model+'&type='+type;	// Specifying which file to get
		ajax.onCompletion = createYear;	// Specify function that will be executed after file has been found
		ajax.runAJAX();		// Execute AJAX function	
	}
	else{
		
		document.getElementById('year').options.length = 0;
		document.getElementById('model_variant').options.length = 0;
	
	}
}

function createYear()
{
	var obj = document.getElementById('year');
	eval(ajax.response);	// Executing the response from Ajax as Javascript code	
}

function getTheYear(sel)
{
	var year = sel.options[sel.selectedIndex].value;
	var model = document.getElementById("model").options[document.getElementById("model").selectedIndex].value;
	var manufacturer = document.getElementById("manufacturer").options[document.getElementById("manufacturer").selectedIndex].value;		

		document.getElementById('model_variant').options.length = 0;
		
		
	if (year != ""){
		// Execute AJAX function
		var type = document.getElementById('cat_type').value;
		ajax.requestFile = 'getData.php?year='+year+'&manufacturer2='+manufacturer+'&model2='+model+'&type='+type;	// Specifying which file to get
		ajax.onCompletion = createModelVariant;	// Specify function that will be executed after file has been found
		ajax.runAJAX();		// Execute AJAX function	
	}
	else{
		
		document.getElementById('model_variant').options.length = 0;
	
	}
}

function createModelVariant()
{
	var obj = document.getElementById('model_variant');
	eval(ajax.response);	// Executing the response from Ajax as Javascript code	
}
