function getCurrentFDP()
{
	var m_currentFDP = 0.0;
	var listOptions = document.getElementsByName('choixFDP');

    for(i=0;i < listOptions.length;i++)
    {
        if (listOptions[i].checked==true){m_currentFDP = listOptions[i].value; }
    }
	return m_currentFDP;
	
}
canHidden = true;

//======================================================================================
//fonction qui permet d'ajouter un produit au panier et de basculer sur la page intermédiaire
function selectItNewGen(ean)
{ 
	var pathToSelect;
	
	pathToSelect = WebsiteURL + "/_application/_functions/addToCart.aspx?action=add&ean=" + ean + "&mode=panier" + "&doNOTdisplay=1";
	
	LoadContent(pathToSelect,"panier","Ajout au panier...","showPanUser('panier');UpdateCartInfos();");
	
	//setTimeout(function(){document.location.href = WebsiteURL + "pageIntermediaire.aspx";}, 50);
	setTimeout(function(){document.location.href = WebsiteURL + "livres/recommandations.aspx";}, 50);
}
//======================================================================================
//fonction qui permet d'ajouter un produit au panier (ou à une sélection ou whishlist)
// et d'afficher ensuite le contenu du panier dans un span(colonne de gauche)
function selectIt(ean, typeSelection, typeOfPage, nameOfPage)
{
	//alert("selectIt 1");
	
	var pathToSelect;
	var timeClose = 0;
	
	pathToSelect = WebsiteURL + "/_application/_functions/addToCart.aspx?action=add&ean=" + ean + "&mode=" + typeSelection;
	
	if (document.getElementById)
	{
		// Tristan - 14/12/2010 
		// On n'affiche plus la popup panier ! (showPanUser) 
		// On redirige vers la page des reco croisées !
		
		SpanCartObj = document.getElementById("panier");
		//Si on séléctionne un article pour le panier "principal", on update le nombre d'articles au panier.	
		if (typeSelection == 'cart') {
			//LoadContent(pathToSelect,"panier","Ajout au panier...","showPanUser('panier');UpdateCartInfos();");
			/* 
			if (nameOfPage=="recommandations") {
				LoadContent(pathToSelect, "panier", "Ajout au panier...", "UpdateCartInfos();");
			}
			else {
				LoadContent(pathToSelect, "panier", "Ajout au panier...", "showPanUser('panier');UpdateCartInfos();");
			}
			*/
			
			/*
			LoadContent(pathToSelect, "panier", "Ajout au panier...", "UpdateCartInfos();");
			setTimeout(function(){document.location.href = WebsiteURL + "livres/recommandations.aspx";}, 1000);
			*/
			document.location.href = WebsiteURL + "livres/recommandations.aspx?ean=" + ean;
			
		} 
		else {
			//Sinon, on fait la meme action, mais sans mettre à jour le nombre d'articles au panier principal
			LoadContent(pathToSelect,"panier", "Ajout au panier...", "showPanUser('panier')");
			/*
			LoadContent(pathToSelect,"panier", "Ajout au panier...", "");
			setTimeout(function(){document.location.href = WebsiteURL + "livres/recommandations.aspx";}, 50);
			*/
		}
		
		SpanCartObj.style.top = yMousePos + "px";
		SpanCartObj.style.left = (xMousePos - (parseInt(SpanCartObj.style.width)/2)) + "px";
		
		if (nameOfPage.length > 0) {
			nameOfPage += "_";
		}
		
		nameOfPage += typeSelection + "::" + ean;
		
		xt_med('F', typeOfPage , nameOfPage);
	}
	
} 


