var rech_stat = 1;
function af_onrech() {
	var mem = new Array();
	vcat = new Array();
	vcat = top.categorie.sort();
	var_cat = "";
	var_marq = "";
	var sel = "";
	
	
	var_cat = "<select name=rech0 onchange='top.rech_select=this.value;af_onrech();'>";
	if (top.rech_select == "Mots Clés") sel = "selected ";
	else sel = "";
	var_cat  = var_cat  + "<option " + sel + "value='Mots Clés'>Mots Clés</option>";
	if (top.rech_select == "Mots Clés Prédéfinis") sel = "selected ";
	else sel = "";
	var_cat  = var_cat  + "<option " + sel + "value='Mots Clés Prédéfinis'>Mots Clés Prédéfinis</option>";
	if (top.rech_select == "Marque") sel = "selected ";
	else sel = "";
	var_cat  = var_cat  + "<option " + sel + "value='Marque'>Marque</option>";
	var_cat  = var_cat + "</select>";
	aff = document.getElementById("sel_cat");
	aff.innerHTML = var_cat;
	
	if (top.rech_select == "Mots Clés") {
		var_cat = "";
		var_cat = "<input type='text' name='in_mot' size='20' maxlength='30' value='" + top.mot_select + "' onchange=top.mot_select=this.value;encours();>" + "&nbsp;&nbsp;<input type='button' value='GO' onclick=top.first_rec=1;af_resultat();>" + "&nbsp;&nbsp;<input type='button' value='effacer' onclick=top.mot_select='';af_onrech();>";
		aff = document.getElementById("sel_marq");
		aff.innerHTML = var_cat;
		aff1 = document.getElementById("sel_titre");
		aff1.innerHTML = "Tapez votre mot clé";
	}
	
	if (top.rech_select == "Mots Clés Prédéfinis") {
		var_cat = "";
		if (top.categ_select == "Sélectionner Marque") sel = "selected ";
		else sel ="";
		var_cat  = var_cat  + "<option " + sel + "value='Sélectionner Catégorie'>Sélectionner Catégorie</option>";
		if (top.categ_select == "Toutes Marques") sel = "selected ";
		else sel ="";
		var_cat  = var_cat  + "<option " + sel + "value='Toutes Catégories'>Toutes Catégories</option>";
		for (i in vcat) {
			separ = vcat[i].split(",");
			if (separ[0] == top.categ_select) sel = "selected ";
			else sel ="";
			var_cat = var_cat + "<option " + sel + "value='" + separ[0] + "'>" + separ[0] + "</option>";
		}
		var_cat = "<select name=rech1 onchange=top.categ_select=this.value;top.first_rec=1;af_resultat()>" + var_cat + "</select>";
		aff = document.getElementById("sel_marq");
		aff.innerHTML = var_cat;
		aff1 = document.getElementById("sel_titre");
		aff1.innerHTML = "Séléctionnez votre mot clé";
	}
	
	if (top.rech_select == "Marque") {
		if (top.marque_select == "Sélectionner Marque") sel = "selected ";
		else sel ="";
		var_marq = var_marq + "<option " + sel + "value='Sélectionner Marque'>Sélectionner Marque</option>";
		if (top.marque_select == "Toutes Marques") sel = "selected ";
		else sel ="";
		var_marq = var_marq + "<option " + sel + "value='Toutes Marques'>Toutes Marques</option>";
		k = 0;
		for (i in top.p) {
			add = 1;
			for (j in mem){ if (mem[j] == top.p[i].marque) add = 0};
			if (add == 1) {
				mem[k] = top.p[i].marque;k++
			}
		}
		mem = mem.sort();
		for (i in mem) {
			if (mem[i] == top.marque_select) sel = "selected ";
			else sel ="";
			if (mem[i] != "") var_marq = var_marq + "<option " + sel + "value='" + mem[i]  + "'>" + mem[i] + "</option>";
		}
		var_marq = "<select name=rech2 onchange=top.marque_select=this.value;top.first_rec=1;af_resultat();>" + var_marq + "</select>";
		aff = document.getElementById("sel_marq");
		aff.innerHTML = var_marq;
		aff1 = document.getElementById("sel_titre");
		aff1.innerHTML = "Sélectionnez la marque";
	}
}

function encours() {
	var venc = "<table width='200' cellpadding='10' cellspacing='0' border='1' bordercolor='#660000' align='center'><tr><td><b>Recherche . . . .</b></td></tr></table>";
	resultat.innerHTML = venc;
}


function af_critere() {
	vsel = "Aucune Sélection";
	if (top.categ_select != "Sélectionner Catégorie") vsel = top.categ_select;
	aff = document.getElementById("crit_cat");
	aff.innerHTML = vsel;
	vsel = "Aucune Séléction";
	if (top.marque_select != "Sélectionner Marque") vsel = top.marque_select;
	aff1 = document.getElementById("crit_marq");
	aff1.innerHTML = vsel;
}

