	var rawMakes="13%AMC%0%1~15%Acura%0%1~32%Alfa Romeo%0%1~AL%Alternative%0%1~84%Aston Martin%0%1~22%Audi%0%1~75%Austin Rover%0%1~23%BMW%0%1~03%Buick%1%1~04%Cadillac%1%1~01%Chevrolet%1%1~10%Chrysler%0%1~83%Daewoo%0%1~39%Daihatsu%0%1~11%Dodge%0%1~97%Don't Know/Other%0%1~09%Eagle%0%1~33%Ferrari%0%1~70%Fiat%0%1~06%Ford%0%1~86%Freightliner%0%1~47%GMC%1%1~80%Geo%0%1~77%HUMMER%1%1~14%Honda%0%1~21%Hyundai%0%1~38%IHC%0%1~81%Infiniti%0%1~31%Isuzu%0%1~24%Jaguar%0%1~62%Jeep%0%1~40%Kia%0%1~78%Lada%0%1~72%Lamborghini%0%1~76%Land Rover%0%1~82%Lexus%0%1~07%Lincoln%0%1~74%Lotus%0%1~73%Maserati%0%1~85%Maybach%0%1~16%Mazda%0%1~25%Mercedes Benz%0%1~08%Mercury%0%1~79%Merkur%0%1~60%Mini%0%1~17%Mitsubishi%0%1~MO%Mobility%0%1~18%Nissan%0%1~05%Oldsmobile%0%1~71%Opel%0%1~36%Peugeot%0%1~12%Plymouth%0%1~02%Pontiac%1%1~26%Porsche%0%1~35%Renault%0%1~34%Rolls Royce%0%1~27%Saab%1%1~65%Saturn%1%1~87%Scion%0%1~19%Subaru%0%1~54%Suzuki%0%1~20%Toyota%0%1~97%Unspecified Car%0%1~28%Volkswagen%0%1~29%Volvo%0%1~30%Yugo%0%1";
	var rawYears="03%0172%2000~03%0173%2000~03%0180%2000~03%_RAN%~03%0178%2000~03%0187%~04%0198%~04%0194%2000~04%0800%2000~04%_ESV%~04%0810%~04%0199%2000~04%_SRX%~04%01%2000%_ESV";
	var rawModels="001%Alliance%1~841%CJ%1~820%Cherokee%1~800%Comanche%1~416%Concord%1~412%Eagle%1~002%Encore%1~822%GR Wagoneer%1~003%Gremlin%1~004%Hornet%1~810%J Pickup%1~414%Javelin%1~415%Matador%1~000%Model Unknown%1~005%Pacer%1~413%Spirit%1~821%Wagoneer%1~840%Wrangler%1*637%CL%1~900%EL%1~631%Integra%1~632%Legend%1~630%MAV%1~700%MDX%1~000%Model Unknown%1~633%NSX%1~800%RDX%1~638%RL%1~639%RSX%1~636%SLX%1~635%TL%1~001%TSX%1~634%Vigor%1*002%164%1~001%Milano%1~000%Model Unknown%1~003%Spider%1*TFL%Fuel%0*900%DB7%1~903%Lagona%1~000%Model Unknown%1~904%V8%1~901%Vantage%1~902%Virage%1*007%100%1~008%200%1~004%4000%1~005%5000%1~001%80%1~002%90%1~908%A2%1~905%A3%1~012%A4%1~019%A5%1~011%A6%1~701%A8%1~909%ALLROAD%1~010%Cabriolet%1~003%GT%1~000%Model Unknown%1~017%Q5%1~018%Q7%1~020%R8%1~910%RS 4%1~009%S4%1~903%S6%1~907%S8%1~013%TT%1~014%TTS%1~006%V8%1*000%Model Unknown%1~001%Sterling%1*922%1 Series%1~3SE%3 Series%1~913%300 Series%1~001%318%1~915%323%1~002%325%1~021%328%1~918%330%1~934%335%1~5SE%5 Series%1~916%523%1~010%524%1~003%525%1~011%528%1~019%530%1~004%535%1~018%540%1~930%545%1~932%550%1~920%6 Series%1~012%635%1~931%645%1~933%650%1~917%725%1~907%733%1~006%735%1~016%740%1~026%745%1~007%750%1~028%760%1~014%840%1~008%850%1~017%L6%1~020%L7%1~023%M%1~009%M3%1~005%M5%1~013%M6%1~025%Mini%1~000%Model Unknown%1~029%X3%1~022%X5%1~015%Z3%1~027%Z4%1~024%Z8%1*999%Buick Full-line%1%1~172%Century%0~174%Electra%0~ENC%Enclave%1%1~179%Estate Wagon%0~LAC%LaCrosse%1%1~173%LeSabre%0~LUC%Lucerne%1%1~000%Model Unknown%0~180%Park Avenue%0~RAN%Rainier%0~177%Reatta%0~178%Regal%0~187%Rendezvous%0~176%Riviera%0~186%Roadmaster%0~171%Skyhawk%0~188%Skylark%0~175%Somerset%0~TER%Terraza%0*192%Allante%0~195%Brougham%0~198%CTS%1%1~CTV%CTS-V%0~999%Cadillac Full-line%1%1~193%Catera%0~191%Cimarron%0~DTS%DTS%1%1~194%DeVille%0~196%Eldorado%0~7ES%Escalade%1%1~800%Escalade%0~ESV%Escalade ESV%1%1~810%Escalade EXT%1%1~197%Fleetwood%0~SRX%SRX Crossover%1%1~STS%STS%1%1~STV%STS-V%1%1~199%Seville%0~200%Sixty Special%0~000%Unknown%0~VSE%V-Series%0~190%XLR Roadster%1%1~XLV%XLR-V%1%1*863%2006 Avalanche%0~AVE%2006 Aveo%0~871%2006 Suburban%0~815%2006 Tahoe%0~TRA%All New 2009 Traverse%1%1~850%Astro%0~7AV%Avalanche%1%1~7AE%Aveo%1%1~117%Beretta%0~820%Blazer%0~810%C/K Pickup%0~122%Camaro%0~113%Caprice%0~111%Cavalier%0~112%Celebrity%0~121%Chevette%0~999%Chevrolet Full-line%1%1~860%Chevy Express%1%1~128%Citation%0~COB%Cobalt%1%1~COL%Colorado%1%1~CAM%Concept Camaro%1%1~115%Corsica%0~129%Corvette%1%1~890%El Camino%0~EQU%Equinox%1%1~862%Express%0~HHR%HHR%1%1~119%Impala%1%1~KOD%Kodiak%1%1~C01%Light Duty Commercial Pickup/Utility%0~C02%Light Duty Commercial Van%0~118%Lumina%0~880%Lumina APV%0~801%Luv%0~116%Malibu%0~8MA%Malibu%1%1~MAH%Malibu Hybrid%1%1~C03%Medium Duty T Series%1%1~C04%Medium Duty W Series%1%1~503%Metro%0~000%Model Unknown%0~124%Monte Carlo%0~123%Monza%0~126%Nova%0~501%Prizm%0~800%S-10 Pickup%0~802%SSR%0~7SI%Silverado%1%1~816%Silverado Classic%0~SE5%Silverado E85%0~7SH%Silverado HD%1%1~817%Silverado HD Classic%0~502%Spectrum%0~861%SportVan%0~500%Storm%0~7SU%Suburban%1%1~7TA%Tahoe%1%1~8TH%Tahoe Hybrid%1%1~841%Tracker%0~821%TrailBlazer%1%1~UPL%Uplander%1%1~114%Vega%0~885%Venture%0*008%300%1~003%300M%1~861%Aspen%1~002%Cirrus%1~365%Concorde%1~568%Conquest%1~351%Cordoba%1~005%Crossfire%1~352%E-Class%1~353%Fifth Avenue%1~862%Fire Power%1~964%Gr Voyager LE%1~360%Imperial%1~001%LHS%1~355%Laser%1~356%LeBaron%1~000%Model Unknown%1~900%Neon%1~359%New Yorker%1~358%Newport%1~860%PT Cruiser%1~006%Pacifica%1~004%Prowler%1~573%Sapporo%1~100%Sebring%1~574%TC%1~850%Town & Country%1~962%Voyager%1*964%Korando%1~917%Lanos%1~920%Leganza%1~000%Model Unknown%1~950%Musso%1~918%Nubira%1~963%Rezzo%1*643%Applause%1~641%Charade%1~642%Charmont%1~000%Model Unknown%1~840%Rocky%1*331%400%1~332%600%1~333%Aries%1~301%Aspen%1~100%Avenger%1~810%Brdw Pickup%1~400%Caliber%1~850%Caravan%1~571%Challenger%1~334%Charger%1~561%Colt%1~564%Colt Vista%1~567%Conquest%1~801%Dakota%1~335%Daytona%1~336%Diplomat%1~870%Durango%1~342%Dynasty%1~348%Intrepid%1~337%Lancer%1~349%Magnum%1~862%Mini Ram Van%1~338%Mirada%1~000%Model Unknown%1~345%Monaco%1~001%Neon%1~003%Nitro%1~339%Omni%1~820%Raider%1~800%Ram 50%1~830%Ram Charger%1~860%Ram Van%1~861%Ram Wagon%1~802%Rampage%1~341%Shadow%1~343%Spirit%1~002%Sprinter%1~SPR%Sprinter Van%1~340%St. Regis%1~346%Stealth%1~200%Stratus%1~347%Viper%1*002%Don't Know/Other%1*321%Medallion%1~000%Model Unknown%1~322%Premier%1~324%Summit%1~325%Talon%1~326%Vision%1*000%All%1*000%Model Unknown%1~940%Siena%1~002%Spider%1~001%X19%1*850%Aerostar%1~001%Aspire%1~830%Bronco%1~840%Bronco II%1~870%Club Wagon%1~221%Contour%1~801%Courier%1~211%Crown Victoria%1~213%EXP%1~860%Econoline%1~606%Edge%1~821%Escape%1~212%Escort%1~826%Excursion%1~825%Expedition%1~500%Expedition EL%1~829%Expedition Max%1~822%Expl Sprt Trac%1~820%Explorer%1~810%F Series Pick-Up%1~203%Fairmont%1~603%Festiva%1~601%Fiesta%1~228%Five Hundred%1~225%Focus%1~226%Freestar%1~FRE%Freestar%1~227%Freestyle%1~827%Fusion%1~202%Futura%1~828%GT%1~219%Granada%1~214%LTD%1~223%Maverick%1~000%Model Unknown%1~215%Mustang%1~201%Pinto%1~220%Probe%1~890%Ranchero%1~800%Ranger%1~218%Taurus%1~229%Taurus X%1~216%Tempo%1~217%Thunderbird%1~907%Verona%1~880%Windstar%1*000%Freightliner%1~001%Spinter%1*831%2006 Yukon%0~ACA%Acadia%1%1~810%C/K Pick-Up%0~890%Caballero%0~CAN%Canyon%1%1~880%Envoy%1%1~EDE%Envoy Denali%0~XUV%Envoy XUV%0~999%GMC Full-line%1%1~820%Jimmy%0~830%K-Jimmy%0~C01%Light Duty Commercial Pickup/Utility%1%1~C02%Light Duty Commercial Van%1%1~C03%Medium Duty T Series%1%1~C04%Medium Duty W Series%1%1~000%Model Unknown%0~861%Rally Wagon%0~800%S-10 Pickup%0~850%Safari%0~862%Savana%1%1~811%Sierra%1%1~223%Sierra Denali%0~SE5%Sierra E85%0~222%Sierra Heavy Duty%0~801%Sonoma%0~870%Suburban%0~TOP%Topkick%1%1~860%Vandura%0~7YU%Yukon%1%1~835%Yukon Denali%1%1~840%Yukon XL%1%1~7YD%Yukon XL Denali%1%1*504%Metro%0~000%Model Unknown%0~506%Prizm%0~505%Spectrum%0~509%Storm%0~840%Tracker%0*001%H1%0~2LE%H2 Limited Edition%1%1~SUT%H2 SUT%1%1~002%H2 SUV%1%1~HH3%H3%1%1~H3A%H3 Alpha%1%1~H3X%H3x%1%1~999%HUMMER Full-line%1%1~000%Model Unknown%0*521%Accord%1~527%CRV%1~523%CRX%1~525%City%1~522%Civic%1~526%Del Sol%1~005%E.V.%1~006%Element%1~532%FCX%1~921%Fit%1~529%HRV%1~540%Insight%1~007%Latitude%1~000%Model Unknown%1~100%Odyssey%1~001%Passport%1~200%Pilot%1~524%Prelude%1~541%Ridgeline%1~530%S2000%1~528%SSX%1*655%Accent%1~005%Azera%1~654%Elantra%1~006%Entourage%1~004%Equus%1~651%Excel%1~656%HCD2 Epoch%1~002%MPV%1~000%Model Unknown%1~001%SUV%1~657%Santa Fe%1~653%Scoupe%1~652%Sonata%1~911%Tiburon%1~658%Tucson%1~007%Veracruz%1~300%XG%1~100%XG300%1~200%XG350%1*000%Model Unknown%1~810%Pick-Up%1~830%Scout%1~870%Traveler%1*004%FX45%1~493%G20%1~499%G35%1~510%G37%1~001%GT R%1~496%I30%1~500%I35%1~495%J30%1~492%M30%1~005%M35%1~002%M45%1~000%Model Unknown%1~494%President%1~491%Q45%1~498%QX4%1~003%QX56%1~497%T30%1*840%Amigo%1~001%Ascender%1~810%Axiom%1~841%Hombre%1~002%I SERIES%1~532%I-Mark%1~531%Impulse%1~000%Model Unknown%1~972%N Series%1~842%Oasis%1~800%Pick-Up%1~821%Rodeo%1~533%Stylus%1~820%Trooper%1~967%Vehicross%1*000%Model Unknown%1~009%S-Class%1~010%X Type%1~002%XJ12%1~003%XJ40%1~001%XJ6%1~008%XJ8%1~005%XJR%1~004%XJS%1~006%XJSC%1~XKS%XK Series%1~007%XK8%1*841%CJ%1~820%Cherokee%1~800%Comanche%1~101%Commander%1~102%Compass%1~821%Grand Cherokee%1~823%Grand Wagoneer%1~100%Liberty%1~000%Model Unknown%1~103%Patriot%1~962%Scrambler%1~961%TJ%1~842%TJ GNDS%1~822%Wagoneer%1~840%Wrangler%1*005%Amanti%1~906%Avella%1~907%Credos%1~000%Model Unknown%1~157%Optima%1~004%Rio%1~061%Rondo%1~060%Sedona%1~158%Sedona%1~001%Sephia%1~013%Sorento%1~003%Spectra%1~002%Sportage%1*001%Jeep%1~000%Model Unknown%1~903%Samara%1*000%All%1*871%Defender%1~872%Discovery%1~874%Discovery II%1~900%Freelander%1~873%Highlander%1~876%LR2%1~875%LR3%1~000%Model Unknown%1~001%Model Unknown%1~870%Range Rover%1*007%ES250%1~002%ES300%1~015%ES330%1~030%ES350%1~006%GS300%1~032%GS350%1~009%GS400%1~012%GS430%1~031%GS450H%1~016%GX470%1~027%IS250%1~011%IS300%1~028%IS350%1~005%LS400%1~013%LS430%1~033%LS460%1~008%LX450%1~010%LX470%1~000%Model Unknown%1~001%RX300%1~017%RX330%1~029%RX350%1~026%RX400H%1~003%SC300%1~004%SC400%1~014%SC430%1*291%Aviator%1~290%Blackwood%1~251%Continental%1~254%LS6%1~253%LS8%1~002%MKX%1~255%Mark III%1~256%Mark IV%1~261%Mark LT%1~257%Mark V%1~258%Mark VI%1~259%Mark VII%1~260%Mark VIII%1~000%Model Unknown%1~280%Navigator%1~252%Town Car%1~001%Zephyr/MKZ%1*000%All%1*000%All%1*000%Maybach%1*549%121%1~003%3%1~542%323%1~005%5%1~004%6%1~541%626%1~544%929%1~800%B-Series Pick-Up%1~858%CX-5%1~860%CX-7%1~862%CX-9%1~820%MPV%1~548%MX3%1~546%MX6%1~001%Miata%1~002%Millenia%1~545%Minivan%1~000%Model Unknown%1~821%Navajo%1~547%Prot?g?%1~543%RX7%1~550%RX8%1~822%Tribute%1~850%Van%1*001%190%1~016%C Class%1~C32%C32%1~019%CL Class%1~018%CLK%1~020%CLS%1~002%E Class%1~960%G Class%1~007%G55%1~102%GL Class%1~100%M Class%1~000%Model Unknown%1~101%R Class%1~015%S Class%1~003%SL Class%1~017%SLK%1*231%Bobcat%1~241%Capri%1~232%Cougar%1~233%Grand Marquis%1~234%LN-7%1~235%Lynx%1~243%Marauder%1~245%Mariner%1~236%Marquis%1~247%Milan%1~000%Model Unknown%1~240%Monarch%1~246%Montego%1~244%Monterey%1~606%Mountainer%1~242%Mystique%1~238%Sable%1~237%Topaz%1~605%Tracer%1~885%Villager%1~239%Zephyr%1*000%Model Unknown%1~903%Samara%1~604%Scorpio%1~602%XR4TI%1*001%Cooper%1~000%Mini%1*560%3000GT%1~551%Chariot%1~552%Cordia%1~570%Diamante%1~001%Eclipse%1~004%Endeavor%1~571%Expo%1~572%Expo LRV%1~553%Galant%1~558%Lambda%1~902%Lancer-MIT%1~557%Minaca%1~554%Mirage%1~000%Model Unknown%1~820%Montero%1~840%Montero Sport%1~003%Outlander%1~800%Pick-Up%1~559%Precis%1~005%Raider%1~002%Sigma%1~555%Starion%1~556%Tredia%1~830%Van%1*BTY%Mobility%0*003%200SX%1~001%210%1~004%240SX%1~005%300ZX%1~002%310%1~009%Altima%1~010%Altra%1~522%Armada%1~007%Axxess%1~810%Frontier%1~012%GT-R%1~518%March%1~513%Maxima%1~519%Micra%1~000%Model Unknown%1~008%Murano%1~515%NX%1~820%Pathfinder%1~800%Pick-Up%1~514%Prairie%1~880%Quest%1~516%Sentra%1~517%Stanza%1~521%Titan%1~830%Vanette%1~523%Versa%1~890%Xterra%1~006%Z%1*161%Achieva%0~158%Alero%0~001%Aurora%0~820%Bravada%0~155%Calais%0~152%Ciera%0~160%Custom Cruiser%0~901%Cutlass%0~159%Cutlass Supreme%0~153%Eighty Eight/LSS%0~151%Firenza%0~164%Intrigue%0~162%LSS%0~000%Model Unknown%0~154%Ninety Eight%0~168%Omega%0~163%Regency%0~880%Silhouette%0~157%Starfire%0~156%Toronado%0~999%the entire line of Oldsmobile vehicles%0*000%All%1*001%405%1~003%505%1~004%604%1~002%605%1~000%Model Unknown%1*319%Acclaim%1~860%B-Van%1~050%Breeze%1~311%Caravelle%1~571%Challenger%1~562%Colt%1~563%Colt Vista%1~568%Conquest%1~317%Fury%1~312%Gran Fury%1~313%Horizon%1~569%Laser%1~000%Model Unknown%1~001%Neon%1~002%Prowler%1~314%Reliant%1~573%Sapporo%1~890%Scamp%1~318%Sundance%1~830%Trailduster%1~315%Turismo%1~316%Volare%1~861%Voyager%1*141%1000%0~149%2000%0~132%6000%0~145%Astre%0~902%Aztek%0~143%Bonneville%0~146%Fiero%0~142%Firebird%0~PG5%G5%1%1~G6C%G6 Convertible%1%1~G6U%G6 Coupe%1%1~PG6%G6 Sedan%1%1~PG8%G8%1%1~GTO%GTO%0~135%Grand Am%0~144%Grand Prix%1%1~503%Le Mans%0~000%Model Unknown%0~890%Montana%0~133%Parisienne%0~148%Phoenix%0~999%Pontiac Full-line%1%1~SV6%SV6%0~134%Safari%0~SOL%Solstice%1%1~131%Sunbird%0~130%Sunfire%0~TOR%Torrent%1%1~880%Trans Sport%0~150%Ventura%0~970%Vibe%1%1*008%356%1~001%911%1~005%912%1~006%914%1~003%924%1~002%928%1~007%930%1~004%944%1~009%968%1~010%Boxster%1~012%Carrera GT%1~011%Cayenne%1~013%Cayman%1~000%Model Unknown%1*581%18I%1~585%Alpine%1~582%Fuego%1~583%LeCar%1~586%Medallion%1~000%Model Unknown%1~587%Premier%1~584%SportWagon%1*000%All%1*005%9-2 X%0~S92%9-2X%0~93C%9-3 Convertible%1%1~004%9-3 Sport Sedan%1%1~93W%9-3 SportCombi%1%1~003%9-5 Sedan%1%1~95W%9-5 SportCombi%1%1~006%9-7 X%0~97X%9-7X%1%1~001%900%0~002%9000%0~000%Model Unknown%0~999%Saab Full-line%1%1~9TX%Turbo X%1%1*091%3 Door Coupe%0~AST%ASTRA%1%1~AUR%AURA%1%1~AGL%AURA Green Line Hybrid%1%1~097%ION%0~QCP%ION Quad Coupe%0~IRL%ION Red Line Coupe%0~094%L-300 Sedan%0~095%L-300 Wagon%0~000%Model Unknown%0~OUT%OUTLOOK%1%1~REL%RELAY%0~090%S-Series Sedan%0~092%S-Series Wagon%0~SKY%SKY%1%1~SRL%SKY Red Line%1%1~999%Saturn Full-line%1%1~093%Saturn GMEV%0~096%VUE%0~8VU%VUE%1%1~8VG%VUE Green Line%1%1~VHY%VUE Green Line Hybrid%0~VRL%VUE Red line%1%1*001%BBX%1~000%Scion%1*912%B9-Tribeca%1~892%Baja%1~890%Brat%1~968%Forester%1~597%Impreza%1~594%Justy%1~592%Legacy%1~595%Loyale%1~000%Model Unknown%1~001%STD%1~596%SVX%1~891%Streega%1~593%XT%1*300%Aerio%1~843%Esteem%1~002%Forenza%1~963%Grand Vitara%1~000%Model Unknown%1~004%Reno%1~400%SX4%1~841%Samurai%1~840%Sidekick%1~001%Swift%1~003%Verona%1~760%X-90%1~200%XL7%1*820%4Runner%1~002%Avalon%1~611%Camry%1~612%Celica%1~613%Corolla%1~001%Corona%1~615%Cressida%1~623%Echo%1~624%FJ-Cruiser%1~640%Highlander%1~870%Landcruiser%1~616%MR2%1~807%Matrix%1~000%Model Unknown%1~607%Paseo%1~800%Pick-Up%1~881%Previa%1~630%Prius%1~805%RAV4%1~SCI%Scion%1~614%Sequoia%1~803%Sienna%1~003%Solara%1~620%Soluna%1~617%Starlet%1~618%Supra%1~801%T100%1~802%Tacoma%1~619%Tercel%1~804%Tundra%1~880%Van%1~622%Yaris%1*003%Unspecified Car%1~004%Unspecified Truck%1*912%Beetle%1~001%Cabriolet%1~625%Corrado%1~008%EOS%1~851%Eurovan%1~626%Fox%1~003%GTI%1~002%Golf%1~622%Jetta%1~000%Model Unknown%1~627%Passat%1~006%Phaeton%1~623%Quantum%1~004%Rabbit%1~624%Scirocco%1~005%Touareg%1~850%Vanagon%1*001%240%1~004%740%1~005%760%1~006%780%1~008%850%1~003%940%1~002%960%1~911%C30%1~009%C70%1~000%Model Unknown%1~905%S40%1~030%S60%1~020%S70%1~909%S80%1~908%S90%1~906%V40%1~011%V50%1~010%V70%1~910%V80%1~907%V90%1~012%XC90%1*662%198%1~661%GV%1~664%GVC%1~001%GVL%1~663%GVS%1~002%GVX%1~000%Model Unknown%1";