function selectIt(ean, typeSelection, typeOfPage, nameOfPage, fromWish, dispoID)
{
	// Tristan - 25/01/2011 : ajout du paramètre dispoID... 
	//alert(" ean=[" + ean + "] \n typeSelection=[" + typeSelection + "] \n typeOfPage=[" + typeOfPage + "] \n nameOfPage=[" + nameOfPage + "] \n fromWish=[" + fromWish + "] \n dispoID=[" + dispoID + "]");
	
	var pathToSelect;
	var timeClose = 0;
	
	pathToSelect = WebsiteURL + "/_application/_functions/addToCart.aspx?action=add&ean=" + ean + "&mode=" + typeSelection + "&fromWish=" + fromWish;
	//alert("selectIt...\n\n" + pathToSelect);
	
	/* Cas de l'ajout à la sélection sur la page intermédiaire */
	//if (nameOfPage == "pageIntermediaire" && typeSelection=="selection")
	if ( nameOfPage=="recommandations" && typeSelection=="selection" )
	{
		//LoadContent(pathToSelect + "&doNOTdisplay=1","panier","", "showPanUser('panier');");
		LoadContent(pathToSelect + "&doNOTdisplay=1","panier","", "");
		
		var URIpath = docRoot + "/_application/_functions/_ajax/loadCartColonneDroite.aspx?type=selection";
		
		LoadContent(URIpath, "colDroite_selection", "");
	}
	else
	{
		if (document.getElementById)
		{
			SpanCartObj = document.getElementById("panier");
			
			// Tristan - 14/12/2010 
			// On n'affiche plus la popup panier ! On redirige vers la page des reco croisées !
			
			if (typeSelection == 'cart') 
			{
				//Si on séléctionne un article pour le panier "principal", on update le nombre d'articles au panier.	
				
				// Tristan - 04/01/2011 
				if (nameOfPage!="IND") 
				{
				    /*
					LoadContent(pathToSelect,"panier","Ajout au panier...","UpdateCartInfos();");
					setTimeout(function(){document.location.href = WebsiteURL + "livres/recommandations.aspx";}, 50);
					*/
					if (dispoID!='AP' && dispoID!='IND' && dispoID!='NDI') 
					{
					    //LoadContent(pathToSelect + '&xmldispo=' + dispoID,"panier","Ajout au panier...","UpdateCartInfos();");
					    //setTimeout(function(){document.location.href = WebsiteURL + "livres/recommandations.aspx";}, 1000);
					    
						
						//-----------------------------------------------------
						// Tristan - 28/09/2011 
						//-----------------------------------------------------
					    //document.location.href = WebsiteURL + "livres/recommandations.aspx?ean=" + ean + "&fromWish=" + fromWish;
						//-----------------------------------------------------
						if (fromWish != '' && fromWish > 0) {
							//alert(" fromWish = [" + fromWish + "]\n EAN = [" + ean + "]\n typeSelection = [" + typeSelection + "]\n\n pathToSelect =\n " + pathToSelect);
							LoadContent(pathToSelect + '&xmldispo=' + dispoID, "panier", "Ajout au panier...", "showPanUser('panier');");
							UpdateCartInfos();
						}
						else {
							document.location.href = WebsiteURL + "livres/recommandations.aspx?ean=" + ean + "&fromWish=" + fromWish;
						}
						//-----------------------------------------------------
						
					}
					else {
					    LoadContent(pathToSelect,"panier","Ajout au panier...","showPanUser('panier');UpdateCartInfos();");
					}
				}
				else {
					LoadContent(pathToSelect,"panier","Ajout au panier...","showPanUser('panier');UpdateCartInfos();");
				}
				
			}
			else {
				//Sinon, on fait la meme action, mais sans mettre à jour le nombre d'articles au panier principal
				//alert('LoadContent : \n' + pathToSelect);
				LoadContent(pathToSelect, "panier", "Ajout au panier...", "showPanUser('panier');");
				//LoadContent(pathToSelect,"panier", "Ajout au panier...", "");
			}
			
			if (nameOfPage.length > 0) {
				nameOfPage += "::";
			}
			
			
			if (nameOfPage.split("::").length == 4) {
				nameOfPage += "clickAjax_add_" + typeSelection + "_" + ean;
			}
			else {
				nameOfPage += "clickAjax_add_" + typeSelection + "::" + ean;
			}
			
			xt_med('F', typeOfPage , nameOfPage);
		}
	}
} 

