function createDropdown(e, name, data, l) { var dropdown = document.createElement("select"); dropdown.setAttribute("id", name); e.appendChild(dropdown); fillDropdown(dropdown, data, l); return dropdown; } function clipText(s, len) { return (s.length < len + 1) ? s : (s.substring(0, len) + "…"); } function fillDropdown(d, data, l) { var maxLen = l; for (var i = 0; i < data.length; ++i) { var option = document.createElement("option"); var displayVal = clipText(data[i], maxLen); option.setAttribute("value", data[i]); d.appendChild(option); option.appendChild(document.createTextNode(displayVal)); } d.selectedIndex = 0; } function resetState(d) { var form = d.parentNode; var iselect = 0; for (; iselect < form.elements.length; ++iselect) { if (form[iselect] == d) break; } if (1 + iselect < form.elements.length) { var target = form.elements[1 + iselect]; clearDropdown(target); fillDropdown(target, form.ymm.data[1 + iselect][selectedValue1(d)], form.ymm.maxLen); target.disabled = (target.options.length <= 1); resetState(form.elements[1 + iselect]); } } function clearDropdown(d) { if (d && d.options) { for (ifield = d.options.length - 1; ifield >= 0; --ifield) { d.removeChild(d.options[ifield]); } } } function selectedValue1(e) { if ("select-one" == e.type) return e.options[e.selectedIndex].value; if ("select-multiple" == e.type) { var result = ""; for (var ifield = 0; ifield < e.options.length; ifield++) { if (e.options[ifield].selected) result += e.options[ifield].value + ','; } return result.substring(0, result.length - 1); } } function selectedValue(f, el) { return selectedValue1(f.elements[el]); } function buildYmms() { var ymms = document.getElementsByTagName("div"); for (var i = 0; i < ymms.length; ++i) { if ("ymm" == ymms[i].getAttribute("className") || "ymm" == ymms[i].getAttribute("class")) createForm(ymms[i]); } } var ymm = {"all":{"maxLen":13,"urls":["","http://research.cars.uk.msn.com/autos/vip/AutoMaker.aspx?make={0}"],"url":"http://research.cars.uk.msn.com/autos/vip/default.aspx?year=&make={0}&model={1}","data":[['Make:','Abarth','AC','Alfa Romeo','Alpina','Ariel','Asia','Aston Martin','Audi','Bentley','BMW','Bristol','Bugatti','Cadillac','Caterham','Chevrolet','Chrysler','Citroen','Citroën','Corvette','Daewoo','Daihatsu','Daimler','DODGE','FBS','Ferrari','Fiat','Ford','FSO','Hindustan','Honda','Hummer','Hyundai','Infiniti','Isuzu','Jaguar','Jeep','Jensen','KIA','KTM','Lada','Lamborghini','Land Rover','Lexus','Lotus','Mahindra','Marcos','Maserati','Maybach','Mazda','MCC','Mclaren','Mercedes-Benz','MG','MINI','Mitsubishi','Morgan','Nice','Nissan','Noble','Perodua','Peugeot','Porsche','Proton','Renault','Rolls-Royce','Rover','Saab','Scimitar','SEAT','Skoda','smart','Ssangyong','Strathcarron','Subaru','Suzuki','Tata','Toyota','TVR','Vauxhall','Venturi','Volkswagen','Volvo','Westfield'],{'Make:':['Model:'],'Abarth':['Model:','All models','500'],'AC':['Model:','All models','212 SC','Ace','Aceca','Cobra','Superblower'],'Alfa Romeo':['Model:','All models','145','146','147','155','156','159','164','166','Brera','GT','GTV','MITO','Spider'],'Alpina':['Model:','All models','B10','B12','B3','B3 S','B5 S','B6 S','B7','D3','Roadster','Roadster S'],'Ariel':['Model:','All models','Atom'],'Asia':['Model:','All models','Rocsta'],'Aston Martin':['Model:','All models','DB7','DB9','DBS','V8','V8 Vantage','Vanquish','Vantage','Virage','Volante'],'Audi':['Model:','All models','A2','A3','A4','A4 Allroad quattro','A5','A6','A8','allroad quattro','Cabriolet','Convertible','Coupe','Q5','Q7','R8','RS4','RS6','S2','S3','S4','S5','S6','S8','TT','TT RS','TTS'],'Bentley':['Model:','All models','Arnage','Azure','Brooklands','Continental','Continental Flying Spur','Continental GT','Turbo'],'BMW':['Model:','All models','1 Series','3 Series','5 Series','6 Series','7 Series','8 Series','X3','X5','X6','Z3','Z4','Z8'],'Bristol':['Model:','All models','Blenheim','Blenheim 2','Fighter'],'Bugatti':['Model:','All models','EB 110'],'Cadillac':['Model:','All models','BLS','CTS','Escalade','Seville','SRX','STS'],'Caterham':['Model:','All models','21','Super 7'],'Chevrolet':['Model:','All models','Aveo','Blazer','Camaro','Captiva','Corvette','Cruze','Epica','Kalos','Lacetti','Matiz','Tacuma'],'Chrysler':['Model:','All models','300C','300C Touring','Crossfire','Grand Voyager','Neon','New Yorker','PT Cruiser','Sebring','Viper','Voyager'],'Citroen':['Model:','All models','C3'],'Citroën':['Model:','All models','AX','Berlingo','Berlingo First','C1','C2','C3','C3 Picasso','C3 Pluriel','C4','C4 Picasso','C5','C6','C8','C-Crosser','Grand C4 Picasso','Nemo','Saxo','Synergie','Xantia','XM','Xsara','Xsara Picasso','ZX'],'Corvette':['Model:','All models','Corvette'],'Daewoo':['Model:','All models','Espero','Kalos','Korando','Lacetti','Lanos','Leganza','Matiz','Musso','Nexia','Nubira','Tacuma'],'Daihatsu':['Model:','All models','Charade','Copen','Cuore','Fourtrak','Grand Move','Hijet','Materia','Mira','Move','Sirion','Sportrak','Terios','YRV'],'Daimler':['Model:','All models','Super Eight','XJ Series'],'DODGE':['Model:','All models','Avenger','Caliber','Journey','Nitro','RAM','SRT-10'],'FBS':['Model:','All models','Census'],'Ferrari':['Model:','All models','348','360','456','456M','550 Maranello','575M Maranello','599','612','California','Enzo','F355','F430','F512 M','Superamerica'],'Fiat':['Model:','All models','500','Barchetta','Brava','Bravo','Cinquecento','Coupe','Croma','Doblò','Grande Punto','Grande Punto S2','Idea','Marea','Multipla','Panda','Punto','Qubo','Sedici','Seicento','Stilo','Tempra','Tipo','Ulysse','Uno'],'Ford':['Model:','All models','C-MAX','Cougar','Escort','Explorer','Fiesta','Focus','Focus C-MAX','Fusion','Galaxy','Ka','Kuga','Maverick','Mondeo','Probe','Puma','Ranger','Scorpio','S-MAX','StreetKa'],'FSO':['Model:','All models','Caro'],'Hindustan':['Model:','All models','Ambassador'],'Honda':['Model:','All models','Accord','Accord Tourer','Civic','CR-V','CRX','FR-V','HR-V','Insight','Integra','Jazz','Legend','Logo','NSX','Prelude','S2000','Shuttle','Stream'],'Hummer':['Model:','All models','H2','H3'],'Hyundai':['Model:','All models','Accent','Amica','Atoz','Coupe','Elantra','Getz','Grandeur','i10','i20','i30','i800','Lantra','Matrix','Santa Fe','Scoupe','Sonata','Terracan','Trajet','Tucson','XG30'],'Infiniti':['Model:','All models','EX','FX','G'],'Isuzu':['Model:','All models','Rodeo','TF','Trooper'],'Jaguar':['Model:','All models','S-TYPE','XF','XJ','XJ Series','XK','XK Series','X-Type'],'Jeep':['Model:','All models','Cherokee','Commander','Compass','Grand Cherokee','Patriot','Wrangler'],'Jensen':['Model:','All models','S-V8'],'KIA':['Model:','All models','Carens','cee\'d','cee\'d SW','Cerato','Clarus','Magentis','Mentor','Mentor II','Picanto','Pride','pro_cee\'d','Rio','Sedona','Shuma','Shuma II','Sorento','Soul','Sportage'],'KTM':['Model:','All models','X-BOW'],'Lada':['Model:','All models','Niva','Riva','Samara'],'Lamborghini':['Model:','All models','Diablo','Gallardo','Murcielago'],'Land Rover':['Model:','All models','Defender','Discovery','Discovery 3','Freelander','Freelander 2','Range Rover','Range Rover Sport'],'Lexus':['Model:','All models','GS','GS300','GS430','IS','IS200','IS300','LS','LS400','LS430','RX','RX300','RX350','RX400h','SC','SC430'],'Lotus':['Model:','All models','2-Eleven','Elan','Elise','Esprit','Europa','Evora','Exige'],'Mahindra':['Model:','All models','CJ3'],'Marcos':['Model:','All models','GTS','GTS Turbo','LM','Mantara','Mantara LM','Mantaray','Mantis','TS250','TS500','TSO'],'Maserati':['Model:','All models','3200 GT','Coupé','Ghibli','GranSport','GranTurismo','Quattroporte','Shamal','Spyder'],'Maybach':['Model:','All models','Maybach'],'Mazda':['Model:','All models','121','323','626','B-Series','BT-50','Demio','Mazda2','Mazda3','Mazda5','Mazda6','MPV','MX-3','MX-5','MX-6','Premacy','RX-7','RX-8','Tribute','Xedos 6','Xedos 9'],'MCC':['Model:','All models','Smart'],'Mclaren':['Model:','All models','F1'],'Mercedes-Benz':['Model:','All models','A-class','B-Class','C-class','CLC-class','CL-class','CLK-class','CLS-class','E-class','E-Class Coupe','G-class','GL-Class','M-class','R-Class','S-class','SL-class','SLK-class','SLR McLaren','Vaneo','V-class','Viano'],'MG':['Model:','All models','MGF','RV8','TF','XPower SV','ZR','ZS','ZT','ZT-T'],'MINI':['Model:','All models','MINI'],'Mitsubishi':['Model:','All models','3000 GT','Carisma','Challenger','Colt','Galant','Grandis','i','L200','Lancer','Outlander','Shogun','Shogun Pinin','Shogun Sport','Sigma','Space Runner','Space Star','Space Wagon'],'Morgan':['Model:','All models','+4','Aero 8','Four Four','Plus Eight','Plus Four','V6'],'Nice':['Model:','All models','MEGA City','MyCar','Ze-O'],'Nissan':['Model:','All models','200 SX','350Z','370Z','Almera','Almera Tino','GT-R','Maxima QX','Micra','Murano','Navara','Note','NP300','Pathfinder','Patrol','Patrol GR','Pickup','Pixo','Primera','QASHQAI','QASHQAI+2','QX','Serena','Skyline','Sunny','Terrano','Terrano II','X-Trail'],'Noble':['Model:','All models','M12','M14','M400'],'Perodua':['Model:','All models','Kelisa','Kenari','Myvi','Nippa'],'Peugeot':['Model:','All models','1007','106','107','205','206','206 SW','207','207 SW','306','307','307 SW','307CC','308','308 SW','308CC','4007','405','406','407','407 Coupe','407 SW','605','607','806','807','Expert','Partner'],'Porsche':['Model:','All models','911','928','968','Boxster','Carrera GT','Cayenne','Cayman','Panamera'],'Proton':['Model:','All models','Compact','Coupe','Gen-2','Impian','Mpi','Persona','Persona Compact','Satria','Satria Neo','Savvy','Wira'],'Renault':['Model:','All models','19','5','Avantime','Clio','Espace','Grand Espace','Grand Modus','Grand Scénic','Kangoo','Koleos','Laguna','Mégane','Modus','Safrane','Savanna','Scénic','Spider','Twingo','Vel Satis'],'Rolls-Royce':['Model:','All models','Corniche','Park Ward','Phantom','Silver Dawn','Silver Seraph','Silver Spirit','Silver Spur'],'Rover':['Model:','All models','100 Series','200 Series','25','400 Series','45','600 Series','75','800 Series','Cabriolet','CityRover','Coupe','Metro','Mini','Montego','Streetwise','Tourer'],'Saab':['Model:','All models','900','9000','9-3','9-3x','9-5'],'Scimitar':['Model:','All models','Sabre'],'SEAT':['Model:','All models','Alhambra','Altea','Altea freetrack','Altea XL','Arosa','Cordoba','Exeo','Ibiza','Leon','Toledo'],'Skoda':['Model:','All models','Fabia','Favorit','Felicia','New Fabia','Octavia','Roomster','Superb'],'smart':['Model:','All models','cabrio','city-coupe','crossblade','forfour','fortwo','Roadster'],'Ssangyong':['Model:','All models','Korando','Kyron','Musso','Rexton','Rexton II','Rodius'],'Strathcarron':['Model:','All models','SC-5A'],'Subaru':['Model:','All models','B9 Tribeca','Forester','Impreza','Justy','Legacy','Legacy Outback','Outback','SVX','Tribeca','Vivio'],'Suzuki':['Model:','All models','Alto','Baleno','Cappuccino','Grand Vitara','Grand Vitara XL-7','Ignis','Jimny','Liana','Samurai','Splash','Swift','SX4','Vitara','Wagon R+','X-90'],'Tata':['Model:','All models','Gurkha','Safari','TL'],'Toyota':['Model:','All models','4Runner','Auris','Avensis','Avensis Verso','Aygo','Camry','Carina E','Celica','Corolla','Corolla Verso','Hilux','IQ','Land Cruiser','Land Cruiser Amazon','Land Cruiser Colorado','Landcruiser','Landcruiser Amazon','MR2','Paseo','Picnic','Previa','Prius','RAV4','Starlet','Supra','Urban Cruiser','Verso','Yaris','Yaris Verso'],'TVR':['Model:','All models','Cerbera','Chimaera','Griffith','Sagaris','T350','T400R','T440R','Tamora','Tuscan','Tuscan R'],'Vauxhall':['Model:','All models','Agila','Antara','Astra','Brava','Calibra','Cavalier','Corsa','Frontera','Insignia','Meriva','Monaro','Monterey','Omega','Signum','Sintra','Tigra','Vectra','VX220','VXR8','Zafira'],'Venturi':['Model:','All models','Atlantique'],'Volkswagen':['Model:','All models','Beetle','Bora','Caddy','California','Caravelle','Eos','Fox','Golf','Golf Plus','Jetta','Lupo','Multivan','Passat','Passat CC','Phaeton','Polo','Scirocco','Sharan','Tiguan','Touareg','Touran','Vento'],'Volvo':['Model:','All models','440','460','480','850','940','960','C30','C70','S40','S60','S70','S80','S90','V40','V50','V70','V70 Classic','V70 XC','V90','XC60','XC70','XC90'],'Westfield':['Model:','All models','130','1600','1800','220','Aerosport','FW 400','Mega Roadster','SEiGHT','Sport','Sport 2000','XTR2','XTR4','ZEI']}],"submit":"redirect(this);"}}; function createForm(e) { var frm = document.createElement("form"); frm.ymm = ymm[e.getAttribute("type")]; e.appendChild(frm); frm.appendChild(document.createTextNode("Find a car:")); frm.appendChild(document.createElement("br")); if (3 == frm.ymm.data.length) { year = createDropdown(frm, "year", frm.ymm.data[0], frm.ymm.maxLen); frm.appendChild(document.createElement("br")); make = createDropdown(frm, "make", frm.ymm.data[1][selectedValue1(year)], frm.ymm.maxLen); frm.appendChild(document.createElement("br")); model = createDropdown(frm, "model", frm.ymm.data[2][selectedValue1(make)], frm.ymm.maxLen); model.disabled = true; year.onchange = new Function("resetState(this);"); make.onchange = new Function("resetState(this);"); model.onchange = new Function(frm.ymm.submit); } else if (2 == frm.ymm.data.length) { make = createDropdown(frm, "make", frm.ymm.data[0], frm.ymm.maxLen); frm.appendChild(document.createElement("br")); model = createDropdown(frm, "model", frm.ymm.data[1][selectedValue1(make)], frm.ymm.maxLen); model.disabled = true; make.onchange = new Function("resetState(this);"); model.onchange = new Function(frm.ymm.submit); } } function redirect(e) { if (0 == e.selectedIndex) return; var frm = e.parentNode; var url = (frm.ymm.urls.length > e.selectedIndex) ? url = frm.ymm.urls[e.selectedIndex] : frm.ymm.url; for (var ifield = 0; ifield < frm.elements.length; ifield++) { var regexp = new RegExp("\\{" + ifield + "\\}", "g"); url = url.replace(regexp, encodeURIComponent(selectedValue(frm, ifield))); } window.location.href = url; } buildYmms();