var irfDivision=""; // Global variable used to identify IRF Division; Used in function writeCurrentModelColumn for IRF Revamp CR
var duplicateErrorMessage="This vehicle is already selected."; //Alert message for duplicate vehicle selection added as part of IRF Revamp CR.
function popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=250,left = 492,top = 374');");
}



//MAKE MODEL LIB
//---------------------------------------------------------------------------------------------------------
// constructor for make object

// ie, writeGmMakesMulti(0)
// used by the select dropdowns for what other models users are interested in;
// Writes out GM makes
function writeGmMakesMulti(onlyActive,fieldname,fieldtype) {
  for (var i = 0; i != makes.length; i++) {
    var make = makes[i];
    if ((onlyActive == 0 || make.active == 1) && make.gm==1 ) {
      document.write('<OPTION VALUE="' + make.code + '"  >' + make.name + '</OPTION>\n');
    }
  }
}

// ie, writeGmMakesMultiSelected(0)
// used by the select dropdowns for what other models users are interested in;
// Writes out GM makes
function writeGmMakesMultiSelected(onlyActive,fieldname,fieldtype) {
  for (var i = 0; i != makes.length; i++) {
    var make = makes[i];
    if ((onlyActive == 0 || make.active == 1) && make.gm==1 ) {
      document.write('<OPTION VALUE="' + make.code + '" SELECTED >' + make.name + '</OPTION>\n');
    }
  }
}