function showPanUser(idSpan)
{
	var trace = "showPanUser('" + idSpan + "') :\n xMousePos = " + xMousePos + "\n yMousePos = " + yMousePos;
	
	var curPage = new structure_dimensionAndScrol();
	var	SpanCartObj = document.getElementById(idSpan);
	var divChildNode = SpanCartObj.childNodes[0];
	var tableNode = null;
	
	trace += "\n\n SpanCartObj.offsetWidth = " + SpanCartObj.offsetWidth + "\n SpanCartObj.offsetHeight = " + SpanCartObj.offsetHeight;
	
	
	SpanCartObj.style.visibility='visible';
	
	
	document.getElementById("sub-container").onclick= function () {
		CloseCart(idSpan);
		document.getElementById("sub-container").onclick= function () {};
	};
 
	/*
	if (!divChildNode.childNodes[0]) {
		divChildNode = SpanCartObj.childNodes[1];
	}

	tableNode = divChildNode.childNodes[0];
	
	if (!tableNode.childNodes[0]) {
		tableNode = divChildNode.childNodes[1];
	}
	
	
	var height_plus_scrol = curPage.height + curPage.scroll_y;
	var width_plus_scrol =  curPage.width + curPage.scroll_x;
	
	
	if (height_plus_scrol < yMousePos + tableNode.clientHeight) {
		SpanCartObj.style.top = (height_plus_scrol - (tableNode.clientHeight+15)) + "px";
	}
	else {
		SpanCartObj.style.top = (yMousePos ) + "px";
	}
	
	
	if (width_plus_scrol < (xMousePos + (tableNode.clientWidth / 2))) {
		SpanCartObj.style.left = (width_plus_scrol - (tableNode.clientWidth + 40)) + "px";
	}
	else {
		SpanCartObj.style.left = (xMousePos - (tableNode.clientWidth / 2)) + "px";
	}
	*/
	
	SpanCartObj.style.top = (yMousePos ) + "px";
	SpanCartObj.style.left = (xMousePos - (SpanCartObj.offsetWidth / 2)) + "px";
	
	
	trace += "\n\n SpanCartObj.style.left = " + SpanCartObj.style.left + "\n SpanCartObj.style.top = " + SpanCartObj.style.top;
	//alert(trace);
	
	
	SpanCartObj.style.zIndex=100;
}
function showPanUser___BAK20110930(idSpan)
{
	var curPage = new structure_dimensionAndScrol();
	var	SpanCartObj = document.getElementById(idSpan);
	var divChildNode = SpanCartObj.childNodes[0];
	var tableNode = null;
	
	SpanCartObj.style.visibility='visible';
	
	document.getElementById("sub-container").onclick= function () {
		CloseCart(idSpan);
		document.getElementById("sub-container").onclick= function () {};
	};
 
	if (!divChildNode.childNodes[0]) {
		divChildNode = SpanCartObj.childNodes[1];
	}

	tableNode = divChildNode.childNodes[0];
	
	if (!tableNode.childNodes[0]) {
		tableNode = divChildNode.childNodes[1];
	}
	 
	var height_plus_scrol = curPage.height + curPage.scroll_y;
	var width_plus_scrol =  curPage.width + curPage.scroll_x;
	
	
	if (height_plus_scrol < yMousePos + tableNode.clientHeight) {
		SpanCartObj.style.top = (height_plus_scrol - (tableNode.clientHeight+15)) + "px";
	}
	else {
		SpanCartObj.style.top = (yMousePos ) + "px";
	}
	
	
	if (width_plus_scrol < (xMousePos + (tableNode.clientWidth / 2))) {
		SpanCartObj.style.left = (width_plus_scrol - (tableNode.clientWidth + 40)) + "px";
	}
	else {
		SpanCartObj.style.left = (xMousePos - (tableNode.clientWidth / 2)) + "px";
	}
	
	SpanCartObj.style.zIndex=100;
}

function showPan(idPan)
{
	pan = document.getElementById(idPan);	
	
	if(pan != null)
	{
		if (pan.style.visibility != "visible")
		{
		
			if (isNaN(yMousePos))
			{
				pan.style.top = "0px";
				pan.style.left = "0px" ;
				pan.style.visibility = "visible";
				pan.style.display = "block";
				
			}
			else
			{
				pan.style.top = yMousePos + "px";
				pan.style.left = ( xMousePos - (pan.width / 2) )  + "px" ;
				pan.style.visibility = "visible";
				pan.style.display = "block";
			}
			
		}
		else
		{
			pan.style.visibility = "hidden";
			pan.style.display = "none";
		}
	}
	
	document.onclick = function()
	{
		
		if (document.getElementById("adressLivraison") != null && canHidden )
		{
			document.getElementById("adressLivraison").style.visibility = "hidden"
			document.getElementById("adressLivraison").style.display = "none"
		}
		
		if (document.getElementById("adressFact") != null && canHidden)
		{
			document.getElementById("adressFact").style.visibility = "hidden"		
			document.getElementById("adressFact").style.display = "none"
		}
		
		if (canHidden)
		{		document.onclick = function () {}}
		else
		{canHidden = true}
	};
}

