// JavaScript Document function fillMake() { // this function is used to fill the category list on load addOption(document.getElementById('make'), "1", "Alfa Romeo"); addOption(document.getElementById('make'), "2", "Audi"); addOption(document.getElementById('make'), "3", "BMW"); addOption(document.getElementById('make'), "4", "Chevrolet"); addOption(document.getElementById('make'), "5", "Chrysler"); addOption(document.getElementById('make'), "6", "Citroen"); addOption(document.getElementById('make'), "44", "Daihatsu"); addOption(document.getElementById('make'), "42", "Dodge"); addOption(document.getElementById('make'), "8", "Fiat"); addOption(document.getElementById('make'), "9", "Ford"); addOption(document.getElementById('make'), "10", "Honda"); addOption(document.getElementById('make'), "11", "Hyundai"); addOption(document.getElementById('make'), "12", "Jaguar"); addOption(document.getElementById('make'), "14", "Kia"); addOption(document.getElementById('make'), "15", "Land Rover"); addOption(document.getElementById('make'), "17", "Lexus"); addOption(document.getElementById('make'), "19", "Mazda"); addOption(document.getElementById('make'), "20", "Mercedes-Benz"); addOption(document.getElementById('make'), "21", "MG"); addOption(document.getElementById('make'), "22", "Mini"); addOption(document.getElementById('make'), "23", "Mitsubishi"); addOption(document.getElementById('make'), "24", "Nissan"); addOption(document.getElementById('make'), "25", "Peugeot"); addOption(document.getElementById('make'), "27", "Proton"); addOption(document.getElementById('make'), "28", "Renault"); addOption(document.getElementById('make'), "30", "Saab"); addOption(document.getElementById('make'), "31", "Seat"); addOption(document.getElementById('make'), "32", "Skoda"); addOption(document.getElementById('make'), "33", "Smart"); addOption(document.getElementById('make'), "36", "Suzuki"); addOption(document.getElementById('make'), "37", "Toyota"); addOption(document.getElementById('make'), "38", "Vauxhall"); addOption(document.getElementById('make'), "39", "Volkswagen"); addOption(document.getElementById('make'), "40", "Volvo"); } function fillOptions() { // this function is used to fill the all the options //addOption(document.usedcarsearch.transmission, "", "Any Transmission..."); addOption(document.getElementById('transmission'), "Manual", "Manual"); addOption(document.getElementById('transmission'), "Automatic", "Automatic"); //addOption(document.usedcarsearch.mileage, "", "Any Mileage..."); addOption(document.getElementById('mileage'), "600", "Delivery Mileage"); addOption(document.getElementById('mileage'), "5000", "Up to 5,000 miles"); addOption(document.getElementById('mileage'), "10000", "Up to 10,000 miles"); addOption(document.getElementById('mileage'), "15000", "Up to 15,000 miles"); addOption(document.getElementById('mileage'), "20000", "Up to 20,000 miles"); addOption(document.getElementById('mileage'), "25000", "Up to 25,000 miles"); addOption(document.getElementById('mileage'), "30000", "Up to 30,000 miles"); //addOption(document.usedcarsearch.maxprice, "", "Any Max Price..."); addOption(document.getElementById('minprice'), "1000", "From £1,000"); addOption(document.getElementById('minprice'), "2000", "From £2,000"); addOption(document.getElementById('minprice'), "3000", "From £3,000"); addOption(document.getElementById('minprice'), "4000", "From £4,000"); addOption(document.getElementById('minprice'), "5000", "From £5,000"); addOption(document.getElementById('minprice'), "6000", "From £6,000"); addOption(document.getElementById('minprice'), "7000", "From £7,000"); addOption(document.getElementById('minprice'), "8000", "From £8,000"); addOption(document.getElementById('minprice'), "9000", "From £9,000"); addOption(document.getElementById('minprice'), "10000", "From £10,000"); addOption(document.getElementById('minprice'), "11000", "From £11,000"); addOption(document.getElementById('minprice'), "12000", "From £12,000"); addOption(document.getElementById('minprice'), "13000", "From £13,000"); addOption(document.getElementById('minprice'), "14000", "From £14,000"); addOption(document.getElementById('minprice'), "15000", "From £15,000"); addOption(document.getElementById('minprice'), "20000", "From £20,000"); addOption(document.getElementById('minprice'), "25000", "From £25,000"); addOption(document.getElementById('minprice'), "30000", "From £30,000"); addOption(document.getElementById('minprice'), "35000", "From £35,000"); addOption(document.getElementById('minprice'), "40000", "From £40,000"); addOption(document.getElementById('minprice'), "45000", "From £45,000"); addOption(document.getElementById('minprice'), "50000", "From £50,000"); addOption(document.getElementById('maxprice'), "1000", "Up to £1,000"); addOption(document.getElementById('maxprice'), "2000", "Up to £2,000"); addOption(document.getElementById('maxprice'), "3000", "Up to £3,000"); addOption(document.getElementById('maxprice'), "4000", "Up to £4,000"); addOption(document.getElementById('maxprice'), "5000", "Up to £5,000"); addOption(document.getElementById('maxprice'), "6000", "Up to £6,000"); addOption(document.getElementById('maxprice'), "7000", "Up to £7,000"); addOption(document.getElementById('maxprice'), "8000", "Up to £8,000"); addOption(document.getElementById('maxprice'), "9000", "Up to £9,000"); addOption(document.getElementById('maxprice'), "10000", "Up to £10,000"); addOption(document.getElementById('maxprice'), "11000", "Up to £11,000"); addOption(document.getElementById('maxprice'), "12000", "Up to £12,000"); addOption(document.getElementById('maxprice'), "13000", "Up to £13,000"); addOption(document.getElementById('maxprice'), "14000", "Up to £14,000"); addOption(document.getElementById('maxprice'), "15000", "Up to £15,000"); addOption(document.getElementById('maxprice'), "20000", "Up to £20,000"); addOption(document.getElementById('maxprice'), "25000", "Up to £25,000"); addOption(document.getElementById('maxprice'), "30000", "Up to £30,000"); addOption(document.getElementById('maxprice'), "35000", "Up to £35,000"); addOption(document.getElementById('maxprice'), "40000", "Up to £40,000"); addOption(document.getElementById('maxprice'), "45000", "Up to £45,000"); addOption(document.getElementById('maxprice'), "50000", "Up to £50,000"); //addOption(document.usedcarsearch.fuel, "", "Any Fuel..."); addOption(document.getElementById('fuel'), "Petrol", "Petrol"); addOption(document.getElementById('fuel'), "Diesel", "Diesel"); //addOption(document.usedcarsearch.sortby, "priceasc", "Price: Ascending"); //addOption(document.usedcarsearch.sortby, "pricedesc", "Price: Decending"); //addOption(document.usedcarsearch.sortby, "mileageasc", "Mileage: Ascending"); //addOption(document.usedcarsearch.sortby, "mileagedesc", "Mileage: Decending"); } function refreshModels() { // ON selection of category this function will work if (document.getElementById('model') && document.getElementById('model') != "undefined") { removeAllOptions(document.getElementById('model')); addOption(document.getElementById('model'), "", "Any Model..."); if (document.getElementById('make') && document.getElementById('make') != "undefined") { if(document.getElementById('make').value == "1"){ addOption(document.getElementById('model'),"243", "Brera"); addOption(document.getElementById('model'),"4", "GT"); addOption(document.getElementById('model'),"265", "Mito"); addOption(document.getElementById('model'),"5", "Spider"); } if(document.getElementById('make').value == "2"){ addOption(document.getElementById('model'),"6", "A3"); addOption(document.getElementById('model'),"7", "A4"); addOption(document.getElementById('model'),"9", "TT"); } if(document.getElementById('make').value == "3"){ addOption(document.getElementById('model'),"10", "1 Series"); addOption(document.getElementById('model'),"11", "3 Series"); addOption(document.getElementById('model'),"12", "5 Series"); addOption(document.getElementById('model'),"283", "X5"); } if(document.getElementById('make').value == "4"){ addOption(document.getElementById('model'),"16", "Captiva"); addOption(document.getElementById('model'),"313", "Cruze"); addOption(document.getElementById('model'),"303", "Spark"); } if(document.getElementById('make').value == "5"){ addOption(document.getElementById('model'),"255", "Sebring"); } if(document.getElementById('make').value == "6"){ addOption(document.getElementById('model'),"24", "Berlingo"); addOption(document.getElementById('model'),"25", "C1"); addOption(document.getElementById('model'),"26", "C2"); addOption(document.getElementById('model'),"27", "C3"); addOption(document.getElementById('model'),"311", "C3 Picasso"); addOption(document.getElementById('model'),"29", "C4"); addOption(document.getElementById('model'),"30", "C4 Grand Picasso"); addOption(document.getElementById('model'),"31", "C4 Picasso"); addOption(document.getElementById('model'),"32", "C5"); addOption(document.getElementById('model'),"250", "Dispatch"); addOption(document.getElementById('model'),"328", "Nemo"); addOption(document.getElementById('model'),"35", "Picasso"); } if(document.getElementById('make').value == "8"){ addOption(document.getElementById('model'),"38", "500"); addOption(document.getElementById('model'),"39", "Bravo"); addOption(document.getElementById('model'),"41", "Doblo"); addOption(document.getElementById('model'),"42", "Grande Punto"); addOption(document.getElementById('model'),"44", "Panda"); addOption(document.getElementById('model'),"45", "Punto"); addOption(document.getElementById('model'),"292", "Punto Evo"); addOption(document.getElementById('model'),"310", "Qubo"); } if(document.getElementById('make').value == "9"){ addOption(document.getElementById('model'),"52", "C-Max"); addOption(document.getElementById('model'),"49", "Fiesta"); addOption(document.getElementById('model'),"50", "Focus"); addOption(document.getElementById('model'),"53", "Fusion"); addOption(document.getElementById('model'),"54", "Galaxy"); addOption(document.getElementById('model'),"327", "Grand C-Max"); addOption(document.getElementById('model'),"55", "Ka"); addOption(document.getElementById('model'),"56", "Kuga"); addOption(document.getElementById('model'),"57", "Mondeo"); addOption(document.getElementById('model'),"58", "Ranger"); addOption(document.getElementById('model'),"277", "SportKa"); } if(document.getElementById('make').value == "10"){ addOption(document.getElementById('model'),"65", "Civic"); addOption(document.getElementById('model'),"66", "CR-V"); addOption(document.getElementById('model'),"68", "Jazz"); addOption(document.getElementById('model'),"298", "S2000"); } if(document.getElementById('make').value == "11"){ addOption(document.getElementById('model'),"70", "Coupe"); addOption(document.getElementById('model'),"288", "i20"); addOption(document.getElementById('model'),"281", "i30"); addOption(document.getElementById('model'),"332", "ix35"); addOption(document.getElementById('model'),"74", "Tucson"); } if(document.getElementById('make').value == "12"){ addOption(document.getElementById('model'),"77", "X-Type"); addOption(document.getElementById('model'),"259", "XF"); addOption(document.getElementById('model'),"339", "XFR"); addOption(document.getElementById('model'),"282", "XKR"); } if(document.getElementById('make').value == "14"){ addOption(document.getElementById('model'),"80", "Carens"); addOption(document.getElementById('model'),"81", "Cee'd"); addOption(document.getElementById('model'),"264", "Pro Cee'd"); addOption(document.getElementById('model'),"86", "Sedona"); addOption(document.getElementById('model'),"272", "Soul"); addOption(document.getElementById('model'),"88", "Sportage"); } if(document.getElementById('make').value == "15"){ addOption(document.getElementById('model'),"91", "Discovery 3"); addOption(document.getElementById('model'),"254", "Freelander 2"); addOption(document.getElementById('model'),"93", "Range Rover"); } if(document.getElementById('make').value == "17"){ addOption(document.getElementById('model'),"98", "IS Series"); } if(document.getElementById('make').value == "19"){ addOption(document.getElementById('model'),"106", "2"); addOption(document.getElementById('model'),"107", "3"); addOption(document.getElementById('model'),"108", "5"); addOption(document.getElementById('model'),"109", "6"); addOption(document.getElementById('model'),"110", "MX-5"); addOption(document.getElementById('model'),"111", "RX-8"); } if(document.getElementById('make').value == "20"){ addOption(document.getElementById('model'),"113", "B Class"); addOption(document.getElementById('model'),"114", "C Class"); addOption(document.getElementById('model'),"116", "CLC Class"); addOption(document.getElementById('model'),"117", "CLK Class"); addOption(document.getElementById('model'),"119", "E Class"); addOption(document.getElementById('model'),"127", "SLK Class"); } if(document.getElementById('make').value == "21"){ addOption(document.getElementById('model'),"267", "TF"); } if(document.getElementById('make').value == "22"){ addOption(document.getElementById('model'),"134", "Cooper"); addOption(document.getElementById('model'),"135", "Cooper S"); addOption(document.getElementById('model'),"136", "One"); } if(document.getElementById('make').value == "23"){ addOption(document.getElementById('model'),"137", "Colt"); addOption(document.getElementById('model'),"139", "Lancer"); addOption(document.getElementById('model'),"262", "Outlander"); addOption(document.getElementById('model'),"140", "Shogun"); } if(document.getElementById('make').value == "24"){ addOption(document.getElementById('model'),"141", "350Z"); addOption(document.getElementById('model'),"324", "Cube"); addOption(document.getElementById('model'),"337", "Juke"); addOption(document.getElementById('model'),"143", "Micra"); addOption(document.getElementById('model'),"145", "Note"); addOption(document.getElementById('model'),"149", "Qashqai"); } if(document.getElementById('make').value == "25"){ addOption(document.getElementById('model'),"153", "107"); addOption(document.getElementById('model'),"155", "207"); addOption(document.getElementById('model'),"338", "207 CC"); addOption(document.getElementById('model'),"312", "3008"); addOption(document.getElementById('model'),"156", "307"); addOption(document.getElementById('model'),"157", "308"); addOption(document.getElementById('model'),"307", "5008"); addOption(document.getElementById('model'),"160", "807"); addOption(document.getElementById('model'),"162", "Partner"); } if(document.getElementById('make').value == "27"){ addOption(document.getElementById('model'),"280", "Satria Neo"); } if(document.getElementById('make').value == "28"){ addOption(document.getElementById('model'),"165", "Clio"); addOption(document.getElementById('model'),"268", "Grand Modus"); addOption(document.getElementById('model'),"167", "Grand Scenic"); addOption(document.getElementById('model'),"168", "Kangoo"); addOption(document.getElementById('model'),"256", "Koleos"); addOption(document.getElementById('model'),"169", "Laguna"); addOption(document.getElementById('model'),"170", "Megane"); addOption(document.getElementById('model'),"260", "Megane CC"); addOption(document.getElementById('model'),"172", "Scenic"); } if(document.getElementById('make').value == "30"){ addOption(document.getElementById('model'),"177", "9-3"); addOption(document.getElementById('model'),"178", "9-5"); } if(document.getElementById('make').value == "31"){ addOption(document.getElementById('model'),"181", "Ibiza"); addOption(document.getElementById('model'),"182", "Leon"); } if(document.getElementById('make').value == "32"){ addOption(document.getElementById('model'),"183", "Fabia"); addOption(document.getElementById('model'),"184", "Octavia"); addOption(document.getElementById('model'),"330", "Yeti"); } if(document.getElementById('make').value == "33"){ addOption(document.getElementById('model'),"188", "fortwo"); } if(document.getElementById('make').value == "36"){ addOption(document.getElementById('model'),"276", "Splash"); addOption(document.getElementById('model'),"197", "Swift"); addOption(document.getElementById('model'),"198", "SX4"); } if(document.getElementById('make').value == "37"){ addOption(document.getElementById('model'),"200", "Auris"); addOption(document.getElementById('model'),"201", "Avensis"); addOption(document.getElementById('model'),"202", "Aygo"); addOption(document.getElementById('model'),"204", "Corolla"); addOption(document.getElementById('model'),"205", "Corolla Verso"); addOption(document.getElementById('model'),"297", "iQ"); addOption(document.getElementById('model'),"209", "Prius"); addOption(document.getElementById('model'),"320", "Verso"); } if(document.getElementById('make').value == "38"){ addOption(document.getElementById('model'),"213", "Astra"); addOption(document.getElementById('model'),"215", "Corsa"); addOption(document.getElementById('model'),"253", "Insignia"); addOption(document.getElementById('model'),"216", "Meriva"); addOption(document.getElementById('model'),"219", "Tigra"); addOption(document.getElementById('model'),"220", "Vectra"); addOption(document.getElementById('model'),"222", "Zafira"); } if(document.getElementById('make').value == "39"){ addOption(document.getElementById('model'),"226", "Eos"); addOption(document.getElementById('model'),"228", "Golf"); addOption(document.getElementById('model'),"230", "Passat"); addOption(document.getElementById('model'),"231", "Polo"); addOption(document.getElementById('model'),"331", "Scirocco"); addOption(document.getElementById('model'),"289", "Tiguan"); addOption(document.getElementById('model'),"234", "Touran"); } if(document.getElementById('make').value == "40"){ addOption(document.getElementById('model'),"274", "C30"); addOption(document.getElementById('model'),"236", "S40"); addOption(document.getElementById('model'),"239", "V50"); addOption(document.getElementById('model'),"240", "V70"); addOption(document.getElementById('model'),"241", "XC70"); } if(document.getElementById('make').value == "42"){ addOption(document.getElementById('model'),"305", "Journey"); } if(document.getElementById('make').value == "44"){ addOption(document.getElementById('model'),"271", "Terios"); } } } } function removeAllOptions(selectbox) { var i; for(i=selectbox.options.length-1;i>=0;i--) { //selectbox.options.remove(i); selectbox.remove(i); } } function addOption(selectbox, value, text, selected) { var optn = document.createElement("OPTION"); optn.text = text; optn.value = value; if(selected){ optn.setAttribute("selected","selected"); } if (selectbox && selectbox != "undefined") { selectbox.options.add(optn); } } function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); } } } function autoSelect() { if (document.getElementById('make') && document.getElementById('make') != "undefined") { findSelected(document.getElementById('make'), "Make"); } findSelected(document.getElementById('model'), "Model"); findSelected(document.getElementById('transmission'), "Transmission"); findSelected(document.getElementById('fuel'), "Fuel"); findSelected(document.getElementById('mileage'), "Mileage"); findSelected(document.getElementById('minprice'), "MinPrice"); findSelected(document.getElementById('maxprice'), "MaxPrice"); findSelected(document.getElementById('sortby'), "SortBy"); } function findSelected(listbox, searchname) { if (listbox && listbox != "undefined") { var searchvalue = getSubstringValue(searchname); for (var x = 0; x < listbox.options.length; x++) { if (listbox.options[x].value == searchvalue) { listbox.options[x].selected = true; } } } } function getSubstringValue(searchname) { var fullsubstring = location.search.substring(1); var splitsubstring = fullsubstring.split("&"); var varname = new Array(); var varvalue = new Array(); for(var i=0;i