// ie, writeGmMakesMulti(0)
// used by the select dropdowns for what other models users are interested in;
// Writes out GM makes
function writeGmMakesSelect(SMSselected) {
  for (var i = 0; i != makes.length; i++) {
    var make = makes[i];
    if (make.gm==1) {
      document.write('<OPTION VALUE="' + make.code + '"' + (make.code == SMSselected)?'SELECTED':'' +  '>' + make.name + '</OPTION>\n');
    }
  }
}


/*

This function writes out GM models.
*/
function writeGmModelsMulti() {
   // if we haven't parsed out all the models for each make, do so
   doModels();

   for (var i = 0; i != makes.length; i++) {
      for (var j = 0; j != makes[i].models.length; j++) {
         if (makes[i].gm == 1 && (makes[i].models[j].active == 1 && makes[i].models[j].brochureAvailable == 1)) {
            document.write('<OPTION VALUE="' + questionID + '%' + makes[i].code + '%' + makes[i].models[j].code + '">' + makes[i].name + ' ' + makes[i].models[j].name + '</OPTION>\n');
         }
      }
   }
}


/*
This function writes out GM models that were selected.
*/
function writeGmModelsMultiSelected() {
   // if we haven't parsed out all the models for each make, do so
   doModels();

   for (var i = 0; i != makes.length; i++) {
      for (var j = 0; j != makes[i].models.length; j++) {
         if (makes[i].gm == 1 && (makes[i].models[j].active == 1 && makes[i].models[j].brochureAvailable == 1)) {
            document.write('<OPTION VALUE="' + questionID + '%' + makes[i].code + '%' + makes[i].models[j].code + '" SELECTED >' + makes[i].name + ' ' + makes[i].models[j].name + '</OPTION>\n');
         }
      }
   }
}