function showPPan(idPan)
{

	pan = document.getElementById(idPan);	
	
	if(pan != null)
	{
		if (pan.style.visibility != "visible")
		{
		
				pan.style.top = "320px";
				pan.style.left = "250px" ;
				pan.style.visibility = "visible";
				pan.style.display = "block";

						
		}
		else
		{
			pan.style.visibility = "hidden";
			pan.style.display = "none";
		}
	}
	
	document.onclick = function()
	{
		
		if (document.getElementById("adressLivraison") != null && canHidden )
		{
			document.getElementById("adressLivraison").style.visibility = "hidden"
			document.getElementById("adressLivraison").style.display = "none"
		}
		
		if (document.getElementById("adressFact") != null && canHidden)
		{
			document.getElementById("adressFact").style.visibility = "hidden"	
			document.getElementById("adressFact").style.display = "none"	
		}
		
		if (canHidden)
		{		document.onclick = function () {};		}
		else
		{canHidden = true;}
	};
}
 
function CloseCart(idCart)
{
	if (document.getElementById)
	{
			SpanCartObj = document.getElementById(idCart);
			SpanCartObj.style.visibility='hidden';				
	}	
}
 


//======================================================================================
//Met à jour le <span> ou est indiqué le nombre d'articles au panier
function UpdateCartInfos()
{
	var pathToSelect;
	pathToSelect = WebsiteURL + "/_application/_functions/addToCart.aspx?action=getTotal";	
	if (document.getElementById)
	{
		LoadContent(pathToSelect,"cartInfosTop","...", "");
		LoadContent(pathToSelect,"cartInfos","...", "majTexteFdp()");

	}
}
//======================================================================================


//======================================================================================
//fonction qui ferme l'affichage du panier après un ajout
function closeCart(idCart)
{
	if (document.getElementById)
	{
		SpanCartObj = document.getElementById(idCart);
		SpanCartObj.innerHTML = "";
		SpanCartObj.style.visibility='hidden';
	}
} 


//======================================================================================
function PanierProcure(thisEan, qte, isMaj)
{
	this.ean = thisEan;
	this.quantite = qte;

	this.majTexteFdp = function()
	{
		if (document.getElementById("promo_fdp") )
		{
			var MyXhr = new XHR();
			var url = docRoot + "/ajax/ajax_request.aspx?idControl=51";
			MyXhr.open("POST", url, true);
			
			MyXhr.onreadystatechange = function() 
			{
				if(MyXhr.readyState == 4 && MyXhr.status == 200) 
				{
					document.getElementById("promo_fdp").innerHTML = MyXhr.responseText;
				}
			}
			
			MyXhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			MyXhr.send("");	
		}


	}
	
	this.UpdateQuantite = function()
	{
	
		var elm_qte = document.getElementById(this.ean);
		
		if (isNaN(this.quantite) || this.quantite < 1)
		{ 
			this.quantite = 1 ;
			elm_qte.value = this.quantite
		}
		else if (this.quantite != parseInt(this.quantite))
		{
			this.quantite = parseInt(this.quantite);
			elm_qte.value = this.quantite
		}
		else if (this.quantite.charAt(this.quantite.length - 1) == '.')
		{
			this.quantite = this.quantite.substr(0,this.quantite.length - 1);
			elm_qte.value = this.quantite
		}
		
		URIpath = "/_application/_functions/addToCart.aspx?action=updateQte&idProd="  + this.ean + "&qte=" + this.quantite;
		
		var self = this;
		/*self = this;*/
	

		LoadContent(URIpath,"Qte_"+ this.ean ,"", "self.majTexteFdp();self.UpdateTotalPanier()");
		
				

		/*MyXhr.onreadystatechange = function() 
		{
			if(MyXhr.readyState == 4 && MyXhr.status == 200) 
			{
				objQte.innerHTML = MyXhr.responseText;
				UpdateTotalPanier(idCart)
			}
		}
		objQte.innerHTML ="...";
		MyXhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		MyXhr.send("");	*/
		
		//on n'oublie pas de mettre a jour le total d'article dans le menu selection, en entete de page
		UpdateCartInfos()
	}
	

	//======================================================================================	
	//Fonction qui recalcule et affiche le total du panier 
	//la quantité.	
	this.UpdateTotalPanier = function()
	{
		
		var MyXhr = new XHR();
		var url = docRoot + "/_application/_functions/addToCart.aspx?action=totalCart";
		MyXhr.open("POST", url, true);
		
		MyXhr.onreadystatechange = function() 
		{
			if(MyXhr.readyState == 4 && MyXhr.status == 200) 
			{
				eval(MyXhr.responseText);
			}
		}
		document.getElementById('TotalCart').innerHTML = "..."
		if (document.getElementById('TotalCartReduc'))
		{
			document.getElementById('TotalCartReduc').innerHTML = "..."
		}
		
		
		MyXhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		MyXhr.send("");	
	}	
	
	
	if (isMaj == 1)
	{
		this.UpdateQuantite();
	}
//======================================================================================	
} 




