var ajax = new Array();

function getModels(sel) {
	var make_id = sel.options[sel.selectedIndex].value;
	document.getElementById('model_id').options.length = 0;	//Empty city select box
	if(make_id.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = 'getModels.php?make_id='+make_id;	//Specifying which file to get
		ajax[index].onCompletion = function(){ createModels(index) };	//Specify function that will be executed
		ajax[index].runAJAX();		//Execute AJAX function
	}
}

function createModels(index) {
	var obj = document.getElementById('model_id');
	eval(ajax[index].response);	//Executing the response from Ajax as Javascript code	
}

function getYears(sel) {
	var model_id = sel.options[sel.selectedIndex].value;
	document.getElementById('years').options.length = 0;	//Empty city select box
	if(model_id.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = 'getModels.php?model_id='+model_id;	//Specifying which file to get
		ajax[index].onCompletion = function(){ createYears(index) };	//Specify function that will be executed
		ajax[index].runAJAX();		// Execute AJAX function
	}
}

function createYears(index) {
	var obj = document.getElementById('years');
	eval(ajax[index].response);	//Executing the response from Ajax as Javascript code	
}
