// make-model pulldown for tire tool, updated Sept 27/07
// english full

/*********************************************************************
 * We can't do a straight assignment of the options array            *
 * (to our name list/array) and so we do things the hard way. <sigh> *
 *********************************************************************/
function writeNewList(selList, arraySelected, selectValue)
{
	selList.options[0].text = "-select-";
	selList.options[0].value = "";

	if (!selectValue) {
	    selList.options[0].selected = true;
	}

	var i = 0;
	selList.length = arraySelected.length+1;
	if (i < arraySelected.length)
	{
		for (i=0; i < arraySelected.length; i++)
		{
			selList.options[i+1].text  = arraySelected[i];
			selList.options[i+1].value = arraySelected[i];

			if (selectValue == arraySelected[i])
			{
			    selList.options[i+1].selected = true;
			}
		}
	}
} // end writeNewList()

function correctName(code)
{
	code = code.replace(/ /g, "_");  // replace spaces with underscores
	code = code.replace(/\./g, "_"); // replace periods with underscores
	code = code.replace(/-/g, "_"); // replace hyphens with underscores (Nov 2005)
	return code;
}

function changeSalesModel(selList, selObj)
{
	var code = selObj.options[selObj.selectedIndex].value;
	code = correctName(code);

	var arraySelected;

	if (code.length < 1)
	{
		arraySelected = "";
	}
	else
	{
		arraySelected = eval("arrSM_" + code);
	}

	writeNewList(selList, arraySelected, "");

	return true;
} // end changeSalesModel()


/*********************************************************************
 * The data for the pulldowns - to match data in tiretool db         *
 *********************************************************************/

// make array
var arrNameplate = new Array(
	"Buick",
	"Cadillac",
	"Chevrolet",
	"GMC",
	"Hummer",
	"Isuzu",
	"Oldsmobile",
	"Pontiac",
	"Saab",
	"Saturn"
);

// note - no separate Chevrolet trucks in tire data

// model arrays

var arrSM_Buick = new Array(
	"Allure",
	"Century",
	"Enclave",
	"Le Sabre",
	"Lucerne",
	"Park Avenue",
	"Rainier",
	"Regal",
	"Rendezvous",
	"Riviera",
	"Terraza"
);

var arrSM_Cadillac = new Array(
	"CTS",
	"CTS-V",
	"Catera",
	"Commercial",
	"Concours",
	"DTS",
	"Deville",
	"EXT",
	"Eldorado",
	"Escalade",
	"Escalade ESV",
	"Escalade EXT",
	"SRX",
	"STS",
	"Seville",
	"XLR"
);

var arrSM_Chevrolet = new Array(
	"Astro",
	"Avalanche",
	"Aveo",
	"Blazer",
	"Camaro",
	"Cavalier",
	"Chassis",
	"Classic",
	"Cobalt",
	"Colorado",
	"Corvette",
	"Corvette ZO6",
	"Epica",
	"Equinox",
	"Express",
	"HHR",
	"Impala",
	"Lumina",
	"Malibu",
	"Malibu Maxx",
	"Metro",
	"Monte Carlo",
	"Optra",
	"Prizm",
	"S-10 Pickup",
	"S10",
	"SSR",
	"Silverado",
	"Silverado HD",
	"Suburban",
	"Tahoe",
	"Tracker",
	"TrailBlazer",
	"TrailBlazer EXT",
	"TrailBlazer SS",
	"Traverse",
	"Uplander",
	"Venture"
);

var arrSM_GMC = new Array(
	"Acadia",
	"Canyon",
	"Centenial",
	"Chassis",
	"Denali",
	"Envoy",
	"Envoy XL",
	"Envoy XUV",
	"Jimmy",
	"Safari",
	"Savana",
	"Sierra",
	"Sierra HD",
	"Sonoma",
	"Yukon",
	"Yukon - XL",
	"Yukon XL"
);

var arrSM_Hummer = new Array(
	"H2",
	"H2 SUT",
	"H3",
	"H3T"
);

var arrSM_Isuzu = new Array(
	"Ascender"
);

var arrSM_Oldsmobile = new Array(
	"Alero",
	"Aurora",
	"Bravada",
	"Cutlass",
	"Eighty Eight",
	"Intrigue",
	"Regency",
	"Silhouette"
);

var arrSM_Pontiac = new Array(
	"Aztek",
	"Bonneville",
	"Firebird",
	"G3 Wave",
	"G5",
	"G5 Pursuit",
	"G6",
	"G8",
	"GTO",
	"GXP",
	"Grand Am",
	"Grand Prix",
	"Montana",
	"Montana SV6",
	"Pursuit",
	"Solstice",
	"Sunfire",
	"Torrent",
	"Vibe",
	"Wave"
);

var arrSM_Saab = new Array(
	"9-7X"
);

var arrSM_Saturn = new Array(
	"Astra",
	"Aura",
	"Electric Car",
	"ION",
	"Innovate",
	"Ion",
	"Ion Red Line",
	"LS",
	"OUTLOOK",
	"Relay",
	"SC",
	"SL",
	"Saturn",
	"Sky",
	"Vue",
	"Vue Hybrid"
);