//======================================================================================
//fonction qui récupère le frais de port actuellement selectionné

//======================================================================================

function print_confitionGeneral(fromCart)
{
	var pathToSelect;
	var timeClose = 0;
	pathToSelect = WebsiteURL + "/ajax/ajax_request.aspx?idControl=54&fromCart=" + fromCart;
	 LoadContent(pathToSelect,"cgv_span","Chargement des conditions general...","showPanUser('cgv_span');");
}
 
function print_conditiondedicace()
{
	var pathToSelect;
	var timeClose = 0;
	pathToSelect = WebsiteURL + "/ajax/ajax_request.aspx?idControl=55";
	 LoadContent(pathToSelect,"cgv_span","Chargement des conditions general...","showPanUser('cgv_span');");
}

  
function trim(s) {
    return s.replace(/^\s+/, '').replace(/\s+$/, '');
}

function showCarteProcure()
{
	var blocCarte = document.getElementById('carteProcure');	

	if (blocCarte.style.visibility != "visible")
	{
		blocCarte.style.top = (yMousePos + 10) + "px";
		blocCarte.style.left = (xMousePos - 200)    + "px";
		blocCarte.style.visibility = "visible";
		
		document.getElementById('txt_numCarte').focus();
	}
	else
	{
		blocCarte.style.visibility = "hidden";
	}
}

function showPromotion()
{
	var blocPromo = document.getElementById('promo');	

	if (blocPromo.style.visibility != "visible")
	{
		blocPromo.style.top = yMousePos + "px";
		blocPromo.style.left = ( xMousePos - 200 )    + "px";
		blocPromo.style.visibility = "visible";
		
		document.getElementById('txt_promotion').focus();
	}
	else
	{
		blocPromo.style.visibility = "hidden";
	}
}

function closeCarteProcure()
{
	document.getElementById("carteProcure").style.visibility='hidden';
	document.getElementById('txt_numCarte').blur();
}

function closePromotion()
{
	document.getElementById("promo").style.visibility='hidden';
	document.getElementById('txt_promotion').blur();
}


//======================================================================================
 


//======================================================================================
// Fonction qui permet de sélectionner un mode de livraison
function ChooseFDP(idFDP)
{
	// mise a jour du bloc papier cadeau si Livraison Rapide
	// LivRapide_fdpID est une variable instancié dans le Header
	
	/*
	if (idFDP == LivRapide_fdpID)
	{
		document.getElementById("KDO").checked = false;
		document.getElementById("KDO").disabled = true;
		document.getElementById("MsgCommande").value = "";
		document.getElementById("MsgCommande").disabled = true;
		document.getElementById("btnCheque").style.visibility = "hidden";
		}else{
		document.getElementById("KDO").disabled = false;
		document.getElementById("MsgCommande").disabled = false;
		document.getElementById("btnCheque").style.visibility = "visible";
	}
	*/			
	
	if (idFDP == "undefined"){return false;}
	
	var MyXhr = new XHR();
	var url = docRoot + "/_application/_functions/_ajax/SelectFDP.aspx?idFDP=" + idFDP;
	//alert(url);
	MyXhr.open("POST", url, true);

	MyXhr.onreadystatechange = function() 
	{
		if(MyXhr.readyState == 4 ) 
		{
			if (MyXhr.status == 200)
			{
			
				eval(MyXhr.responseText); //  => updateZoneFDP
				//objMain.innerHTML = MyXhr.responseText;		
			}
		}	
	}
	
	MyXhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	MyXhr.send("");
}

