﻿MakeArray = new Array(42)
ModelArray = new Array(42)

MakeArray[0] = 'Acura';
ModelArray[0] = new Array('CL', 'Integra', 'MDX', 'NSX', 'RL', 'RSX', 'SLX', 'TL', 'TSX');

MakeArray[1] = 'Audi';
ModelArray[1] = new Array('A3', 'A4', 'A4 Series', 'A6', 'A6 Series', 'A8', 'A8 Series', 'allroad', 'Allroad', 'Cabriolet', 'Q7', 'RS 4', 'RS6', 'S4', 'S6', 'S8', 'TT');

MakeArray[2] = 'BMW';
ModelArray[2] = new Array('3-Series', '5-Series', '6-Series', '7-Series', '8-Series', 'X3-Series', 'X5-Series', 'Z3-Series', 'Z4-Series', 'Z8-Series');

MakeArray[3] = 'Buick';
ModelArray[3] = new Array('Century', 'LaCrosse', 'LeSabre', 'Lucerne', 'Park Avenue', 'Rainier', 'Regal', 'Rendezvous', 'Riviera', 'Skylark', 'Terraza');

MakeArray[4] = 'Cadillac';
ModelArray[4] = new Array('Catera', 'Concours', 'CTS', 'CTS-V', 'd\'Elegance', 'Deville', 'DeVille', 'DeVille DHS', 'DeVille DTS', 'DTS', 'Eldorado', 'Escalade', 'Escalade ESV', 'Escalade EXT', 'Seville', 'SRX', 'STS', 'STS-V', 'XLR', 'XLR-V');

MakeArray[5] = 'Chevrolet';
ModelArray[5] = new Array('Astro Cargo', 'Astro Cargo Van', 'Astro Passenger', 'Avalanche', 'Aveo', 'Blazer', 'C 3500 HD', 'C/K 1500', 'C/K 1500 Work', 'C/K 2500', 'C/K 2500 Crew Cab', 'C/K 3500', 'C/K 3500 Crew Cab', 'Camaro', 'Cavalier', 'Chevy Van', 'Cobalt', 'Colorado', 'Corvette', 'Equinox', 'Express Cargo Van', 'Express Commercial Cutaway', 'Express Commrcl Cutaway', 'Express Passenger', 'Express RV Cutaway', 'Express Van', 'Forward Control Chassis', 'G Commercial Cutaway', 'G RV Cutaway', 'HHR', 'Impala', 'Lumina', 'Malibu', 'Malibu Maxx', 'Metro', 'Monte Carlo', 'Motor Home Chassis', 'New Tahoe', 'P Forward Control Chassis', 'P Motor Home Chassis', 'Prizm', 'S-10', 'Silverado 1500', 'Silverado 1500 Classic', 'Silverado 1500 Classic Hybrid', 'Silverado 1500 Crew Cab', 'Silverado 1500 Hybrid', 'Silverado 1500HD', 'Silverado 1500HD Classic', 'Silverado 2500', 'Silverado 2500 Crew Cab', 'Silverado 2500HD', 'Silverado 2500HD Classic', 'Silverado 3500', 'Silverado 3500 Classic', 'Silverado SS', 'Silverado SS Classic', 'SSR', 'Suburban', 'Tahoe', 'Tahoe Police', 'Tracker', 'TrailBlazer', 'Uplander', 'Uplander Cargo Van', 'Venture', 'Venture Cargo Van');

MakeArray[6] = 'Chrysler';
ModelArray[6] = new Array('300M', '300-Series', 'Cirrus', 'Concorde', 'Crossfire', 'LHS', 'Pacifica', 'Prowler', 'PT Cruiser', 'Sebring', 'Sebring Conv', 'Sebring Coupe', 'Sebring Sedan', 'Town & Country', 'Town & Country LWB', 'Town & Country SWB', 'Voyager');

MakeArray[7] = 'Daewoo';
ModelArray[7] = new Array('Lanos', 'Leganza', 'Nubira');

