// JavaScript Document

function change_categorie(box_src,box_dst,motor_def,dest) {
	var categorie = box_src.value;
	
	for (i=0;i<box_dst.options.length;i++) {			
				box_dst.options[i].text = "";
				box_dst.options[i].value = 0;
		}
	for (i=0;i<box_dst.options.length;i++) {			
				box_dst.options[i]=null;
		}
		
	if (categorie != "000")
	 {
		var soudom_list = eval("soudom_list_"+categorie);
		var size = soudom_list.length;
		var soucategorie=0;
			
		if (size > 0) 
		{
			for (j=0;j<size;j++)
			{
				var option = document.createElement("OPTION");
				if (j==0) soucategorie=soudom_list[j][0];
				option.value=soudom_list[j][0];
				option.text=soudom_list[j][1];
				box_dst.options[j] = option;	
			}
		}
	
		var url = dest+"?categorie_def="+categorie+"&soucategorie_def="+soucategorie+"&motor_def="+motor_def;
		//document.location.href=url;
	}
	else
	{
		box_dst.options[0].text = "Choisir";
		box_dst.options[0].value = 000;
	}
	box_dst.selectedIndex=0;
}

function go_liste_produit() {
	var categorie = document.forms['listing'].elements['categorie'].value ;
	var souscategorie = document.forms['listing'].elements['soucategorie'].value ;
	var motorisation = document.forms['listing'].elements['motorisation'].value ;
	
	if ( (categorie!="000") && (souscategorie!="000") && (motorisation !="000") ) 
	{
	
		/*var url = "liste_produit.php?categorie_def="+categorie+"&soucategorie_def="+souscategorie+"&motor_def="+motorisation ;
		if (navigator.platform.indexOf("Win")>-1) 
		{
			document.location.href=url;
		}
		else 
		{
			window.location=url;
		}
		*/
		document.forms['listing'].submit();
	}
	else
	{
		MyLoc = document.URL ;
		if ( MyLoc.indexOf("FR/") > 0 ) alert("Votre sélection n'est pas complète !");
		if ( MyLoc.indexOf("ES/") > 0 ) alert("Su selección no está completa !");
		if ( MyLoc.indexOf("NL/") > 0 ) alert("Uw selectie is niet volledig !");
		if ( MyLoc.indexOf("UK/") > 0 ) alert("Your selection is not complete !");
	}
}

function change_motor(box_src,box_dst,box2,dest) {
	var soucategorie = box_src.value;
	var carbu = box2.value;
	
	if ( (carbu != "000" ) && (soucategorie != "000"))
	{
		var moteur_list = eval("motor_list_"+soucategorie);
		var size = moteur_list[carbu].length;
		var moteur=0;
		
		for (i=0;i<box_dst.options.length;i++) {			
				box_dst.options[i].text = "";
				box_dst.options[i].value = 0;
		}
		for (i=0;i<box_dst.options.length;i++) {			
				box_dst.options[i]=null;
		}
			
		if (size > 0) 
			{
				for (j=0;j<size;j++)	{
					var option = document.createElement("OPTION");			
					option.value=moteur_list[carbu][j][1];
					option.text=moteur_list[carbu][j][1];
					box_dst.options[j] = option;	
				}
			}
		else
			{
				box_dst.options[0].text = "-";
				box_dst.options[0].value = 000;
			}
	}
	else
	{
		box_dst.options[0].text = "Choisir";
		box_dst.options[0].value = 000;
	}
	box_dst.selectedIndex=0;
	//var url = dest+"?categorie_def="+categorie+"&soucategorie_def="+soucategorie+"&motor_def="+motor_def;
	//document.location.href=url;
}


function change_carbu(box_src,box_dst,box1,dest) {
	var soucategorie = box1.value;
	var carbu = box_src.value;

	if ( (carbu != "000" ) && (soucategorie != "000"))
	{
		var moteur_list = eval("motor_list_"+soucategorie);
		var size = moteur_list[carbu].length;
		var moteur=0;
		
		for (i=0;i<box_dst.options.length;i++) {			
				box_dst.options[i].text = "";
				box_dst.options[i].value = 0;
		}
		for (i=0;i<box_dst.options.length;i++) {			
				box_dst.options[i]=null;
		}
			
		if (size > 0) 
			{
				for (j=0;j<size;j++)	
				{
					var option = document.createElement("OPTION");			
					option.value=moteur_list[carbu][j][1];
					option.text=moteur_list[carbu][j][1];
					box_dst.options[j] = option;	
				}
			}
		else
			{
				box_dst.options[0].text = "-";
				box_dst.options[0].value = 000;
			}
	}
	else
	{
		box_dst.options[0].text = "Choisir";
		box_dst.options[0].value = 000;
	}

	box_dst.selectedIndex=0;
	//var url = dest+"?categorie_def="+categorie+"&soucategorie_def="+soucategorie+"&motor_def="+motor_def;
	//document.location.href=url;
}

function change_produit(box_src,categorie,motor_def,dest) {
	var soucategorie = box_src.value;
	var url = dest+"?categorie_def="+categorie+"&soucategorie_def="+soucategorie+"&motor_def="+motor_def;
	//document.location.href=url;
}

function change_produit_motor(box_src,categorie,soucategorie,dest) {
	var motorisation = box_src.value;
	var url = dest+"?categorie_def="+categorie+"&soucategorie_def="+soucategorie+"&motor_def="+motorisation;
	//document.location.href=url;
}

function ajout_panier(qte,id_produit,dest,cat,soucat,motor) {
	qte_prod = qte.value;
	var url = "panier.php?action=add_panier&qte="+qte_prod+"&id_produit="+id_produit+"&categorie_def="+cat+"&soucategorie_def="+soucat+"&motor_def="+motor;
	document.location.href=url;
}

function popup_centre(page, mywidth, myheight)
{
    var winl = (screen.width - mywidth) / 2; 
    var wint = (screen.height- myheight) / 2;
    win = window.open(page,'site','width='+mywidth+',height='+myheight+',top='+wint+',left='+winl+',toolbar=no,scrollbars=yes,directories=no,status=yes,menubar=no,resizable=no,align=center')
    if(parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function MM_jumpMenu(targ,selObj,restore){ 
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