// End function ChooseFDP() 



//======================================================================================
// Fonction qui permet de mettre à jour le contenu de la zone frais de port
// et Total commandedu récapitultif de commande
function updateZoneFDP(fdpVal,CmdAmount,CmdAmountReduc, isHT)
{
	total = parseFloat(CmdAmount) + parseFloat(fdpVal);
	totalReduc = parseFloat(CmdAmount) - parseFloat(CmdAmountReduc);

	// Mise à jour de la valeur total du panier
	document.getElementById("TotalCart2").innerHTML = parseFloat(CmdAmount).toFixed(2).replace( '.', ',' );
	
	// Mise à jour de la valeur TTC/HT
	document.getElementById("isHT2").innerHTML = isHT;
	document.getElementById("isHT3").innerHTML = isHT;
	
	// Mise à jour de la value du total panier réduc si il existe
	if (document.getElementById("TotalCartReduc2"))
	{
		document.getElementById("TotalCartReduc2").innerHTML = parseFloat(totalReduc).toFixed(2).replace( '.', ',' );
		total -= parseFloat(CmdAmountReduc);
	}
	
	
	// mise a jour du frais de port
	document.getElementById("fdp").innerHTML = parseFloat(fdpVal).toFixed(2).replace( '.', ',' );
	
	// mise à jour du total global
	document.getElementById("totalCmd").innerHTML = total.toFixed(2).replace( '.', ',' );
			
}
// End function updateZoneFDP() 


function majTexteFdp()
{
	if (document.getElementById("promo_fdp") )
	{
			var MyXhr = new XHR();
			var url = docRoot + "/ajax/ajax_request.aspx?idControl=52";
			MyXhr.open("POST", url, true);
			
			MyXhr.onreadystatechange = function() 
			{
				if(MyXhr.readyState == 4 && MyXhr.status == 200) 
				{
					document.getElementById("promo_fdp").innerHTML = MyXhr.responseText;
				}
			}
			
			MyXhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			MyXhr.send("");	
		}


	}

	
	//======================================================================================		
//Fonction de (dé)sélection de tous les articles ds la liste de résultats des recherches simple et thématique 
function selectAll(form_name,SenderName) 
{
	var FormObj = eval("document." + form_name);
	senderObj = eval("document." + form_name + "." + SenderName);
	if (senderObj.checked)
	{
		checkIt= true;
	}
	else
	{
		checkIt= false;
	}
	
	for(i=0; i < FormObj.length ; i++)
	{
		if (FormObj.elements[i].type=='checkbox')
		{
			var E = FormObj.elements[i];
			E.checked = checkIt;
		}
	}
	
} // End function selectAllBooks() 


//======================================================================================
// Fonction qui supprime tous les articles cochés du panier puis recharge le panier à la page courante
function DeleteSelectedITems()
{
	if (confirm("\312tes-vous s\373r de vouloir supprimer les \351l\351ments coch\351s ?"))
	{
		document.cartForm.action= WebsiteURL + "/_application/_functions/addToCart.aspx?action=DelSelection";
		document.cartForm.submit();
	}
	
}
// End function DeleteSelectedITems() 

//======================================================================================
// Tristan - 04/07/2011 
// Suppression d'un article dans une liste de sélection 
//======================================================================================
function DeleteSelectionLine(lineId)
{
	if (confirm("\312tes-vous s\373r de vouloir supprimer cet article de votre s\351lection ?"))
	{
		document.cartForm.action= WebsiteURL + "/_application/_functions/addToCart.aspx?action=DeleteSelectionLine&lineId=" + lineId;
		document.cartForm.submit();
	}
	
}


//=============================================================================================
// Fonction qui surrime tous les articles du panier puis recharge le panier à la page courante
//=============================================================================================
function DeleteAllItems()
{
	if (confirm("\312tes-vous s\373r de vouloir vider ce panier ?"))
	{
		document.cartForm.action= WebsiteURL + "/_application/_functions/addToCart.aspx?action=DelAll";
		document.cartForm.submit();
	}
}
// End function DeleteAllItems() 


