var makes = new Array(); //var models = new Array(); //var details = new Array(); addMake(0,'All'); addModel(0,'All'); // addDetail("All",0,"All"); addMake(1,"ACURA"); addModel(1,"INTEGRA"); addModel(1,"RSX"); addModel(1,"TSX"); addModel(1,"3.5 RL"); addModel(1,"TL NAVIGATION"); addModel(1,"TL"); addModel(1,"MDX"); addMake(7,"AUDI"); addModel(7,"A3 2.0L"); addModel(7,"A6"); addModel(7,"A8"); addModel(7,"A4"); addMake(11,"BMW"); addModel(11,"528I"); addModel(11,"325I"); addModel(11,"325XI"); addModel(11,"X3"); addModel(11,"X5"); addModel(11,"335I"); addMake(16,"BUICK"); addModel(16,"RENDEZVOUS"); addMake(17,"CADILLAC"); addModel(17,"STS"); addMake(19,"CHEVROLET"); addModel(19,"150"); addModel(19,"TRAILBLAZER"); addMake(20,"CHRYSLER"); addModel(20,"300"); addModel(20,"PASIFICA"); addMake(34,"FORD"); addModel(34,"F-150 4X4"); addModel(34,"ESCAPE"); addMake(41,"HONDA"); addModel(41,"CRV"); addModel(41,"ACCORD"); addModel(41,"ODYSSEY"); addModel(41,"CIVIC"); addModel(41,"PILOT EXL"); addMake(43,"HYUNDAI"); addModel(43,"SANTA"); addModel(43,"SONATA"); addMake(44,"INFINITI"); addModel(44,"G35X AWD"); addModel(44,"G35"); addModel(44,"M35X"); addModel(44,"FX 35"); addMake(51,"KIA"); addModel(51,"SORENTO"); addMake(55,"LEXUS"); addModel(55,"RX 330"); addModel(55,"RX 400H"); addModel(55,"ES350"); addModel(55,"ES330"); addModel(55,"IS 250"); addModel(55,"GS300"); addModel(55,"GX470"); addMake(56,"LINCOLN"); addModel(56,"LS"); addMake(59,"MAZDA"); addModel(59,"MAZDA 3"); addModel(59,"MILLENIA"); addMake(60,"MERCEDES-BENZ"); addModel(60,"E320"); addModel(60,"300SL"); addModel(60,"C230"); addModel(60,"CLK 350"); addModel(60,"ML350"); addModel(60,"ML320"); addModel(60,"C320"); addModel(60,"C240"); addModel(60,"SL500"); addModel(60,"S500"); addMake(64,"MITSUBISHI"); addModel(64,"PLUS 4"); addMake(68,"NISSAN"); addModel(68,"SENTRA"); addModel(68,"MURANO"); addModel(68,"PATHFINDER"); addModel(68,"ARMADA"); addModel(68,"XTRIAL"); addModel(68,"MAXIMA"); addModel(68,"ALTIMA"); addMake(86,"SUBARU"); addModel(86,"FE"); addMake(88,"SUZUKI"); addModel(88,"VITARA"); addMake(89,"TOYOTA"); addModel(89,"CAMRY"); addModel(89,"HIGHLANDER"); addModel(89,"PRIUS"); addModel(89,"SIENNA"); addModel(89,"COROLLA"); addModel(89,"SOLARA"); addModel(89,"FJ CRUISER"); addModel(89,"MATRIX"); addModel(89,"AVALON"); addMake(93,"VOLKSWAGEN"); addModel(93,"JETTA"); addModel(93,"TOUAREG"); addMake(97,"JEEP"); addModel(97,"COMENDER"); addModel(97,"GRAND CHEROKEE"); addModel(97,"TJ"); addMake(102,"MIINI"); addModel(102,"COOPER"); addMake(106,"LAND ROVER"); addModel(106,"LR3"); /************************************************** * make constructor is just holds the makes index * **************************************************/ function _make(make_index){ this.make_index = make_index; } /************************************************** * Create new Make and added it as an object to * * makes array. * **************************************************/ function addMake(make_index,make_name){ _make[make_name] = new _make(make_index); makes[make_index] = new _createMake(make_name,make_index); } /************************************************** * Create Make Constructor * **************************************************/ function _createMake(make_name,make_index){ this.make_name = make_name; this.make_index = make_index; this.models = new Array(); } /************************************************** * Create new model and added to models array in * * makes array. * **************************************************/ function addModel(model_index,model_name){ makes[model_index].models[model_name] = new _createModel(model_name,model_index); } /************************************************** * Add Model Constructor * **************************************************/ function _createModel(model_name,model_index){ this.model_name = model_name; this.model_index = model_index; this.details = new Array(); } /************************************************** * Create new detail and added to detail array in * * makes array. * **************************************************/ function addDetail(model_name,detail_index,detail_name){ makes[detail_index].models[model_name].details[detail_name] = new _createDetail(detail_name,detail_index); } /************************************************** * Add Detail Constructor * **************************************************/ function _createDetail(detail_name,detail_index){ this.detail_name = detail_name; this.detail_index = detail_index; } /* addMake(1,"dsfsdmaziar"); addModel(1,"hello"); addMake(2,"maziar"); addModel(2,"masoudi"); //addDetail("masoudi",2,"LX"); addMake(3,"ACURA"); addModel(3,"1.6 EL"); addDetail("1.6 EL",3,"SL"); */ //alert(makes[1].models['test'].details['LX'].detail_index); /************************************************** * Load the make menu when page is loaded * **************************************************/ function fillMake(){ var i = 0; try{ document.forms[0].make.options.length = 0; document.forms[0].make.options.selectedIndex = 0; var selectedMake = (makes); for(aMake in selectedMake){ var m_index = selectedMake[aMake].make_index; var m_name = selectedMake[aMake].make_name; document.forms[0].make.options[i++] = new Option(m_name, m_index); } document.forms[0].make.options[0].selected = true; }catch(e){ // alert(e); } //alert(0); } /************************************************** * Load the model menu when make menu is changed* **************************************************/ function fillModel(){ var i = 1; var msg; var menuIndex = document.forms[0].make.selectedIndex; var makeIndex = document.forms[0].make.options[document.forms[0].make.selectedIndex].value; //alert(document.forms[0].make.options[document.forms[0].make.selectedIndex].value); document.forms[0].make.options[menuIndex].selected = true; document.forms[0].model.options.length = 1;//(makeIndex == 0) ? 0 : 1; document.forms[0].model.options.selectedIndex = 0; //alert(makeIndex + " and length is " + document.forms[0].model.options.length); var selectedMake = (makes[makeIndex].models); for(t in selectedMake){ var mo_name = (selectedMake[t].model_name); var mo_index = (selectedMake[t].model_index); document.forms[0].model.options[i++] = new Option(mo_name,mo_index); } } /**************************************************** * Load the detail menu when model menu is changed* ****************************************************/ function fillDetail(){ var i = 1; var msg = ""; // var makeIndex = document.search.make.selectedIndex; // var modelIndex = document.search.model.options[document.search.model.selectedIndex].text; var makeIndex = document.search.make.options[document.search.make.selectedIndex].value; var modelIndex = document.search.model.options[document.search.model.selectedIndex].text; document.search.detail.options.length = 1; document.search.detail.options.selectedIndex = 0; var selectedModel = (makes[makeIndex].models[modelIndex].details); for(d in selectedModel){ var d_name = selectedModel[d].detail_name; var d_index = selectedModel[d].detail_index; document.search.detail.options[i++] = new Option(d_name,d_index); } if(document.search.detail.options[1].text == "None") document.search.detail.options[1].selected = true; } function debug(){ var msg = ""; for(m in makes){ msg += makes[m].make_name + " " +makes[m].make_index + "\n"; var model = (makes[m].models) for(mo in model){ msg += makes[m].models[mo].model_name + makes[m].models[mo].model_index + "\n"; } } alert(msg); }