function str_rep(vrep,vold,vnew) {
	while (vrep.indexOf(vold) != -1) {
		vrep = vrep.replace(vold,vnew)
	}
	return vrep;
 }

function af_resultat() {
	var top_cat = new Array();
	var art_sel = new Array();
	var art_prop = new Array();
	var mots_cle = new Array();
	var str_prop = "";
	var res = 0;
	var max_rec = 200;
	var vnom_rech = "";
	var mot_cle = "";
	
	var top_cat = new Array("0","Anti-âge","Articulations","Circulation","Confort masculin","Confort féminin","Défenses","Digestions","Equilibre Nerveux","Excès de graisse","Fatigue","Foie","Grossesse","Hiver/froid","Intestins","Ménopause","Minéraux","Minceur","Sportifs","Stress/moral","Transit","Vitamines","Vitalité","Croissance","Peau","Ongles","Cheveux","Elimination","Récupération","Antimites","Ambiance","Bien-être1","Os2","Acidité","Equilibre général","Anti-oxydant","Endurance","Alimentation biologique","Compléments alimentaires","Hygiène","Cosmétiques","Accessoires","Dépuratif","Cartilage","Yeux","Teinture","Shampooing","Savon","Confort de la vue","Lotion");
	
	if ((top.categ_select == "Sélectionner Catégorie" && top.rech_select == "Mots Clés Prédéfinis") || (top.marque_select == "Sélectionner Marque" && top.rech_select == "Marque") || (top.mot_select == "" && top.rech_select == "Mots Clés")) content ="<center><b><font face=Times New Roman style='font-size:20;' color=#660000>Aucune Recherche Séléctionnée</font></b></center>";
	else {
		if (top.rech_select == "Mots Clés") {
			vmot = top.mot_select.toLowerCase();
			vmot = str_rep(vmot,"'"," ");
			vmot = str_rep(vmot,","," ");
			vmot = str_rep(vmot,"-"," ");
			vmot = str_rep(vmot,"é","e");
			vmot = str_rep(vmot,"è","e");
			vmot = str_rep(vmot,"à"," ");
			vmot = str_rep(vmot,"â","a");
			vmot = str_rep(vmot,"ê","e");
			vmot = str_rep(vmot," d "," ");
			vmot = str_rep(vmot," l "," ");
			vmot = str_rep(vmot," a "," ");
			mots_cle = vmot.split(" ");
		}
		if (top.rech_select == "Mots Clés Prédéfinis") {
			vmot = top.categ_select.toLowerCase();
			vmot = str_rep(vmot,"'"," ");
			vmot = str_rep(vmot,","," ");
			vmot = str_rep(vmot,"-"," ");
			vmot = str_rep(vmot,"é","e");
			vmot = str_rep(vmot,"è","e");
			vmot = str_rep(vmot,"à"," ");
			vmot = str_rep(vmot,"â","a");
			vmot = str_rep(vmot,"ê","e");
			vmot = str_rep(vmot," d "," ");
			vmot = str_rep(vmot," l "," ");
			vmot = str_rep(vmot," a "," ");
			mot_cle = vmot;
			
		}
		
		for (i in top.rech_list) {
			if (top.rech_select == "Mots Clés") {
				mot_sel = 1;
				for (k in mots_cle){
					if (top.rech_list[i].search(mots_cle[k]) == -1) mot_sel = 0;
				}
				if (mot_sel == 1) {art_sel[i] = 1;res=1;}
			}
			
			if (top.rech_select == "Mots Clés Prédéfinis") {
				if (top.categ_select == "Toutes Catégories" || top.rech_list[i].search(mot_cle) != -1)  {art_sel[i] = 1;res = 1;}
			}
			
			if (top.rech_select == "Marque") {
				if (top.marque_select == "Sélectionner Marque" || top.marque_select == "Toutes Marques" || top.p[i].marque == top.marque_select) {art_sel[i] = 1;res=1;}
			}
		}
		
		var content = "";
		var art_nom = new Array();
		var art_num = new Array();
		k = 0;
		for (n in art_sel) {
			art_nom[k] = top.p[n].nom + top.p[n].condit + top.p[n].marque;
			art_num[top.p[n].nom + top.p[n].condit + top.p[n].marque] = n;
			k++;
		}
		art_nom = art_nom.sort();
		n = 1;
		for (j in art_nom) {
			n++;
			if (n > top.first_rec) content = content + af_1produit(art_num[art_nom[j]]);
			if (n > (top.first_rec + max_rec - 1)) break;
		}
		var table_start = "<table width='550' align='center'><tr><td><font face='Times New Roman' color='#aa0000' style='font-size:20;'><center><b>" + k + " Produits sélectionnés</b><br>( " + top.first_rec + " - " + (n - 1) +") </center></font><br><br><font face='Times New Roman' color='#550000' style='font-size:13;'>Cliquer sur le nom du produit pour accéder à la page correspondante</font></td></tr></table><table width=550 border=1 bgcolor=#ffffff cellspacing=0 cellpadding=2 bordercolor=#bb8888 align=center><tbody><tr bgcolor=#eaeae0 align=center style='color:#550000;font-size:10pt;font-style:bold;'><td width=310>Nom des Produits</td><td width=150>&nbsp;Marque</td><td width=80>Prix</td></tr>";
		content = table_start + content + "</tbody></table>";
		if (k < (max_rec + 1)) content = content + "<br><table width='150' bgcolor='#bb0000' cellspacing='0' cellpadding='0' align='center'><tr><td width='150'><font face='Arial' color='#ffff00' style='font-size:12;'><center><b>fin de liste</b></center></font></td></tr></table>"
		var ptotal = Math.ceil(k / max_rec);
		var pcour = (top.first_rec + max_rec - 1) / max_rec;
		if (k > max_rec) {
			if (((top.first_rec + max_rec) <= k) && (top.first_rec == 1))  {
				content = content + "<br><table width='400' bgcolor='#bb0000' cellspacing='0' cellpadding='0' align='center'><tr><td width='90'></td><td width='240'><font face='Arial' color='#dddddd' style='font-size:12;'><center><b>Page " + pcour + " / " + ptotal + "</b></center></font></td><td width='50'><font face='Arial' color='#dddddd' style='font-size:12;'><center><b>suivant</b></center></font></td><td width='20'><input width='20' TYPE=image src='avance.jpg' alt='page suivante (historique)' onclick='top.first_rec=top.first_rec+" + max_rec + ";af_resultat();'></td></tr></table>"
			}
			if (((top.first_rec + max_rec) <= k) && (top.first_rec != 1))  {
				content = content + "<br><table width='400' bgcolor='#bb0000' cellspacing='0' cellpadding='0' align='center'><tr><td width='20'><input width='20' TYPE=image src='retour.jpg' alt='page précédente' onclick='top.first_rec=top.first_rec-" + max_rec + ";af_resultat();'></td><td width='70'><font face='Arial' color='#dddddd' style='font-size:12;'><center><b>précédent</b></center></font></td><td width='250'><font face='Arial' color='#dddddd' style='font-size:12;'><center><b>Page " + pcour + " / " + ptotal + "</b></center></font></td><td width='50'><font face='Arial' color='#dddddd' style='font-size:12;'><center><b>suivant</b></center></font></td><td width='20'><input width='20' TYPE=image src='avance.jpg' alt='page suivante (historique)' onclick='top.first_rec=top.first_rec+" + max_rec + ";af_resultat();'></td></tr></table>"
			}
			if ((top.first_rec + max_rec) > k)  {
				content = content + "<br><table width='400' bgcolor='#bb0000' cellspacing='0' cellpadding='0' align='center'><tr><td width='20'><input width='20' TYPE=image src='retour.jpg' alt='page précédente' onclick='top.first_rec=top.first_rec-" + max_rec + ";af_resultat();'></td><td width='70'><font face='Arial' color='#dddddd' style='font-size:12;'><center><b>précédent</b></center></font></td><td width='250'><font face='Arial' color='#dddddd' style='font-size:12;'><center><b>Page " + pcour + " / " + ptotal + "</b></center></font></td><td width='90'></td></tr></table>"
			}
		}
		if (res == 0) content = "<font face='Times New Roman' color='#aa0000' style='font-size:20;'><center>Aucun article ne correspond aux critères</center></font>";
	}
	aff = document.getElementById("resultat");
	aff.innerHTML = content;
}

