/* fonctions javascript */


/* fonction de redirection */
function redirige(adresse)
{
	window.location.replace(adresse);
}

/* pour accès à la base de données en dynamique */
function get_firefox(theUrl)
{
	p = new XMLHttpRequest();
	p.onload = null;
	p.open("GET",theUrl, false);
	p.send(null);
	if(p.status == 200)
	    return (p.responseText);
}

function get_ie(theUrl)
{
	var xmlHttpReq = new ActiveXObject("MSXML2.XMLHTTP.3.0");
	xmlHttpReq.open("GET", theUrl, false);
	xmlHttpReq.send();
	return xmlHttpReq.responseText;
}


function select_nav_get(theUrl)
{
	if(navigator.appName == "Microsoft Internet Explorer")
	{
		return get_ie(theUrl);
	}
	else
	{
		return get_firefox(theUrl);
	}
}

/*________________________________________________*/
//  maj_panier
/*_______________________________________________*/
function maj_panier(operation_p,id_client_p,id_produit_p,id_produit_cadeau_p)
{
	var nom_quantite = 0;
	var quantite_chiffre = 0;
	var quantite_identique_cadeau = 0;

	if(id_produit_p != 0)
	{
	     nom_quantite = 'quantite_'+id_produit_p;
	     quantite_chiffre = document.getElementsByName(nom_quantite)[0].value;
	}

	reponse_p =  select_nav_get("/boutique/script/maj_panier.php?operation="+operation_p+"&id_produit="+id_produit_p+"&quantite_chiffre="+quantite_chiffre+"&id_produit_cadeau="+id_produit_cadeau_p);
	
	if(reponse_p != "")
	{
		eval(reponse_p);
	}
}

function changer_affichage_div(objetCondition, idElement, inputMasquage)
{
	var theObject = document.getElementById(idElement);

	if(objetCondition.checked == true)
	{
		theObject.style.display = "none";
		inputMasquage.value = 1;
	}
	else
	{
		theObject.style.display = "block";
		inputMasquage.value = 0;
	}
}

function maj_code_avantage(code_p)
{
	reponse_p =  select_nav_get("/boutique/script/maj_code_avantage.php?code="+code_p);
		
	if(reponse_p != "")
	{
		eval(reponse_p);
	}
}

function verifie_cgv()
{
	if(!document.panier)
	{
		return false;
	}
	
	if(!document.panier.accepter_cgv)
	{
		return false;
	}
	
	if(document.panier.accepter_cgv.checked == false)
	{
		var theObjectHaut = document.getElementById("alerte_cgv_haut");
		var theObjectBas = document.getElementById("alerte_cgv_bas");
		
		theObjectHaut.style.display = "block";
		theObjectBas.style.display = "block";
		
		return false;
	}
}