MakeArray[8] = 'Dodge';
ModelArray[8] = new Array('Avenger', 'Caliber', 'Caravan', 'Caravan C/V', 'Charger', 'Dakota', 'Durango', 'Grand Caravan', 'Grand Caravan C/V', 'Intrepid', 'Magnum', 'Neon', 'Ram 1500', 'Ram 2500', 'Ram 3500', 'Ram BR1500', 'Ram BR2500', 'Ram BR2500 Chassis Cab', 'Ram BR3500', 'Ram BR3500 Chassis Cab', 'Ram SRT-10', 'Ram Van', 'Ram Wagon', 'Sprinter', 'Sprinter Cab Chassis', 'Sprinter Wagon', 'Stratus', 'Stratus Coupe', 'Stratus Sedan', 'Viper');

MakeArray[9] = 'Eagle';
ModelArray[9] = new Array('Talon', 'Vision');

MakeArray[10] = 'Ford';
ModelArray[10] = new Array('Aerostar', 'Aspire', 'Club Wagon', 'Contour', 'Crown Victoria', 'Econoline', 'Econoline Cargo Van', 'Econoline Commercial Chassis', 'Econoline Commercial Cutaway', 'Econoline Commrcl Chassis', 'Econoline Commrcl Cutaway', 'Econoline Cutaway', 'Econoline RV Cutaway', 'Econoline Wagon', 'Escape', 'Escort', 'Excursion', 'Expedition', 'Expedition EL', 'Explorer', 'Explorer Sport', 'Explorer Sport Trac', 'F-150', 'F-150 Heritage', 'F-150 Series', 'F-150 Series Standard', 'F-150 SuperCrew', 'F-150 Work Series', 'F-250 HD Series', 'F-250 HD Series Crew Cab', 'F-250 Series', 'F-250 Series Standard', 'F-250 Work Series', 'F-350 Chassis Cab', 'F-350 Series', 'F-350 Series Crew Cab', 'F-800', 'Five Hundred', 'Focus', 'Freestar', 'Freestar Cargo Van', 'Freestar Wagon', 'Freestyle', 'F-Super Duty Chassis Cab', 'Fusion', 'GT', 'Mustang', 'Probe', 'Ranger', 'Super Duty E-350 DRW', 'Super Duty E-450 DRW', 'Super Duty E-550 Cutaway', 'Super Duty E-550 DRW', 'Super Duty F-250', 'Super Duty F-350 DRW', 'Super Duty F-350 SRW', 'Super Duty F-450', 'Super Duty F-450 DRW', 'Super Duty F-550', 'Super Duty F-550 DRW', 'Super Duty F-650', 'Super Duty F-750', 'Taurus', 'Thunderbird', 'Windstar', 'ZX2');

MakeArray[11] = 'Geo';
ModelArray[11] = new Array('Metro', 'Prizm', 'Tracker');

MakeArray[12] = 'GMC';
ModelArray[12] = new Array('Canyon', 'Classic Sierra 2500', 'Classic Sierra 3500', 'Classic Sierra 3500 HD', 'Classic Sierra Crew Cab', 'Denali', 'Envoy', 'Envoy XL', 'Envoy XUV', 'Forward Control Chassis', 'G Savana Camper Special', 'G Savana Special', 'Jimmy', 'New Sierra 1500', 'New Sierra 2500', 'P Forward Control Chassis', 'P School Bus Chassis', 'Safari Cargo', 'Safari Cargo Van', 'Safari Passenger', 'Savana Camper Special', 'Savana Cargo', 'Savana Cargo Van', 'Savana Cutaway', 'Savana Passenger', 'Savana RV Cutaway', 'Savana Special', 'School Bus Chassis', 'Sierra "Classic 1500"', 'Sierra 1500', 'Sierra 1500 Classic', 'Sierra 1500 Classic Hybrid', 'Sierra 1500 Crew Cab', 'Sierra 1500 Hybrid', 'Sierra 1500 Special', 'Sierra 1500HD', 'Sierra 1500HD Classic', 'Sierra 2500', 'Sierra 2500 Crew Cab', 'Sierra 2500HD', 'Sierra 2500HD Classic', 'Sierra 3500', 'Sierra 3500 Classic', 'Sierra 3500 Crew Cab', 'Sierra 3500 HD', 'Sierra Denali', 'Sierra Denali Classic', 'Sonoma', 'Suburban', 'Yukon', 'Yukon Denali', 'Yukon XL', 'Yukon XL Denali');