//======================================================================================
// Fonction qui importe une liste d'ean vers le panier principal
function ImportListEan()
{
	document.cartForm.action= WebsiteURL + "/_application/_functions/addToCart.aspx?action=import_list_to_panier";
	document.cartForm.submit();
}
// End function ImportListEan() 

//======================================================================================
// Tristan - 04/07/2011 
// Export d'un article d'une liste de sélection vers un panier 
//======================================================================================
function moveToCart(lineId)
{
	if (confirm("Voulez-vous vraiment transf\351rer cet article de votre s\351lection vers votre panier ?"))
	{
		document.cartForm.action= WebsiteURL + "/_application/_functions/addToCart.aspx?action=moveToCart&lineId=" + lineId;
		document.cartForm.submit();
	}
	
}

//======================================================================================
// Tristan - 06/07/2011 
// Export d'un article du panier vers la liste de sélection 
//======================================================================================
function moveToSel(isLogged, lineId, reco)
{
	var scriptUrl = WebsiteURL + "/_application/_functions/addToCart.aspx?action=moveToSel&lineId=" + lineId;
	if (reco != undefined && reco == 'reco') {
		scriptUrl += "&reco=" + reco;
	}
	
	
	if (isLogged == 1) 
	{
		if (confirm("Voulez-vous vraiment transf\351rer cet article de votre panier vers votre s\351lection ?"))
		{
			document.cartForm.action = scriptUrl;
			document.cartForm.submit();
		}
	}
	else 
	{
		// Là on n'est pas connecté, donc on affiche la popup avec message de connexion 
		if (document.getElementById) 
		{
			SpanCartObj = document.getElementById("panier");
			LoadContent(scriptUrl, "panier", "Ajout \340 votre s\351lection...", "showPanUser('panier');");
		}
	}
	
}

//======================================================================================
// Tristan - 06/07/2011 
// Export d'un article d'une liste de sélection vers une liste cadeaux 
//======================================================================================
function moveToKdo(isLogged, ean, nbListKdo, idListKdo, modeFrom, reco)
{
	var mode = 'wishlist'; // on ajoue à une wishlist (kdo) 
	var fromWish;
	var strJs_mode;
	
	if (modeFrom=='selection') {
		fromWish = 'sel'
		strJs_mode = 's\351lection';
	}
	else if (modeFrom=='cart') {
		fromWish = 'cart'
		strJs_mode = 'panier';
	}
	
	
	var confirmTransfert = true;
	if (isLogged == 1 && idListKdo <= 0) {
		confirmTransfert = confirm("Voulez-vous vraiment transf\351rer cet article de votre " + strJs_mode + " vers votre liste cadeaux ?");
	}
	
	if (confirmTransfert)
	{
		if (isLogged == 0 || (isLogged == 1 && nbListKdo > 1)) 
		{
			// Si on n'est pas connecté, ou si on l'est avec plusieurs listes kdo en base 
			// on affiche la popup listes kdo... 
			var pathToSelect = WebsiteURL + "/_application/_functions/addToCart.aspx?action=add&ean=" + ean + "&mode=" + mode + "&fromWish=" + fromWish;
			if (reco != undefined && reco == 'reco') {
				pathToSelect += "&reco=" + reco;
			}
			
			if (document.getElementById) {
				SpanCartObj = document.getElementById("panier");
				LoadContent(pathToSelect, "panier", "Ajout \340 la liste cadeaux...", "showPanUser('panier');");
			}
		}
		else 
		{
			// Si on est connecté avec 0 ou 1 liste kdo en base 
			var scriptUrl = WebsiteURL + "/_application/_functions/addToCart.aspx?action=moveToKdo&ean=" + ean + "&mode=" + mode + "&fromWish=" + fromWish;
			if (idListKdo > 0) {
				scriptUrl += "&addInWish=" + idListKdo;
			}
			if (reco != undefined && reco == 'reco') {
				scriptUrl += "&reco=" + reco;
			}
			
			document.cartForm.action = scriptUrl
			document.cartForm.submit();
		}
	}
}


//======================================================================================
// Fonction qui supprime la liste séléctionnée par le libraire
function DeleteListeLibr()
{
	if (confirm("\312tes-vous s\373r de vouloir supprimer cette s\351lection ?"))
	{
		document.listLibrForm.action= WebsiteURL + "/_application/_functions/addToCart.aspx?action=DelListLibr";
		document.listLibrForm.submit();
	}
}
// End function DeleteListeLibr() 


