Critere.prototype.constructor = Critere; function Critere(curcat,brand,model,min_price,max_price,min_yearmodel,max_yearmodel,mileage,cubic,energy,color,gearbox,ss_cat,advanced, mainzone){ this.curcat = curcat; this.prefered_brand = (brand?brand.toUpperCase():''); this.prefered_model = (model?model.toUpperCase():''); this.prefered_min_price = min_price; this.prefered_max_price = max_price; this.prefered_min_yearmodel = min_yearmodel; this.prefered_max_yearmodel = max_yearmodel; this.prefered_mileage = mileage; if (cubic) { var T = cubic.split(/\|/); this.prefered_min_cubic = T[0]; this.prefered_max_cubic = T[1]; } else { this.prefered_min_cubic = ''; this.prefered_max_cubic = ''; } this.energy = energy; this.color = color; this.gearbox = gearbox; this.advanced=advanced; this.vpmainzone= mainzone; this.ss_cat=(ss_cat!=null ? ss_cat:''); this.combo_brand = document.getElementById('brand'); this.countbrand = 0; this.combo_model = document.getElementById('model'); this.combo_prix_maxi = document.getElementById('prix_maxi'); this.combo_prix_mini = document.getElementById('prix_mini'); this.combo_yearmodel_maxi = document.getElementById('yearmodel_maxi'); this.combo_yearmodel_mini = document.getElementById('yearmodel_mini'); this.combo_region = document.getElementById('cp'); this.combo_mileage = document.getElementById('mileage'); this.combo_puissance = document.getElementById('pfisc'); this.combo_co2 = document.getElementById('amount'); this.combo_version = document.getElementById('DynVersionReload'); this.combo_min_cubic = document.getElementById('min_cubic'); this.combo_max_cubic = document.getElementById('max_cubic'); this.hidden_cubic = document.getElementById('cubic'); this.input_cp = document.getElementById('cp'); this.checkbox_dpt = document.getElementById('departement'); this.combo_Energy = document.getElementById('energie'); this.combo_color = document.getElementById('couleur'); this.combo_gearbox = document.getElementById('gearbox'); this.WhatCatT = (document.getElementById('WhatCatT') != null ? document.getElementById('WhatCatT').value : null); this.marque = new Array(); this.ss_cat_found = ';'; this.isDev = false; this.isRec = false; this.isProd = false; if (window.location.href.match(new RegExp('\.lacentrale\.dev'))) { this.isDev = true; this.pathStatic = '/'; //window.location.href.replace(new RegExp('^[^.]*\.([^.]*\.lacentrale\.dev/).*$'),'http://dev-lc-static.$1'); } else if (window.location.href.match(new RegExp('srvwrec')) || window.location.href.match(new RegExp('192\.168\.1\.4'))) { this.isRec = true; this.pathStatic = 'http://srvwrec:81/'; } else { this.isProd = true; this.pathStatic = 'http://static.lacentrale.fr/'; } if(curcat=='auto') this.ob_cat = new Category(curcat,'re',(this.ss_cat!='' ? this.ss_cat:'40,41,42,43,44,45,46,47,48,49')); else if(curcat=='moto'&&this.advanced) this.ob_cat = new Category(curcat,'re',(this.ss_cat!='' ? this.ss_cat:'60,61,62,63,64,65,66,67,68,69,72')); else if(curcat=='utils') this.ob_cat = new Category(curcat,'re',(this.ss_cat!='' ? this.ss_cat:'80,81,82,83,84')); else if(curcat=='loisir') this.ob_cat = new Category(curcat,'re',(this.ss_cat!='' ? this.ss_cat:'506,507,508,510,423')); this.Init_static_marque(); if (this.curcat!='od') { if(this.WhatCatT!=null) { this.CatChange(this.WhatCatT); } this.fill_make(); //this.fill_min_price(); if(this.vpmainzone == 'tz_main_home.php'){ this.fill_max_price(); } /*if (this.combo_yearmodel_mini) this.fill_min_yearmodel(); if (this.combo_yearmodel_maxi) this.fill_max_yearmodel(); if (this.combo_mileage) this.fill_mileage();*/ if (this.combo_min_cubic && this.combo_max_cubic) { this.fill_cubic(); } } this.Init(); } //------------------partie publique-----------------------// Critere.prototype.Init_static_marque = function(){ var i; for(i=0;i< this.combo_brand.length;i++) this.marque[i]=this.combo_brand.options[i]; } Critere.prototype.Init = function() { this.fill_region(); this.fill_energy(); this.fill_color(); this.fill_gearbox(); this.check_crit_categorie(); } Critere.prototype.MakeChange = function() { this.setPrefBrand(); this.fill_model(); this.clearVersion(); } Critere.prototype.CatChange = function(curcat) { if(curcat)this.curcat = curcat; this.fill_make(); this.clearVersion(); this.check_crit_categorie(); if (this.combo_min_cubic && this.combo_max_cubic) this.fill_cubic(); document.form.action = (document.getElementById('galerie')? 'galerie_':'listing_')+(this.curcat=='loisir'?'camping_car-caravane':(this.curcat=='utils'?'utilitaire':this.curcat))+'.php'; } Critere.prototype.ModelChange = function() { this.setPrefModel(); this.clearVersion(); } Critere.prototype.MaxPriceChange = function() { this.setPrefMaxPrice(); } Critere.prototype.MinPriceChange = function() { this.fill_max_price(); } Critere.prototype.MaxCubicChange = function() { this.setPrefMaxCubic(); } Critere.prototype.MinCubicChange = function() { this.setPrefMinCubic(); this.fill_cubic(); } Critere.prototype.MaxYearmodelChange = function() { this.setPrefMaxYearmodel(); } Critere.prototype.MinYearmodelChange = function() { this.setPrefMinYearmodel(); this.fill_max_yearmodel(); } Critere.prototype.PuissanceChange = function() { if(this.combo_puissance.value)this.combo_puissance.value.indexOf('|') != -1 ? this.combo_puissance.name='pdin' : this.combo_puissance.name='pfisc'; } Critere.prototype.CO2Load = function(value) { var co2_array = new Array('', '90', '150','180'); for(i=1;i0 && Tres.length>0 && Tcp[i].length==0)Tres[Tres.length]=Tcp[i]; else if(/^[0-9][0-9]$/.test(Tcp[i]))Tres[Tres.length]=Tcp[i]; else if(/^[0-9]$/.test(Tcp[i]))Tres[Tres.length]=Tcp[i]; else if(/^(2A|2B|[A-Z]|[A-Z][A-Z])$/.test(Tcp[i]))Tres[Tres.length]=Tcp[i]; } for(i in Tres){ j=(parseInt(i)+1); while(j0 || res=='2A' || res=='2B'); } Critere.prototype.go_and_submit = function() { if(!document.form)return; if(this.input_cp!=null)this.input_cp.value=this.input_cp.value.replace(/,$/,''); if(this.combo_co2!=null && (this.curcat=='auto' || this.curcat=='utils')){ if(this.combo_co2.value != 0){ var co2_array = new Array('', '90', '150','180'); this.combo_co2.value = co2_array[this.combo_co2.value]; } else { this.combo_co2.value = ''; } } this.check_dpt('efface'); this.calc_cubic(); // Ajout d'une image pour comptabiliser les options selectionnees - Le "s" est celui de la dev, comme demandé dans TMACLASSIFIED-1851 if(sF1){ var sUrlOpt = "http://logi11.xiti.com/hit.xiti?s=501013&s2=0&p=Recherche::bouton_listing&f1=[" + encodeURIComponent(sF1) + "]"; $("body").append(''); } document.form.submit(); } Critere.prototype.SubmitAdvanced = function() { var adresse = ''; if (CBM.homeSearch) { if (CBM.homeSearch.getDimensions()['x'] <= CBM.homeSearch.params.mobileLimit) { adresse = 'searchMobile.php?curCat=' + this.curcat + '&'; } else { adresse = 'listing_' + (this.curcat == 'loisir' ? 'camping_car-caravane' : (this.curcat == 'utils' ? 'utilitaire' : this.curcat)) + '.php?'; } } var cat=this.get_cat(); adresse = adresse + 'SS_CATEGORIE=' + cat; if (this.combo_brand) adresse = adresse + '&marque=' + this.combo_brand.options[this.combo_brand.selectedIndex].value; if (this.combo_model) adresse = adresse + '&modele=' + this.combo_model.options[this.combo_model.selectedIndex].value; if (document.getElementById('cp')) adresse = adresse + '&cp=' + document.getElementById('cp').options[document.getElementById('cp').selectedIndex].value; if (this.combo_prix_maxi) adresse = adresse + '&prix_maxi=' + this.combo_prix_maxi.options[this.combo_prix_maxi.selectedIndex].value; /*if (this.combo_prix_mini) adresse = adresse + '&prix_mini=' + this.combo_prix_mini.options[this.combo_prix_mini.selectedIndex].value;*/ if (document.getElementById('energie')) adresse = adresse + '&energie=' + document.getElementById('energie').options[document.getElementById('energie').selectedIndex].value; adresse = adresse + '&advanced=1'; window.location = adresse; } Critere.prototype.set_region = function(idx){ /*selecting a region*/ this.combo_region.selectedIndex = idx; } Critere.prototype.fill_region = function(){ if(!this.combo_region || !this.combo_region.options)return; var Tregion = new Array(new Array('Région',''), //new Array('Alsace','67,68,DE'),new Array('Aquitaine','24,33,40,47,64,ES'), new Array('Alsace','67,68'),new Array('Aquitaine','24,33,40,47,64'), new Array('Auvergne','03,15,43,63'),new Array('Basse Normandie','14,50,61'), new Array('Bourgogne','21,58,71,89'),new Array('Bretagne','22,29,35,56'), //new Array('Centre','18,28,36,37,41,45'),new Array('Champagne Ardenne','08,10,51,52,BE'), new Array('Centre','18,28,36,37,41,45'),new Array('Champagne Ardenne','08,10,51,52'), //new Array('Corse','2A,2B,20'),new Array('Franche Comte','25,39,70,90,CH'), new Array('Corse','2A,2B,20'),new Array('Franche Comte','25,39,70,90'), new Array('Haute Normandie','27,76'),new Array('Ile De France','75,77,78,91,92,93,94,95'), //new Array('Languedoc Roussillon','11,30,34,48,66,ES'),new Array('Limousin','19,23,87'), new Array('Languedoc Roussillon','11,30,34,48,66'),new Array('Limousin','19,23,87'), //new Array('Lorraine','54,55,57,88,LU'),new Array('Midi-Pyrenées','09,12,31,32,46,65,81,82,ES'), new Array('Lorraine','54,55,57,88'),new Array('Midi-Pyrenées','09,12,31,32,46,65,81,82'), //new Array('Nord Pas De Calais','59,62,BE'),new Array('Pays De La Loire','44,49,53,72,85'),/ new Array('Nord Pas De Calais','59,62'),new Array('Pays De La Loire','44,49,53,72,85'), new Array('Picardie','02,60,80'),new Array('Poitou Charentes','16,17,79,86'), //new Array('Provence alpes cote d\'azur','04,05,06,13,83,84,98,IT'), new Array('Provence alpes cote d\'azur','04,05,06,13,83,84,98'), //new Array('Rhone Alpes','01,07,26,38,42,69,73,74,CH,IT') new Array('Rhone Alpes','01,07,26,38,42,69,73,74') ); for(var i=0;i ((min_cubic > 0) ? parseInt(min_cubic, 10) : 0)) { this.combo_max_cubic.options[max_len++] = new Option ( format(labelCubicMoto[i]) + ' cm3 maxi.' , labelCubicMoto[i] ); if(this.prefered_max_cubic && labelCubicMoto[i] == this.prefered_max_cubic) { this.combo_max_cubic.options[max_len - 1].selected = true; } } } } Critere.prototype.calc_cubic = function() { if (this.curcat!='moto' && this.curcat!='quad' && this.curcat!='scooter') return; if (this.combo_max_cubic && this.combo_min_cubic && (this.combo_min_cubic.selectedIndex > 0 || this.combo_max_cubic.selectedIndex > 0)) this.hidden_cubic.value = this.combo_min_cubic.value+'|'+this.combo_max_cubic.value; else this.hidden_cubic.value = ''; } Critere.prototype.check_crit_categorie = function() { var T_champs = new Array('couleur','energie','mileage','gearbox','warranty','nb_beds','nb_seats','length','width','yearmodel_mini','yearmodel_maxi','brand','model','mileage','pfisc'); var T_disable = new Array(); var classe=''; T_disable[0] = new Array('423,425|423|425|426|427|428|84','energie|gearbox'); T_disable[1] = new Array('426','yearmodel_maxi|yearmodel_mini|couleur'); T_disable[2] = new Array('426|427|428','warranty|nb_seats|length|width|version|brand|model|mileage'); T_disable[3] = new Array('423,425|423|425','warranty|nb_seats|length|width|version|mileage|pfisc'); var i,j; var cat=this.get_cat(); for (i=0;i0) return; document.getElementById('brand').disabled=true; classe = document.getElementById('brand').className; classe = classe + ' disabledT'; document.getElementById('brand').className = classe; document.getElementById('model').disabled=true; classe = document.getElementById('model').className; classe = classe + ' disabledT'; document.getElementById('model').className = classe; } Critere.prototype.fill_static_marque = function(TabMarque){ var i; var label = this.marque[0].text this.marque = new Array(new Option(label,'')); var temp; var marque = TabMarque.split(/;/); for(i=0;i0) this.combo_brand.options[i]=null;/*vide la combo*/ var ss_cat; if(document.getElementById('SS_CATEGORIE')){ ss_cat = document.getElementById('SS_CATEGORIE').value; var nb = ss_cat.split(',').length; } var brands=new Array(); idx=this.combo_brand.options.length-1; if (this.combo_brand) idx=this.combo_brand.options.length-1; Ttemp_cat = cat.split(new RegExp(',')); if(this.curcat=='utils'||this.curcat=='loisir'||this.curcat=='auto'||(this.curcat=='moto'&& this.advanced)) compteur = this.ob_cat.getnbCat(); for (i=0;i0&&(this.curcat=='auto'||this.curcat=='moto'||this.curcat=='quad'||this.curcat=='scooter'||this.curcat=='utils'||this.curcat=='loisir')) { var TModeles = Ttemp[1].split(new RegExp("\t")); for (var k=0;k0) this.combo_model.options[i-1]=null;/*vide la combo*/ this.combo_model.options[0] = new Option ( 'Mod\u00e8le', '' ); idx=0; Ttemp_cat = cat.split(new RegExp(',')); for (i=0;i1) this.combo_prix_mini.options[i-1]=null;/*vide la combo*/ if (this.combo_prix_mini.options.length==0) this.combo_prix_mini.options[this.combo_prix_mini.options.length] = new Option ( 'Prix min.' , ''); if (this.curcat=='moto' || this.curcat=='scooter' || this.curcat=='quad') { for (i=0;i-1) min_price = this.combo_prix_mini.options[this.combo_prix_mini.selectedIndex].value; else min_price=0; var step = 1500; var min = (min_price>0)?parseInt(min_price,10) + step:1500; var max = 100500; var TabPriceMoto = new Array(1500,2500,3500,5000,7000,8000,10000,12000,15000); while((i = this.combo_prix_maxi.options.length)>1) this.combo_prix_maxi.options[i-1]=null; if (this.combo_prix_maxi.options.length==0) this.combo_prix_maxi.options[this.combo_prix_maxi.options.length] = new Option ( 'Prix max.' , ''); /*build list starting from price min + step and trying to restore old value*/ if (this.curcat=='moto' || this.curcat=='scooter' || this.curcat=='quad') { for (i=0;i((min_price>0)?parseInt(min_price,10):0)) { this.combo_prix_maxi.options[this.combo_prix_maxi.options.length] = new Option ( format(TabPriceMoto[i]) + ' \u20ac maxi.' , TabPriceMoto[i] ); if(this.prefered_max_price && TabPriceMoto[i] == this.prefered_max_price)this.combo_prix_maxi.options[this.combo_prix_maxi.options.length-1].selected=true; } } } else { for(i=min;i<=max;i+=step) { this.combo_prix_maxi.options[this.combo_prix_maxi.options.length] = new Option ( format(i) + ' \u20ac maxi.' , i ); if(this.prefered_max_price && i == this.prefered_max_price)this.combo_prix_maxi.options[this.combo_prix_maxi.options.length-1].selected=true; } } } Critere.prototype.fill_min_yearmodel = function() { var ladate=new Date(); var age; var cat=this.get_cat(); var max,min; if(cat==49){ age=ladate.getFullYear()-1900; max=ladate.getFullYear()-31; }else if (cat.indexOf("49") != -1) { age=ladate.getFullYear()-1900; max=ladate.getFullYear(); }else{ age=30; max=ladate.getFullYear(); } min = (ladate.getFullYear())-age; var step = 1; var i; while((i = this.combo_yearmodel_mini.options.length)>1) this.combo_yearmodel_mini.options[i-1]=null;/*vide la combo*/ if (this.combo_yearmodel_mini.options.length==0) this.combo_yearmodel_mini.options[this.combo_yearmodel_mini.options.length] = new Option ( 'Mill\u00e9sime compris entre ' , ''); if(this.prefered_min_yearmodel=='0')this.combo_yearmodel_mini.options[this.combo_yearmodel_maxi.options.length-1].selected=true; for(i=max;i>=min;i-=step) { this.combo_yearmodel_mini.options[this.combo_yearmodel_mini.options.length] = new Option ( i +' ann\u00e9e mini.', i ); if((this.prefered_min_yearmodel!='')&&(i==this.prefered_min_yearmodel))this.combo_yearmodel_mini.options[this.combo_yearmodel_mini.options.length-1].selected=true; } } Critere.prototype.fill_max_yearmodel = function() { /*fill max yearmodel combo*/ var ladate=new Date(); var cat=this.get_cat(); var max,min,i; if(cat==49){ age=ladate.getFullYear()-1900; max=ladate.getFullYear()-31; }else if (cat.indexOf("49") != -1) { age=ladate.getFullYear()-1900; max=ladate.getFullYear(); }else{ age=30; max=ladate.getFullYear(); } var min_yearmodel; if (this.combo_yearmodel_mini.selectedIndex>-1) min_yearmodel = this.combo_yearmodel_mini.options[this.combo_yearmodel_mini.selectedIndex].value; else min_yearmodel=0; var step = 1; min = (min_yearmodel>0)?parseInt(min_yearmodel,10) :((ladate.getFullYear())-age); while((i = this.combo_yearmodel_maxi.options.length)>1) this.combo_yearmodel_maxi.options[i-1]=null; if (this.combo_yearmodel_maxi.options.length==0) this.combo_yearmodel_maxi.options[this.combo_yearmodel_maxi.options.length] = new Option ( '' , ''); /*build list starting from yearmodel min + step and trying to restore old value*/ for(i=max;i>=min;i-=step) { this.combo_yearmodel_maxi.options[this.combo_yearmodel_maxi.options.length] = new Option ( i+' ann\u00e9e maxi.' , i ); if(this.prefered_max_yearmodel && i == this.prefered_max_yearmodel)this.combo_yearmodel_maxi.options[this.combo_yearmodel_maxi.options.length-1].selected=true; } } Critere.prototype.fill_mileage = function() { /*fill maxi km combo*/ var min = 10000; var max = 200000; var step = 10000; var i; if(this.combo_mileage!=null){ while((i = this.combo_mileage.options.length)>1) this.combo_mileage.options[i-1]=null; if (this.combo_mileage.options.length==0) this.combo_mileage.options[this.combo_mileage.options.length] = new Option ( 'Kilom\u00e9trage maximum' , ''); for(i=min;i<=max;i+=step) { this.combo_mileage.options[this.combo_mileage.options.length] = new Option ( format(i) + ' km maxi.' , i ); if((this.prefered_mileage!='')&&(i==this.prefered_mileage))this.combo_mileage.options[this.combo_mileage.options.length-1].selected=true; } } } Critere.prototype.clearVersion = function(){ //desactivation de la methode return; } function format(the_string){ /*return a well formated string 3000 => 3 000*/ var str = ''+the_string; var step = 3; var tmp = ''; var i; var nbspace=0; for(i=str.length-1;i>=0;i--){ tmp=str.charAt(i)+tmp; if(((tmp.length-nbspace)%step==0)&&(i>0)){tmp=' '+tmp;nbspace++;} } return tmp; } function decode(the_string) { return the_string.replace(new RegExp('\\*','g'),'/').replace(new RegExp('~','g'),'+').replace(new RegExp('`','g'),'\'').replace(new RegExp('_','g'),'-').replace(new RegExp('\\^','g'),'&'); } Critere.prototype.get_cat = function() { var i,cat; if (document.getElementById('cat[0]')==null) { if (document.getElementById('SS_CATEGORIE').options!=null) { cat = document.getElementById('SS_CATEGORIE').options[document.getElementById('SS_CATEGORIE').selectedIndex].value; } else { cat = document.getElementById('SS_CATEGORIE').value; } }else{ for (i=0;i< 3;i++) { if (document.getElementById('cat['+i+']') && document.getElementById('cat['+i+']').checked) cat = document.getElementById('cat['+i+']').value; } } return cat; } Critere.prototype.fill_energy = function(){ if(this.combo_Energy==null)return; var Tnrj = new Array(new Array('Carburant','',''), new Array('Diesel','2',''), new Array('Essence','1',''), new Array('Electrique','4','greenenergie'), new Array('Hybrides','8,9','greenenergie'), new Array('Bicarburation essence / gpl','3','greenenergie'), new Array('Bicarburation essence bio\u00e9thanol','10','greenenergie'), new Array('Autres \u00e9nergies alternatives','5,6,7,11','greenenergie') ); for(var i=0;i