MakeArray[13] = 'Honda';
ModelArray[13] = new Array('Accord', 'Civic', 'Civic del Sol', 'Civic Hybrid', 'CR-V', 'Element', 'Fit', 'Insight', 'Odyssey', 'Passport', 'Pilot', 'Prelude', 'Ridgeline', 'S2000');

MakeArray[14] = 'Hummer';
ModelArray[14] = new Array('H1', 'H2', 'H2 SUT', 'H3');

MakeArray[15] = 'Hyundai';
ModelArray[15] = new Array('Accent', 'Azera', 'Elantra', 'Entourage', 'Santa Fe', 'Sonata', 'Tiburon', 'Tucson', 'XG300', 'XG350');

MakeArray[16] = 'Infiniti';
ModelArray[16] = new Array('FX35', 'FX45', 'G20', 'G35 Coupe', 'G35 Sedan', 'G35 Sport Coupe', 'I30', 'I35', 'J30', 'M35', 'M45', 'Q45', 'QX4', 'QX56');

MakeArray[17] = 'Isuzu';
ModelArray[17] = new Array('Amigo', 'Ascender', 'Axiom', 'Hombre', 'i-280', 'i-350', 'Oasis', 'Rodeo', 'Rodeo Sport', 'Trooper', 'VehiCROSS');

MakeArray[18] = 'Jaguar';
ModelArray[18] = new Array('S-TYPE', 'XJ', 'XJ Series', 'XJ Series Sedan', 'XK', 'XK Series', 'XK8', 'X-TYPE');

MakeArray[19] = 'Jeep';
ModelArray[19] = new Array('Cherokee', 'Commander', 'Grand Cherokee', 'Liberty', 'Wrangler');

MakeArray[20] = 'Kia';
ModelArray[20] = new Array('Amanti', 'Optima', 'Rio', 'Sedona', 'Sephia', 'Sorento', 'Spectra', 'Sportage');

MakeArray[21] = 'Land Rover';
ModelArray[21] = new Array('Defender 90', 'Discovery', 'Discovery Series II', 'Freelander', 'LR3', 'Range Rover', 'Range Rover Sport');

MakeArray[22] = 'Lexus';
ModelArray[22] = new Array('ES 300', 'ES 300 Luxury Sport Sdn', 'ES 330', 'ES 350', 'GS 300', 'GS 300 Luxury Perform Sdn', 'GS 400', 'GS 400 Luxury Perform Sdn', 'GS 430', 'GS 450h', 'GX 470', 'IS 250', 'IS 300', 'IS 350', 'LS 400', 'LS 400 Luxury Sdn', 'LS 430', 'LX 450 Luxury Wagon', 'LX 470', 'LX 470 Luxury SUV', 'LX 470 Luxury Wagon', 'RX 300', 'RX 300 Luxury SUV', 'RX 330', 'RX 350', 'RX 400h', 'SC 300', 'SC 300 Luxury Sport Cpe', 'SC 400', 'SC 400 Luxury Sport Cpe', 'SC 430');

MakeArray[23] = 'Lincoln';
ModelArray[23] = new Array('Aviator', 'Blackwood', 'Continental', 'LS', 'Mark LT', 'Mark VIII', 'MKZ', 'Navigator', 'Town Car', 'Zephyr');

MakeArray[24] = 'Mazda';
ModelArray[24] = new Array('2WD B-Series Pickup', '2WD Truck', '4WD B-Series Pickup', '4WD Truck', 'B-Series 2WD Truck', 'B-Series 4WD Truck', 'CX-7', 'MAZDA3', 'MAZDA5', 'MAZDA6', 'Millenia', 'MPV', 'MPV Wagon', 'MPV Wagons', 'MX5 Miata', 'MX-5 Miata', 'MX6', 'Protege', 'Protege5', 'RX-8', 'Tribute', 'Tribute SUV');

MakeArray[25] = 'Mercedes-Benz';
ModelArray[25] = new Array('C Class', 'CL Class', 'CLK Class', 'CLS Class', 'E Class', 'G Class', 'GL Class', 'M Class', 'R Class', 'S Class', 'SL Class', 'SLK Class', 'SLR McLaren');

