var wL=new Array(),wLO=new Array(),oIDV,wV=new Array(),urlR=new Array();
function BWTL(){a=arguments;this.i=a[0];this.type=a[1];this.id=a[2];this.gdp=a[3];this.par=a[4];this.chi=new Array();this.sel=false;for(i=5;i<a.length;i++)this.chi[this.chi.length]=a[i];}
function BWT_ChargeVille() {f=d.getElementById('recherche_form');oL=f["localisation[]"];for(var i=wLO.length-1;i>=0;i--) {oL.options[i]=new Option(wLO[i][1],wLO[i][0]);if(wLO[i][2]!='') oL.options[i].style.color=wLO[i][2];if(wLO[i][3]!='') oL.options[i].selected=true;if(wLO[i][4]!='') oL.options[i].className=wLO[i][4];}}
function BWT_getIndex(val,idv){for(var z=wL.length-1;z>=0;z--) if(wL[z].type+'_'+wL[z].id==val && wL[z].gdp==idv) return z;return -1;}
function BWT_ChangeVille(idv,noredirect) {
	if(!noredirect) {
		if(urlR[idv]) d.location.href=urlR[idv];
		else setTimeout("BWT_ChangeVille("+idv+")",500);
	}
	else BWT_ChargeQuartiers(idv);
}
function BWT_ChargeQuartiers(idv) {
	f=d.getElementById('recherche_form');
	if(f) {
		oIDV=idv;
		oL=f["localisation[]"];
		oV=f["ville"]||{};
		for (m=oL.options.length-1;m>0;m--) oL.options[m]=null;
		oL.options[0]=new Option(wLO[0][1],wLO[0][0]);
		k=1;
		if(idv>0) {
			for(i=1;i<wLO.length;i++) {
				if(wLO[i][5]==idv) {
					oL.options[k]=new Option(wLO[i][1],wLO[i][0]);
					//if(wLO[i][2]!='') oL.options[k].style.color=wLO[i][2];
					if(wLO[i][3]!='') oL.options[k].selected=true;
					//if(wLO[i][4]!='') oL.options[k].className=wLO[i][4];
					k++;
				}
			}
			if(oV.type=='hidden') {
				for(i=0;i<wV.length;i++)
					if(d.getElementById('bouton_ville['+i+']'))
						if(idv==i) {
							d.getElementById('bouton_ville['+i+']').className='bouton_c';
							oV.value=idv;
						} else d.getElementById('bouton_ville['+i+']').className='bouton';
			} else {
				if(oV.selectedIndex==0) 
					for(i=1;i<oV.length;i++)
						if(oV.options[i].value==idv) oV.options[i].selected=true;
			}
			f.action=urlR[idv];
		}
	}
}
function BWT_Localisation(t,z){
/*	if(d.recherche) {
		oL=d.recherche["localisation[]"];
		reboucle=false;
		for(var i=oL.options.length-1;i>0;i--) oL.options[i].className='i_select';
		for(var i=wLO.length-1;i>0;i--) {
			index=BWT_getIndex(wLO[i][0],oIDV);
			if(index>0) if(oL.options[wL[index].i] && wL[index].gdp==oIDV){	
				if(wL[index].type=='a'){
					if(oL.options[wL[index].i].selected==true){
						t=0;
						for(var j=wL[index].chi.length-1;j>=0;j--) {
							index2=BWT_getIndex('q_'+wL[index].chi[j],oIDV);
							if(wL[index2]) if(oL.options[wL[index2].i].selected==true)t++;
						}
						if(t==0) for(var j=wL[index].chi.length-1;j>=0;j--){
							index2=BWT_getIndex('q_'+wL[index].chi[j],oIDV);
							if(wL[index2]) {
								wL[index2].sel=true;
								oL.options[wL[index2].i].className='i_select_s1';
								oL.options[wL[index2].i].selected=false;
							}
						}else{
							oL.options[wL[index].i].selected=false;
							oL.options[wL[index].i].className='i_select_s';
							for(var j=wL[index].chi.length-1;j>=0;j--){
								index2=BWT_getIndex('q_'+wL[index].chi[j],oIDV);
								if(wL[index2]) {
									if(oL.options[wL[index2].i].selected==false&&wL[index2].sel==true){
										oL.options[wL[index2].i].selected=true;
										oL.options[wL[index2].i].className='i_select1';
									}else if(oL.options[wL[index2].i].selected==true&&wL[index2].sel==true){
										oL.options[wL[index2].i].selected=false;
										oL.options[wL[index2].i].className='i_select1';
									}else reboucle=true;
								}
							}
							if(reboucle==true){
								index2=BWT_getIndex('q_'+wL[index].chi[j],oIDV);
								if(wL[index2]) {
									for(var j=wL[index].chi.length-1;j>=0;j--){
										wL[index2].sel=true;
										oL.options[wL[index2].i].className='i_select_s1';
										oL.options[wL[index2].i].selected=false;
									}
								}
								oL.options[wL[index].i].selected==true;
								oL.options[wL[index].i].className='i_select';
							}
						}
					}else{
						t=0;
						if(wL[index].chi.length>0) for(var j=wL[index].chi.length-1;j>=0;j--) {
							index2=BWT_getIndex('q_'+wL[index].chi[j],oIDV);
							if(wL[index2]) if(oL.options[wL[index2].i].selected==true) t++;
						}
					}
				}else{
					index2=BWT_getIndex('a_'+wL[index].par,oIDV);
					if(wL[index2]) if(oL.options[wL[index].i].selected==true && oL.options[wL[index2].i]){
						if(oL.options[wL[index2].i].selected==false){
							t=0;
							for(var j=wL[index2].chi.length-1;j>=0;j--) {
								index3=BWT_getIndex('q_'+wL[index2].chi[j],oIDV);
								if(oL.options[wL[index3].i].selected==true) t++;
							}
							if(t==wL[index2].chi.length){
								oL.options[wL[index2].i].selected=true;
								for(var j=wL[index2].chi.length-1;j>=0;j--){
									index3=BWT_getIndex('q_'+wL[index2].chi[j],oIDV);
									oL.options[wL[index3].i].selected=false;
									oL.options[wL[index3].i].className='i_select_s1';
									wL[index3].sel=true;
								}
							}else oL.options[wL[index2].i].className='i_select_s';
						}
					}
				}
			}
		}
	}*/
}
function VAP_ChgOr(t,o){dr=f=d.getElementById('recherche_form');dr.col_ordre.value=t;dr.typ_ordre.value=o;dr.submit();}
function VAP_ZoomIt(v){d.photoXL.src=v;}
