/* FILTRAGE DES CATEGORIES */
function filtre(p_cat_id, p_numpg) 
{		
	var msg = '';
	
	for(var cpt = 0; cpt < document.filtrage.length; cpt ++)
	{
		if(document.filtrage[cpt].type == 'select-one' && document.filtrage[cpt].options[document.filtrage[cpt].options.selectedIndex].value != 0)
			msg += document.filtrage[cpt].name+"[*]"+document.filtrage[cpt].options[document.filtrage[cpt].options.selectedIndex].value+'[***]';
		else if((document.filtrage[cpt].type == 'radio') && document.filtrage[cpt].checked)
			msg += document.filtrage[cpt].name+"[*]"+document.filtrage[cpt].value+'[***]';
		else if(document.filtrage[cpt].type == 'text' && document.filtrage[cpt].value != '')
			msg += document.filtrage[cpt].name+"[*]"+document.filtrage[cpt].value+'[***]';
	}
	
	if(msg != '')
	{
		msg = msg.substring(0, msg.length -5);	
		msg = "&filtres="+msg;
	}

		verif_xhr();
		
		xhr_object.open("POST", "pg/resultats_achat.php", true);
		
		xhr_object.onreadystatechange = function() 
		{
			if(xhr_object.readyState == 4 && xhr_object.status == 200)
			{
				document.getElementById('produits').innerHTML = xhr_object.responseText;
			}
			else
			{
				document.getElementById('produits').innerHTML = '<p class="chargement"><img src="../images/loadingAnimation.gif" /></p>';
			}
		}
	
		xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");			
		xhr_object.send("action=filtrage&numpg="+p_numpg+"&cat_id="+p_cat_id+msg);
}

/* AUTRES PRODUITS */
function autres_produits(p_pro_id, p_id, p_titre, p_filtres) 
{		
	verif_xhr();
	
	xhr_object.open("POST", "pg/resultats_achat.php", true);
	
	xhr_object.onreadystatechange = function() 
	{
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			document.getElementById(p_id).innerHTML = xhr_object.responseText;
		}
		else
		{
			document.getElementById(p_id).innerHTML = '<p class="chargement"><img src="../images/loadingAnimation.gif" /></p>';
		}
	}

	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");			
	xhr_object.send("action=autres_produits&pro_id="+p_pro_id+"&titre="+p_titre+"&filtres="+p_filtres);
}