MakeArray[26] = 'Mercury';
ModelArray[26] = new Array('Cougar', 'Grand Marquis', 'Marauder', 'Mariner', 'Milan', 'Montego', 'Monterey', 'Mountaineer', 'Mystique', 'Sable', 'Tracer', 'Villager', 'Villager Wgn');

MakeArray[27] = 'MINI';
ModelArray[27] = new Array('Cooper', 'Cooper Conv');

MakeArray[28] = 'Mitsubishi';
ModelArray[28] = new Array('3000GT', 'Diamante', 'Eclipse', 'Endeavor', 'Galant', 'Lancer', 'Mirage', 'Montero', 'Montero Sport', 'Outlander', 'Raider');

MakeArray[29] = 'Nissan';
ModelArray[29] = new Array('200SX', '240SX', '350Z', 'Altima', 'Armada', 'Frontier', 'Frontier 2WD', 'Frontier 4WD', 'Maxima', 'Murano', 'Pathfinder', 'Quest', 'Sentra', 'Titan', 'Trucks 2WD', 'Trucks 4WD', 'Xterra');

MakeArray[30] = 'Oldsmobile';
ModelArray[30] = new Array('Achieva', 'Alero', 'Aurora', 'Bravada', 'Cutlass', 'Cutlass Supreme', 'Eighty Eight', 'Intrigue', 'LSS', 'Regency', 'Silhouette');

MakeArray[31] = 'Plymouth';
ModelArray[31] = new Array('Breeze', 'Neon', 'Prowler', 'Voyager');

MakeArray[32] = 'Pontiac';
ModelArray[32] = new Array('Aztek', 'Bonneville', 'Firebird', 'G5', 'G6', 'Grand Am', 'Grand Prix', 'GTO', 'Montana', 'Montana SV6', 'Solstice', 'Sunfire', 'Torrent', 'Trans Sport', 'Vibe');

MakeArray[33] = 'Porsche';
ModelArray[33] = new Array('911 Carrera', '911 Carrera 4', 'Boxster', 'Carrera GT', 'Cayenne', 'Cayman');

MakeArray[34] = 'Saab';
ModelArray[34] = new Array('9-2X', '9-7X');

MakeArray[35] = 'Saturn';
ModelArray[35] = new Array('2dr Coupe', '3dr Coupe', '4dr Sedan', '4dr Wagon', '4dr Wagon RHD', 'Aura', 'Ion', 'LS 4dr Sedan', 'L-Series', 'LW 4dr Wagon', 'Relay', 'SC 3dr Coupe', 'Sky', 'SL 4dr Sedan', 'SW 4dr RHD Wagon', 'SW 4dr Wagon', 'VUE', 'VUE 4dr SUV');

MakeArray[36] = 'Scion';
ModelArray[36] = new Array('tC', 'xA', 'xB');

MakeArray[37] = 'Subaru';
ModelArray[37] = new Array('B9 Tribeca (Natl)', 'Baja', 'Baja (Natl)', 'Forester', 'Forester (Natl)', 'Forester (NY/NJ)', 'Impreza Coupe', 'Impreza Sedan', 'Impreza Sedan (Natl)', 'Impreza Sedan (NY/NJ)', 'Impreza Wagon', 'Impreza Wagon (Natl)', 'Impreza Wagon (NY/NJ)', 'Legacy Sedan', 'Legacy Sedan (Natl)', 'Legacy Sedan (NY/NJ)', 'Legacy Wagon', 'Legacy Wagon (Natl)', 'Legacy Wagon (NY/NJ)', 'SVX');

MakeArray[38] = 'Suzuki';
ModelArray[38] = new Array('Aerio', 'Esteem', 'Forenza', 'Grand Vitara', 'Reno', 'Sidekick', 'Swift', 'Verona', 'Vitara', 'Vitara V6', 'X-90', 'XL-7');

MakeArray[39] = 'Toyota';
ModelArray[39] = new Array('4Runner', 'Avalon', 'Camry', 'Camry Hybrid', 'Camry Solara', 'Celica', 'Corolla', 'Echo', 'FJ Cruiser', 'Highlander', 'Highlander Hybrid', 'Land Cruiser', 'Matrix', 'MR2 Spyder', 'Paseo', 'Previa', 'Prius', 'RAV4', 'Sequoia', 'Sienna', 'Supra', 'T100', 'Tacoma', 'Tercel', 'Tundra', 'Yaris');