/*
This function sorts an array of objects by the specified property.
*/
function arraySort(arrayName, length, property) {
   for (var i = 0; i < (length - 1); i++) {
      for (var j = i + 1; j < length; j++) {
         if (eval("arrayName[j]." + property) < eval("arrayName[i]." + property)) {
            var temp = arrayName[i];
            arrayName[i] = arrayName[j];
            arrayName[j] = temp;
         }
      }
   }
}


/*
This is the constructor for vehicle object.
*/
function vehicle(makeName, modelName, makeCode, modelCode) {
   this.name = makeName + " " + modelName;
   this.code = makeCode + modelCode;
}


/*
This function creates the checkboxes in the specified number of
columns for the GM Fleet type question for cross divisional makes.
*/
function writeCurrentFleetModelColumn(eligiblemodels,fieldName,numberOfColumns) {
   // if we haven't parsed out all the models for each make, do so
   doModels();

   var vehicles = eligiblemodels.split("~");
   var sortedVehicles = new Array(); // this array will be used to store vehicles, and sorted by make and model names
   var colNumber = 0;
   var vCount = 0; // vehicle count;

   for (i = 0; i < vehicles.length - 1; i++) {
      var codes = vehicles[i].split("%");
      var makeCode = codes[1];
      var modelCode = codes[2];

      // look up vehicle make and model names with corresponding make and model codes
      for (var j = 0; j != makes.length; j++) {
         for (var k = 0; k != makes[j].models.length; k++) {
            if (makes[j].code == makeCode && makes[j].models[k].code == modelCode) {
               // assign to sortedVehicles array
               sortedVehicles[vCount] = new vehicle(makes[j].name, makes[j].models[k].name, makeCode, modelCode);

               vCount++;
            }
         }
      }
   }

   // sort the array of objects by the "name" property
   arraySort(sortedVehicles, sortedVehicles.length, "name")

   // display vehicles
   for (i = 0; i < sortedVehicles.length; i++) {
      if (colNumber == 0){
         document.write("<tr>");
      }
      document.write("<td>");
      document.write("<input type='checkbox' name='"
         + fieldName + "' value='"
         + sortedVehicles[i].code + "'>" + "<span id='text'>"
         + sortedVehicles[i].name
         + "</span></input><br />");
      document.write("</td>");

      colNumber++;

      if (colNumber == numberOfColumns) {
         colNumber = 0;
         document.write("</tr>");
      }
   }k
}