/****************************************************
 ************* FUNCTION LISTE_LIBRAIRE **************
 ****************************************************/
function Liste_libraire(idCheckBox, idTextBox, idSpan, ean, prixTTC, onChecked)
{
	// onChecked --> si 1, le déclanchement vient du faite que l'utilisateur à coché la checkbox, 
	//				 si 0, L'utilisateur vient de remplir la texteBox
	elmt_checkBox = document.getElementById(idCheckBox);
	elmt_textBox = document.getElementById(idTextBox);
	elmt_span = document.getElementById(idSpan);
	
	str_ean = ean;
	float_prixTTC = prixTTC;
	
	var idOf_bookSel = 'nbrBookSel'; // l'id de la zone ou on renseigne le nombre de titres choisis par l'utilisateur

	
	this.onTextBox_changed = function()
	{
		// si la textBox est pas remplis, on la met à 0
		if (elmt_textBox.value.length == 0 || !(elmt_textBox.value > 0)) 
		{
			elmt_textBox.value = 0;
			elmt_checkBox.checked = false;
		}
		// si la checkBox n'est pas coché, on renseigne à 0
		else if (!elmt_checkBox.checked){elmt_checkBox.checked = true;}

		// on calcul le nouveau sous total de la ligne !
		this.calcSousTotal_listLibr()
	}
	
	this.onCheckBox_checked = function()
	{
		if (elmt_checkBox.checked && (elmt_textBox.value.length == 0 || !(elmt_textBox.value > 0)))
		{
			elmt_textBox.value = 1;
		}
		
		// on calcul le nouveau sous total de la ligne !
		this.calcSousTotal_listLibr()
	}
	
	
	this.calcSousTotal_listLibr = function()
	{
		quantite = '';
		
		// si la checkBox est non coché, on spécifie une valeur vbidon pour la quantité
		if (elmt_checkBox.checked) 
		{quantite = elmt_textBox.value;}
		if (!elmt_checkBox.checked) 
		{quantite = 'vide'}
		
		if (quantite > 0)
		{
			// si la checkBox n'est pas coché, on la coche		
			if (!elmt_checkBox.checked){elmt_checkBox.checked = true;}
			
			// on met a jour le sous total de la ligne, en fonction du prix de la ligne et de la quantité choisis
			elmt_span.innerHTML = "<em>Sous total <b>" + parseFloat(quantite * parseFloat(float_prixTTC).toFixed(2)).toFixed(2).replace( '.', ',' ) + " &euro;</b></em>"
		
		}
		else if (elmt_checkBox.checked)
		{
			elmt_textBox.value = 1;
			// on met a jour le sous total de la ligne, en fonction du prix de la ligne et de la quantité choisis
			elmt_span.innerHTML = "<em>Sous total <b>" + parseFloat(elmt_textBox.value * parseFloat(float_prixTTC).toFixed(2)).toFixed(2).replace( '.', ',' ) + " &euro;</b></em>"
		}
		else
		{
			// on vide le sous total
			elmt_span.innerHTML = ""
			
			// on decoche la checkBox si elleetait coché
			if (!elmt_checkBox.checked){elmt_checkBox.checked = false;}
		
			quantite = 'vide';
		}
	

			
		// on se rend via AJAX airline dans le processus de maj		
		URIpath = docRoot + '/ajax/ajax_request.aspx?idControl=99&ean='+ ean +'&qte=' + quantite; 	  

		// puis on effectue le tout
		LoadContent(URIpath,idOf_bookSel,"","");
	}
	
	
	if (onChecked ==1)
	{this.onCheckBox_checked();}
	else
	{this.onTextBox_changed();}
}
 
 
function valid_formDedicace(myForm)
{
	labelName = myForm.dest_forDedicace;
	areaContent = myForm.content_forDedicace;
	checkDedicace = myForm.check_forDedicace;
	reussite = false;
		
	if (checkDedicace.checked == true)
	{
		if (labelName.value != '')
		{
			reussite = true;
			} else {
			alert('Un destinataire est requis pour cette demande de dedicace.');
		}
	} else {
		if (labelName.value != '')
		{
			reussite = confirm('Etes-vous certain de vouloir annuler votre demande de dedicace ?');
			} else {
			reussite = true;
		}
	}
	
	return reussite;
}



