
function WriteManufacturerDropDown(manFieldName, modFieldName, selectedModID, selectedManID) {
	document.write('<select name=\"' + manFieldName + '\" id=\"' + manFieldName + '\" style=\"width: 160px;\"');
	document.write('	OnChange=\"JavaScript:PopulateModelDropDown(this.form, this.options[this.selectedIndex].value,' + modFieldName + ',0);\"');
	document.write('	OnFocus=\"JavaScript:');	
	if (selectedManID>0) {
		//There has been a selected manufacturer specified, so call the function appropriately
		document.write('PopulateModelDropDown(this.form, ' + selectedManID + ', ' + modFieldName + ', ' + selectedModID + ');');
	}
	else
	{
		//Nothing has been defined as 'SELECTED', so just display as normal
		document.write('PopulateModelDropDown(this.form, 0, ' + modFieldName + ', 0);this.selectedIndex = 0;');
	}
	document.write('\">');
	document.write('	<option value=\"0\">MANUFACTURER</option>');
	for (i = 0; i < arManu.length; i++) {
		document.write('	<option value=\"' + arManu[i][0] + '\"');
		//Write the SELECT depending on the id
		if (selectedManID != 0) {
			//check to see if this particular itteration's value is correct
			if (arManu[i][0] == selectedManID) {
				document.write(' SELECTED');
			}
		}
		document.write('>' + arManu[i][1] + '</option>');
	}
	document.write('</select>');
}

function WriteModelDropDown(modFieldName) {
	document.write('<select name=\"' + modFieldName + '\" id=\"' + modFieldName + '\" style=\"width: 160px;\">');
	document.write('	<option value=\"0\">MODEL</option>');
	document.write('	<option value=\"0\">ANY</option>');
	document.write('</select>');
}

function PopulateModelDropDown(objForm, ManufacturerID, modFieldName, selectedModID) {
	if (ManufacturerID != 0) {
		/*
			Access the array directly
			We need to remove the last options in the Model drop down
			then add the new ones from this array.
		*/
		eval("objForm." + modFieldName.name + ".options.length=2;")	//removed all but the top 2 elements
		//loop through the array and add options as needed
		for (i=0;i<arModels[ManufacturerID].length;i++) {
			//Get the option's value and text in variables
			strToSplit = arModels[ManufacturerID][i];
			intPosOfComma = strToSplit.indexOf(",");
			
			intValue = strToSplit.substring(0, intPosOfComma);
			strText = strToSplit.substring(intPosOfComma+1, strToSplit.length);
			
			var oOption = document.createElement("OPTION");			//Create the option element variable to call
			eval("objForm." + modFieldName.name + ".options.add(oOption);")						//Add the OPTION element to the MODEL drop down
			oOption.value = intValue;								//Add the value
			oOption.innerText = strText;							//Add the test value
			if (selectedModID == intValue) {
				oOption.selected = true;
			}
		}
	}
	else
	{
		//Set the options' back down to 2 as nothing has been selected
		eval("objForm." + modFieldName.name + ".options.length=2;")
		eval("objForm." + modFieldName.name + ".selectedIndex = 0;")
	}
}