function Make(code, name, gm, active) {
  this.code = code;
  this.name = name;
  this.gm = gm;
  this.active = active;
  this.models = null;
}

// constructor for model object

function Model(code, name, active, brochureAvailable, years) {
  this.code = code;
  this.name = name;
  this.active = active;
  this.brochureAvailable = brochureAvailable;
  this.years = years;  // array of years of available brochures
}

// parse out all the makes into an array of make
// objects, makes[]

var rawMakesSplit = rawMakes.split('~');
var numMakes = rawMakesSplit.length;
var makes = new Array(numMakes);
var makeIndex = new Object();
for (var i = 0; i != numMakes; i++) {
  var fields = rawMakesSplit[i].split('%');
  makes[i] = new Make(fields[0], fields[1], fields[2], fields[3]);

  makeIndex[fields[0]] = makes[i];
}

var rawYearsSplit = rawYears.split('~');
var numYearArrays = rawYearsSplit.length;
var yearArrays = new Array(numYearArrays);
var yearArrayIndex = new Object();
for (var i = 0; i != numYearArrays; i++) {
  var fields = rawYearsSplit[i].split('%');
  yearArrays[i] = fields[2].split(',');

  // create a unique id for each array of years,
  var makeModelID = fields[0] + fields[1];
  yearArrayIndex[makeModelID] = yearArrays[i];
}