function af_1produit(iproduit) {
	var vaf1produit = "";
	var_select = "";
	if (top.panier[iproduit]) {
		if (top.panier[iproduit].qte != 0) imgsel="sel1.jpg";
		else imgsel="sel0.jpg";
	}
	else imgsel="sel0.jpg";
	if (top.panier[iproduit]) pqte = String(top.panier[iproduit].qte);
	else pqte = "0";
	var mem_marq = top.p[iproduit].marque
	var afvnom = top.p[iproduit].nom + " - " + top.p[iproduit].condit;
	if (afvnom.length > 42) afvnom = afvnom.substr(0,42);
	if (mem_marq.length > 24) mem_marq = top.p[iproduit].marque.substr(0,24);
	vaf1produit = "<tr></td><td width=310><a href='" + top.p[iproduit].page + ".htm' target=page class=pasoulr title='Acceder à la page de cet article' onmouseover=this.style.textDecoration='underline';this.style.color='#aa0000'; onmouseout=this.style.textDecoration='none';this.style.color='#000088';>&nbsp;" + afvnom + "</a></td><td width=150 class=txttble>&nbsp;" + mem_marq + "</td><td width=80 class=txttble1 align='right'>&nbsp;" + francs(top.p[iproduit].prix) + " " + top.devise[top.devise_sel].abrev + "</td></tr>";
	return(vaf1produit);
}

function rech_ajout_panier(iref,valeur){
	top.panier[iref]=new top.article(valeur);
	if (!document["_" + iref]) {
		document["_" + iref] = new Image();
		document["_" + iref].src = iref + ".jpg";
	}
	paniera();
	af_image(iref);
	edit_fin();

}