/****************************************************************************************************
* Define Model Object used to populate model drop list                                              * 
****************************************************************************************************/
var modelList = new Array();
function ModelData(pModelID,pModel, pYear) {
	this.modelID = pModelID;
	this.model = pModel;
	this.year = pYear;
}

/****************************************************************************************************
* Array to hold the model list retrieved from the database.  Iterate through list on form to        *
* populate this list.                                                                               *
****************************************************************************************************/
function addModelYear(modelId, model, year){
	modelList[modelList.length] = new ModelData(modelId,model,year);
}

/****************************************************************************************************
* Function to set model drop list (html:select) based on what was selected in the year drop list.   *
* This code gets executed when the user changes the value in the year drop list.                    *
****************************************************************************************************/
function setModelDropList(form, currYear) {
	var j = 1;
	form.modelId.length = 0;
	form.modelId.options[0] = new Option("Select a Model");
	form.modelId.options[0].value = "0";

	for (var i=0; i < modelList.length; i++) {

		if (modelList[i].year == currYear.value) {
			form.modelId.options[j] = new Option(modelList[i].model);
			form.modelId.options[j].value = modelList[i].modelID;
			j++;
		}
	}
}