// function to parse out all models, called from updateModels(), and
// then only once, presumably to save on not having to do all this
// work if the user never selects anything

var modelsDone = 0;
// when doModels() runs, it only runs once, for after the

function doModels() {

  //if (modelsDone == 0) {

    var rawModelsSplit = rawModels.split('*');

    // the number of rawmodels is the number of makes...
    for (var i = 0; i != numMakes; i++) {
      // all the models for this make are separated by ~
      var theseModelsRaw = rawModelsSplit[i].split('~');
      var numThese = theseModelsRaw.length;  // number of models for this make
      var theseModels = new Array(numThese);  // build array of models

      // current array of models gets attached to the .models
      // property of the related make
      makes[i].models = theseModels;

      // create each model object in theseModels, aka makes[i].models
      for (var j = 0; j != numThese; j++) {
        var fields = theseModelsRaw[j].split('%');
		var makeModelID = makes[i].code + fields[0];
        theseModels[j] = new Model(fields[0], fields[1], fields[2], fields.length == 4 ? fields[3] : 0, yearArrayIndex[makeModelID]);
      }
    }
//    modelsDone = 1;
//  }
}

//This is for combo boxes
//function updateModelsC(makeList, modelList, onlyActive, onlyBrochureAvailable, useJoint) {
function updateModelsC(makeList, modelList,onlyActive, onlyBrochureAvailable, useJoint) {
  doModels();
  // if we haven't parsed out all the models for each make, do so
  if (makeList.options[makeList.selectedIndex].value=='' || makeList.selectedIndex==0){
  		modelList.options.length = 0;
  		modelList.options[0] = new Option('Model', '00000');
		return;
  }
  // the currently-selected make, such as "04" for Cadillac
  var makeCode = makeList.options[makeList.selectedIndex].value;

  // make the length of the corresponding model dropdown 0. ie, clear it
  modelList.options.length = 0;

  // set the first element of the corresponding model dropdown to say "Model"
  // and have the value 00000 to mean no make or model
  modelList.options[0] = new Option('Model', '00000');

  if (makeCode != '00') {
    // get the array of models associated with this make code,
    // which we conveniently extract from makeIndex[]

    var models = makeIndex[makeCode].models;
    //alert("Models:"+models);
    for (var i = 0; i != models.length; i++) {
      var model = models[i];
      //alert(model);
	  modelList.options[modelList.length] = new Option(model.name, model.code);
	  /*
      if ((onlyActive  ==  0 || model.active == 1) && (onlyBrochureAvailable == 0 || model.brochureAvailable == 1)) {
        // modelList.options[modelList.length] is a fancy way of saying
		// "the last element of modelList"; that is, we are appending
		// each model to the pulldown pointed to by modelList
		if(modelList.name=="X00950GROUP00951" || modelList.name=="X00950GROUP00953"){ //Full Line removal from Household dropdowns for IRF Revamp
			if(model.code!="999"){ //Full Line removal from Household dropdowns for IRF Revamp
				modelList.options[modelList.length] = new Option(model.name, (useJoint == 1 || make.gm==1 ) ? makeCode + model.code : model.code);
			}
		}
		else
		{
				modelList.options[modelList.length] = new Option(model.name, model.code);
		}
      }
      */
    }
  }
  // ensure that the 0th element of the dropdown list is selected,
  if (modelList.length != 0) {
    modelList.options[0].selected = true;
  }

  //reloadLists();
 /*
  */
}


//This is for combo boxes
function updateModelsAdmin(makeList, modelList, onlyActive, onlyBrochureAvailable, useJoint) {

  // if we haven't parsed out all the models for each make, do so
  doModels();

  // the currently-selected make, such as "04" for Cadillac
  var makeCode = makeList.options[makeList.selectedIndex].value;

  // make the length of the corresponding model dropdown 0. ie, clear it
  modelList.options.length = 0;

  // set the first element of the corresponding model dropdown to say "Model"
  // and have the value 00000 to mean no make or model
  modelList.options[0] = new Option('Model', '00000');

  if (makeCode != '00') {
    // get the array of models associated with this make code,
    // which we conveniently extract from makeIndex[]
    var models = makeIndex[makeCode].models;
    for (var i = 0; i != models.length; i++) {
      var model = models[i];
      if ((onlyActive  ==  0 || model.active == 1) && (onlyBrochureAvailable == 0 || model.brochureAvailable == 1)) {
        // modelList.options[modelList.length] is a fancy way of saying
	// "the last element of modelList"; that is, we are appending
	// each model to the pulldown pointed to by modelList
        modelList.options[modelList.length] =
          new Option(model.name, model.code);
      }
    }
  }
  // ensure that the 0th element of the dropdown list is selected,
  if (modelList.length != 0) {
    modelList.options[0].selected = true;
  }

  reloadLists();
}

//This is for combo boxes
function updateModelsQ(makeCode, modelListName, onlyActive, onlyBrochureAvailable, useJoint) {

  // if we haven't parsed out all the models for each make, do so
  doModels();


  // make the length of the corresponding model dropdown 0. ie, clear it
  modelList=document.forms[0].elements[modelListName];
  modelList.options.length = 0;

  // set the first element of the corresponding model dropdown to say "Model"
  // and have the value 00000 to mean no make or model
  modelList.options[0] = new Option('Model', '00000');

  if (makeCode != '00') {
    // get the array of models associated with this make code,
    // which we conveniently extract from makeIndex[]
    var models = makeIndex[makeCode].models;
    for (var i = 0; i != models.length; i++) {
      var model = models[i];
      if ((onlyActive  ==  0 || model.active == 1) && (onlyBrochureAvailable == 0 || model.brochureAvailable == 1)) {
        // modelList.options[modelList.length] is a fancy way of saying
	// "the last element of modelList"; that is, we are appending
	// each model to the pulldown pointed to by modelList
        modelList.options[modelList.length] =
          new Option(model.name, (useJoint == 1 || make.gm==1 ) ? makeCode +  model.code : model.code);
      }
    }
  }
  // ensure that the 0th element of the dropdown list is selected,
  if (modelList.length != 0) {
    modelList.options[0].selected = true;
  }

  reloadLists();
}