MakeArray[40] = 'Volkswagen';
ModelArray[40] = new Array('Cabrio', 'EuroVan', 'Golf', 'GTI', 'Jetta', 'New Beetle', 'Passat', 'Phaeton', 'R32', 'Rabbit', 'Touareg');

MakeArray[41] = 'Volvo';
ModelArray[41] = new Array('850 Series', '960 Series', 'C70', 'C70 Series', 'C70 Series Coupe', 'S40', 'S60', 'S70', 'S70 Series Sedan', 'S80', 'S80 Series Sedan', 'S90 Series Sedan', 'V40', 'V50', 'V70', 'V70 Series Wagon', 'V90 Series Wagon', 'XC70', 'XC90');

function PopulateMakes(controlSetName)
{
    var controlSet = GetControlSet(controlSetName);
    if ( document.getElementById(controlSet.makeId) == null ) return;

    var makeDropDown = document.getElementById(controlSet.makeId);
    selectedMakeIndex = makeDropDown.selectedIndex;
    makeDropDown.length = 0;
    
    var optionDefault = new Option("Select Make", "any");
    makeDropDown.options[0] = optionDefault;
    
	for(var i = 0; MakeArray[i] != null; i++) 
	{
        var option = new Option(MakeArray[i], MakeArray[i]);
        makeDropDown.options[i+1] = option;
	}

    if ( controlSet.selectedMakeName != '')
    {
        // This happens for postback
        makeDropDown.value = controlSet.selectedMakeName
    }
    else
    {
        // This happens at back button
        makeDropDown.selectedIndex = selectedMakeIndex;
    }
    PopulateModels(controlSet.setName);
}

function PopulateModels(controlSetName)
{
    var controlSet = GetControlSet(controlSetName);
    if ( document.getElementById(controlSet.makeId) == null ) return;
    if ( document.getElementById(controlSet.modelId) == null ) return;

    var makeDropDown = document.getElementById(controlSet.makeId);
    var modelDropDown = document.getElementById(controlSet.modelId);
    selectedModelIndex = modelDropDown.selectedIndex;
    modelDropDown.length = 0;

    var optionDefault = new Option("All Models", "any");
    modelDropDown.options[0] = optionDefault;

    var selectedMakeIndex = makeDropDown.options.selectedIndex;

    modelDropDown.options.length = 1;
    if ( selectedMakeIndex == 0 ) return;

    var currentModelArray = ModelArray[selectedMakeIndex-1]
	for(var i = 0; currentModelArray[i] != null; i++) 
	{
        var option = new Option(currentModelArray[i], currentModelArray[i]);
        modelDropDown.options[i+1] = option;
	}
    
    if ( controlSet.selectedModelName != '')
    {
        // This happens for postback
        modelDropDown.value = controlSet.selectedModelName
    }
    else
    {
        // This happens at back button
        modelDropDown.selectedIndex = selectedModelIndex;
    }
}


// Private methods that should NOT be called from your web page...

function InitializeControlSets()
{
	for (i = 0; i < controlSets.length; i++)
	{
		PopulateMakes(controlSets[i].setName);
	}
}

function RegisterControlSet(setName, makeControlId, modelControlId, selectedMake, selectedModel)
{
	controlSet = GetControlSet(setName);
	if (controlSet == null)
	{
		// Create a new registry...
		controlSet = CreateNewControlSet(setName);
	}
	
	controlSet.makeId = makeControlId;
	controlSet.modelId = modelControlId;
	controlSet.selectedMakeName = selectedMake;
	controlSet.selectedModelName = selectedModel;
}

function GetControlSet(setName)
{
	for (i = 0; i < controlSets.length; i++)
	{
		if (controlSets[i] != null)
		{
			if (controlSets[i].setName == setName)
			{
				return (controlSets[i]);
			}
		}
	}
	
	return (null);
}

function CreateNewControlSet(setName)
{
	controlSet = new Object;
	controlSet.setName = setName;
	controlSets[controlSets.length] = controlSet;
	return (controlSet);
}


