
	function Form (formName, typeField, makeField, modelField)
	{
		this.formName = formName;
		this.typeField = typeField;
		this.makeField = makeField;
		this.modelField = modelField;
		this.types = window[formName + 'Types'];
		this.makes = window[formName + 'Makes'];
		this.models = window[formName + 'Models'];
		this.anyYear = window[formName + 'AnyYear'];
		this.anyType = window[formName + 'AnyType'];
		this.anyMake = window[formName + 'AnyMake'];
		this.anyModel = window[formName + 'AnyModel'];
	}
	
	function pseudoAssoc(id,name)
	{
		this.id = id;
		this.name = name;
	}
	
	function modelAttributes(id,name,type)
	{
		this.id = id;
		this.name = name;
		this.type = type;
	}
	
	Form.prototype.Years = function () { return this.anyYear; }
	
	Form.prototype.loadType = function ()
	{
		// Remove all makes from dropdown list
		var typeSelect = document.forms[this.formName].elements[this.typeField];
		typeSelect.options.length = 0;
		
		// Load all makes into dropdown list
		for (i=0; i<this.types.length; i++)
			typeSelect.options[i] = new Option(this.types[i].name,this.types[i].id);
	}
	
	Form.prototype.loadMake = function()
	{
		// Remove all makes from dropdown list
		var makeSelect = document.forms[this.formName].elements[this.makeField];
		for (i=makeSelect.options.length; i>=0; i--)
			makeSelect.options[i] = null;
		
		// Load all makes into dropdown list
		for (i=0; i<this.makes.length; i++)
			makeSelect.options[i] = new Option(this.makes[i].name,this.makes[i].id);
	}
	
	Form.prototype.loadModel = function()
	{
		var makeSelect = document.forms[this.formName].elements[this.makeField];
		var modelSelect = document.forms[this.formName].elements[this.modelField];
		var typeSelect = document.forms[this.formName].elements[this.typeField];
		
		// Remove all models from dropdown list
			modelSelect.options.length = 0;
		
		// Find selected Type and Make
		selectedType = typeSelect.value;
		selectedMake = makeSelect.selectedIndex;
		
		// Set the default option and option incrementor
		modelSelect.options[0] = new Option(this.anyModel.name,this.anyModel.id);
		modelCounter = 1;
		
		if (selectedMake == 0) // No make is selected
		{
			for (i=0; i<this.models.length; i++)
			{
				for (j=0; j<this.models[i].length; j++)
				{				
					// Add to model dropdown only if it's the right Type
					if (selectedType == this.anyType.id)
					{
						modelSelect.options[modelCounter] = new Option(this.models[i][j].name,this.models[i][j].id);
						modelCounter++;
					}
					else if (this.models[i][j].type.indexOf(selectedType) > -1)
					{
						modelSelect.options[modelCounter] = new Option(this.models[i][j].name,this.models[i][j].id);
						modelCounter++;
					}
				}
			}
		}
		else // Only add Models of the selected Make
			for (i=0; i<this.models[selectedMake].length; i++)
			{
				// Add to model dropdown only if it's the right Type
				if (selectedType == this.anyType.id)
				{
					modelSelect.options[modelCounter] = new Option(this.models[selectedMake][i].name,this.models[selectedMake][i].id);
					modelCounter++;
				}
				else if (this.models[selectedMake][i].type.indexOf(selectedType) > -1)
				{
					modelSelect.options[modelCounter] = new Option(this.models[selectedMake][i].name,this.models[selectedMake][i].id);
					modelCounter++;
				}
			}
	}
	
	Form.prototype.Get = function()
	{
		fields = document.forms[this.formName].elements;
		text = "";
		for (i=0; i<fields.length; i++)
		{
			if (fields[i].name != "")
			{
				if (text != "") text += "&";
				text += fields[i].name + '=' + fields[i].value;
			}
		}
		return text;
	}