//This is for check boxes
function updateModelsB(makeList, modelList, onlyActive, onlyBrochureAvailable, useJoint) {

  // if we haven't parsed out all the models for each make, do so
  doModels();

  // the currently-selected make, such as "04" for Cadillac
  var makeCode = makeList.options[makeList.selectedIndex].value;

  // make the length of the corresponding model dropdown 0. ie, clear it
  modelList.options.length = 0;

  // set the first element of the corresponding model dropdown to say "Model"
  // and have the value 00000 to mean no make or model
  modelList.options[0] = new Option('Model', '00000');

  if (makeCode != '00') {
    // get the array of models associated with this make code,
    // which we conveniently extract from makeIndex[]
    var models = makeIndex[makeCode].models;
    for (var i = 0; i != models.length; i++) {
      var model = models[i];
      if ((onlyActive  ==  0 || model.active == 1) && (onlyBrochureAvailable == 0 || model.brochureAvailable == 1)) {
        modelList.options[modelList.length] =
          new Option(model.name, useJoint == 1 ? makeCode + '/' + model.code : model.code);
      }
    }
  }
  // ensure that the 0th element of the dropdown list is selected,
  if (modelList.length != 0) {
    modelList.options[0].selected = true;
  }

  reloadLists();
}


function updateYears(modelList, yearList) {

  // if we haven't parsed out all the models for each make, do so
  doModels();

  // the currently-selected model, such as "03/0202" for Chevy Blazer.
  var modelCode = modelList.options[modelList.selectedIndex].value;

  // make the length of the corresponding year dropdown 0. ie, clear it
  yearList.options.length = 0;

  // set the first element of the corresponding model dropdown to say "Year"
  // and have the value 0000 to mean no year
  yearList.options[0] = new Option('Year', '0000');

  if (modelCode != '00000') {
    // get the array of years associated with this make/model code,
    // which we conveniently extract from yearArrayIndex[]
    var years = yearArrayIndex[modelCode];
    for (var i = 0; i != years.length; i++) {
      var year = years[i];
      // yearList.options[yearList.length] is a fancy way of saying
      // "the last element of yearList"; that is, we are appending
      // each model to the pulldown pointed to by yearList
      yearList.options[yearList.length] = new Option(year, year);
    }
  }
  // ensure that the 0th element of the dropdown list is selected,
  if (yearList.length != 0) {
    yearList.options[0].selected = true;
  }
}

// ie, writeMakes(0)
// used by the select dropdowns for what other models users are interested in;
// Writes out every make there is
//function writeMakes(onlyActive,fieldname,fieldtype) {
function writeMakes(fieldObj) {
  //alert('<OPTION VALUE="">Make</OPTION>\n');

  for (var i = 0; i != makes.length; i++) {
    fieldObj.options[i+1] = new Option(makes[i].name, makes[i].code);
    /*
    if ((onlyActive == 0 || make.active == 1) && onlyActive!=2) {
      alert('<OPTION VALUE="' + make.code + '">' + make.name + '</OPTION>\n');
    }
	else if (onlyActive == 2 && make.gm==0 && make.active == 1) {//Added to filtering out GM Brands from displaying in Other manufacturers dropdown - added for IRF Revamp CR
      alert('<OPTION VALUE="' + make.code + '">' + make.name + '</OPTION>\n');
    }*/

  }
}

// ie, writeGMMakes(0)
// used by the select dropdowns for what other models users are interested in;
// Writes out GM makes
function writeGmMakes(onlyActive,includeList) {
var incList=includeList.split("~");
  document.write('<OPTION VALUE="">Make</OPTION>\n');
  for (var i = 0; i != makes.length; i++) {
    var make = makes[i];
    if ((onlyActive == 0 || make.active == 1) && make.gm==1 ) {
    	if (includeList=='' || includeList=='null' || includeList==null){
		document.write('<OPTION VALUE="' + make.code + '">' + make.name + '</OPTION>\n');
    	}else{
		for (var q=0;q<incList.length;q++){
			if (incList[q]==make.code && irfDivision!=make.code){
			      document.write('<OPTION VALUE="' + make.code + '">' + make.name + '</OPTION>\n');
			}
		}
	}
    }
  }
}
//added to remove the GM vehcile from the other manufacture question.
function writeMakesNonGM(onlyActive,fieldname,fieldtype) {
  document.write('<OPTION VALUE="">Make</OPTION>\n');
  for (var i = 0; i != makes.length; i++) {
    var make = makes[i];
	if(make.code!='05'){
	if (make.gm== 0)  {
      document.write('<OPTION VALUE="' + make.code + '">' + make.name + '</OPTION>\n');
    }}
  }
}

// Return the make name as string
function getMakeName(smscode) {
  for (var i = 0; i != makes.length; i++) {
    var make = makes[i];
    if (make.code==smscode){
    	return make.name;
    }
}
return '';
}


// called once, at the location of each brochure models pulldown, to create
// the requisite number of empty options, presumably to keep the pulldown

function writeNulls(count) {
  document.write('<OPTION VALUE="00000">Model</OPTION>\n');
}

// used by the "what other makes/models interest you?" pulldowns.
// consider modifying this for use in the year pulldown for brochures
function writeYears() {
	var d = new Date();
  for (var i = d.getFullYear(); i >= 1969; i--) {
    document.write('<OPTION VALUE="' + i + '">' + i + '</OPTION>');
  }
}


// called once, at the location of each current models pulldown, to create
// the requisite number of empty options, presumably to keep the pulldown
// NOTE that here we have just 0000 for an empty model, whereas
// writeNulls has 00000
function writeCurrentModelNulls(count) {
  document.write('<OPTION VALUE="00000">Model</OPTION>\n');
  for (var i = 0; i != count; i++) {
    document.write('<OPTION VALUE="00000">______</OPTION>\n');
  }
}


// called once, at the location of each current models pulldown, to create
// the requisite number of empty options, presumably to keep the pulldown
// NOTE that here we have just 00000 for an empty model, whereas
// writeNulls has 00000
function writeCurrentModel(SMSMakeCode,fieldName) {

  // if we haven't parsed out all the models for each make, do so
  doModels();

  // the currently-selected make, such as "04" for Cadillac
  var makeCode = SMSMakeCode;

  if (makeCode != '00') {
    var models = makeIndex[makeCode].models;
    for (var i = 0; i != models.length; i++) {
	var model = models[i];
	if (models[i].active==1){
		document.write("<input type=\"checkbox\" name=\""+fieldName+"\" value=\""+model.code+"\">"+"<span id=\"text\">"+model.name+"</span></input><br />");
	}

    }
  }

  }

function writeCurrentModelColumn(SMSMakeCode,fieldName,numberOfColumns) {
   // if we haven't parsed out all the models for each make, do so
      doModels();

   // the currently-selected make, such as "04" for Cadillac
  var makeCode = SMSMakeCode;
irfDivision=makeCode;
   if (makeCode != '00') {
      var models = makeIndex[makeCode].models;
      var colNumber=0;


	  for (var i = 0; i != models.length; i++) {
         var model = models[i];
			if (model.active==1 && model.code=='999'){//IRF Revanmp Release2.9 full line vehicle in first line.
				document.write("<input type=\"checkbox\" name=\""+fieldName+"\" value=\""+SMSMakeCode+model.code+"\">"+"<span id=\"text\">"+model.name+"</span></input><br />");
			}

	  }

   	  for (var i = 0; i != models.length; i++) {
         var model = models[i];
         if (model.active==1 && model.code!='999'){//IRF Revanmp Release2.9 full line vehicle removal from existing model
            if (colNumber==0){
               document.write("<tr>");
            }
            document.write("<td nowrap>");
            document.write("<input type=\"checkbox\" name=\""+fieldName+"\" value=\""+SMSMakeCode+model.code+"\">"+"<span id=\"text\">"+model.name+"</span></input>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />");
            document.write("</td>");
            colNumber++
            if (colNumber==4){
               colNumber=0;
               document.write("</tr>");
            }
         }
      }

   }
}

function writeCurrentModelColumnBlue(SMSMakeCode,fieldName,numberOfColumns) {
	// if we haven't parsed out all the models for each make, do so
	doModels();

	var makeCode = SMSMakeCode;
irfDivision=makeCode;
   if (makeCode != '00') {
      var models = makeIndex[makeCode].models;
      var colNumber=0;


	  for (var i = 0; i != models.length; i++) {
         var model = models[i];
			if (model.active==1 && model.code=='999'){//IRF Revanmp Release2.9 full line vehicle in first line.
				document.write("<input type=\"checkbox\" name=\""+fieldName+"\" value=\""+SMSMakeCode+model.code+"\">"+"<span id=\"text\">"+model.name+"</span></input><br />");
			}

	  }

   	  for (var i = 0; i != models.length; i++) {
         var model = models[i];
         if (model.active==1 && model.code!='999'){//IRF Revanmp Release2.9 full line vehicle removal from existing model
            if (colNumber==0){
               document.write("<tr>");
            }
            document.write("<td nowrap>");
            document.write("<input type=\"checkbox\" name=\""+fieldName+"\" value=\""+SMSMakeCode+model.code+"\">"+"<span id=\"text\">"+model.name+"</span></input>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />");
            document.write("</td>");
            colNumber++
            if (colNumber==4){
               colNumber=0;
               document.write("</tr>");
            }
         }
      }

   }
}








// called once, at the location of each years pulldown, to create
// the requisite number of empty options, presumably to keep the pulldown
function writeYearNulls(count) {
  document.write('<OPTION VALUE="0000">Year</OPTION>\n');
  for (var i = 0; i != count; i++) {
    document.write('<OPTION VALUE="0000">____</OPTION>\n');
  }
}


// used to write options 1..10 and 15 for the question
// "how many more years will you own/drive this vehicle?"
// Not currently asked in current application
function writeMoreYears() {
  for (var i = 1; i != 11; i++) {
    document.write('<OPTION VALUE="' + i + '">' + i + '</OPTION>');
  }
  document.write('<OPTION VALUE="15">&gt;10</OPTION>');
}






function  checkModels(modelDropdown){ // Avoid duplicate selection for Divisonal GM model dropdowns
	if(modelDropdown.selectedIndex==0)
		return;
	var currentValInDropdown=modelDropdown.value;
	var currentSelIndex=modelDropdown.selectedIndex;
	switch(modelDropdown.name)
		{
			case "XMMGM001model0":
				if(currentValInDropdown==document.forms[0].XMMGM001model1.value || currentValInDropdown==document.forms[0].XMMGM001model2.value)
				{
					alert(duplicateErrorMessage);
					modelDropdown.options[0].selected=true;
					//modelDropdown.options[currentSelIndex].selected=true;
					modelDropdown.focus();
				}
				break;
			case "XMMGM001model1":
				if(currentValInDropdown==document.forms[0].XMMGM001model0.value || currentValInDropdown==document.forms[0].XMMGM001model2.value)
				{
					alert(duplicateErrorMessage);
					modelDropdown.options[0].selected=true;
					//modelDropdown.options[currentSelIndex].selected=true;
					modelDropdown.focus();
				}
				break;
			case "XMMGM001model2":
				if(currentValInDropdown==document.forms[0].XMMGM001model0.value || currentValInDropdown==document.forms[0].XMMGM001model1.value)
				{
					alert(duplicateErrorMessage);
					modelDropdown.options[0].selected=true;
					//modelDropdown.options[currentSelIndex].selected=true;
					modelDropdown.focus();
				}
				break;
		}
}


// Return IRF Code
function  changeIRF(model){
	switch(model)
		{
			case "g6sedan":
				return "PO20KA55F";
				break;
			case "g6coupe":
				return "PO20KA55F";
				break;
			case "g6convertible":
				return "PO20KA55F";
				break;
			case "g5":
				return "PO20KA815";
				break;
			case "solstice":
				return "PO20KA74B";
				break;
			case "grandprix":
				return "PO20KA565";
				break;
			case "vibe":
				return "PO20KA564";
				break;
			case "torrent":
				return "PO20KA815";
				break;
			case "g8":
				return "PO20KA815";
				break;
		}
}

