var timerFader;
var isYes;
unSubmit = false;
cmdClick = false;

function cmdClickHREF()
{
	if (cmdClick || (document.getElementById('txt_numCarte') && document.getElementById('txt_numCarte').value.length == 0)) unSubmit = false;
	if (unSubmit) cmdClick = true;
 
	return !unSubmit;
}
/********************************************************************************************
 ************************************ BLOC PROMOTION ************************************
 ********************************************************************************************/
function promotion()
{
	  msg_noPromo = "<nobr><span id='error_promotion'>D&eacute;sol&eacute;, aucun code  ne correspond &agrave; la saisie : </span></nobr>";
	  msg_invalidePromo = "<nobr><span id='error_promotion'>D&eacute;sol&eacute;, votre code n'est plus valide : </span></nobr>";
	  msg_PromoExist = "<nobr><span id='error_promotion'>Chargement de votre promotion.</span></nobr>";
	  msg_numPromoVide = "<nobr><span id='error_promotion'>Veuillez saisir un code promotionnel.</span></nobr>";
	  msg_lastPromo_isBest = "<nobr><span id='error_promotion'>Vous disposez d&eacute;j&agrave; d'une promotion plus int&eacute;ressante.</span></nobr>";
	  // maj 27/02/2009, par d.guillard
 	  var idOf_error = "error_promotion";
	  var idOf_error_bis = "label_promotion";
	
	this.codePromotion = "";
	
	
	this.Validate_Form_promotion	= function(Txt_value)
	{
		this.codePromotion = Txt_value;
		
		if(this.codePromotion != '')
		{
			this.Load_promotion(Txt_value);
		}
	}
	
	
	//======================================================================================
	//Charge une carte procure à partir d'un formulaire ajax
	//Add le 22/03/2007 par Christophe Bonvallet
	this.Load_promotion = function(Txt_value)
	{
		var MyXhr = new last_httpRequest(docRoot + '/ajax/ajax_request.aspx', 'idControl=53&needReload=1&codePromo=' + this.codePromotion, 'POST');
		curId = idOf_error;

		if (!document.getElementById(curId))
		{curId  = idOf_error_bis ;}



		
						document.getElementById(curId).innerHTML = "<nobr>V&eacute;rification du code promotionnel en cours</nobr>";
	
		MyXhr.createRequestObject();
		MyXhr.sendPostReq();

		MyXhr.xmlHttp.onreadystatechange = function() 
		{	// alert(MyXhr.xmlHttp.status);
			 if(MyXhr.xmlHttp.readyState == 4)
			 {
			 
					var codeRetour = MyXhr.xmlHttp.responseText;
 
					// All Good !
					if (codeRetour == 1)
					{
						document.getElementById(curId).innerHTML = msg_PromoExist;
						if (cmdClick) 
						{document.location.href = docRoot + '/commandes/index.aspx';}
						else 
						{document.location.reload(); }
					}
					else if (codeRetour == 0)
					{
						cmdClick = false;unSubmit=false;
						document.getElementById(curId).innerHTML = msg_lastPromo_isBest;					
					}
					else if (codeRetour == -1)
					{
						cmdClick = false;unSubmit=false;
						// maj le 27/02/2009 par d.guillard
						//document.getElementById(idOf_error).innerHTML = msg_invalidePromo + Txt_value + '</nobr>';
						document.getElementById(curId).innerHTML = msg_invalidePromo;
					} // carte inconnu
					else if (codeRetour < -1)
					{
						cmdClick = false;unSubmit=false; 
						// maj le 27/02/2009 par d.guillard
						//document.getElementById(idOf_error).innerHTML = msg_noPromo + Txt_value  + '</nobr>';
						document.getElementById(curId).innerHTML = msg_noPromo;
					} 
			}	
		}
	}
}

/********************************************************************************************
 ************************************ BLOC CARTE PROCURE ************************************
 ********************************************************************************************/
function carteProcure()
{
	msg_noCarte = "<nobr>D&eacute;sol&eacute;, aucune carte ne correspond au num&eacute;ro saisi.</nobr>";
	msg_invalideCarte = "<nobr>D&eacute;sol&eacute;, la validit&eacute; de votre carte est expir&eacute;.</nobr>";
	msg_carteExist = "<nobr>Num&eacute;ro saisie valide.</nobr>";
	msg_numVide = "<nobr>Veuillez saisir un num\351ro de carte La Procure.</nobr>";
	idOf_error = "error_numCarte"
	this.carteProcure = "";
	
	
	this.Validate_Form_carteProcure	= function(Txt_value)
	{
		this.carteProcure = Txt_value;
		
		if(this.carteProcure != '')
		{
			this.Load_carteProcure();
		}
	}
	
	
	//======================================================================================
	//Charge une carte procure à partir d'un formulaire ajax
	//Add le 22/03/2007 par Christophe Bonvallet
	this.Load_carteProcure = function()
	{
		var MyXhr = new last_httpRequest(docRoot + '/ajax/ajax_request.aspx', 'idControl=3&needReload=1&numCarte_procure=' + this.carteProcure, 'POST');
	
	
		MyXhr.createRequestObject();
		MyXhr.sendPostReq();

		MyXhr.xmlHttp.onreadystatechange = function() 
		{	
			if(MyXhr.xmlHttp.readyState == 4 ) 
			{
			
				if (MyXhr.xmlHttp.status == 200)
				{
					var codeRetour = MyXhr.xmlHttp.responseText;
		
		
					// All Good !
					if (codeRetour == 1)
					{
						if (cmdClick) document.location.href = docRoot + '/commandes/index.aspx';
						else document.location.reload();
						

					
					}else if (codeRetour == -1)
					{cmdClick = false;unSubmit=false;
						document.getElementById(idOf_error).innerHTML = msg_invalideCarte;
					} // carte inconnu
					else
					{cmdClick = false;unSubmit=false;
						document.getElementById(idOf_error).innerHTML = msg_noCarte;
					}
						
				}
				else
				{cmdClick = false;unSubmit=false;
					ShowDebugMsg(MyXhr.responseText)
				}
			}	
		}
	}
}
	//======================================================================================
	//Fonction qui teste un numero de carte procure, et effectue une fonction suivant la validité du numero
	//Add le 22/03/2007 par D.Guillard
	function Is_CarteValid(numCarte)
	{
		//Si l'utilisateur ne saisie pas de numero carte procure, on passe à la phase de soumission du formulaire
		if (numCarte != '')
		{
			var MyXhr = new XHR();
			var URIpath = docRoot + "/ajax/ajax_request.aspx?idControl=3&numCarte_procure=" + numCarte + "&mod=isValid";
			Check_CarteProcure_byXHR(URIpath,numCarteBon,numCarteFaux);
		} else {
			numCarteBon();
		}
	}
	
	//======================================================================================
	//Fonction qui test un numero de carte procure, et effectue une fonction suivant la validité du numero
	//Add le 22/03/2007 par D.Guillard
	function Check_CarteValid(numCarte)
	{
		//Si l'utilisateur ne saisie pas de numero carte procure, on passe à la phase de soumission du formulaire
		if (numCarte != '')
		{
			var MyXhr = new XHR();
			var URIpath = docRoot + "/ajax/ajax_request.aspx?idControl=3&numCarte_procure=" + numCarte + "&mod=isValid";
			Check_CarteProcure_byXHR(URIpath,numCarteOk,numCarteNoOk);
		} else {
			numCarteOk();
		}
	}

//======================================================================================
// Check et soumet le formulaire de recherche reference catalogue	
function Validate_FormCatalogue_recherche(Txt_value,Id_ofCatalogue)
{

	if (Txt_value != '')
	{
		Recherche_CatReference(Txt_value,Id_ofCatalogue);
	} else {
		alert('Veuillez saisir une r\351f\351rence catalogue.');
		document.getElementById('error_Reference_' + Id_ofCatalogue).innerHTML = "";	
	}
}
//======================================================================================
//Recherche un Ean à partir d'une référence catalogue
//Add le 22/03/2007 par D.Guillard
function Recherche_CatReference(Reference,Typecat)
{

		var MyXhr = new XHR();
		var errorMSG1 = '<font color="red">D&eacute;sol&eacute;, cette r&eacute;f&eacute;rence ne correspond &agrave; aucun produit du catalogue actuel</font>';
		var errorMSG2 = '<font color="red">D&eacute;sol&eacute;, cette notice est actuellement indisponible</font>';
		var errorSecondTest = 'errorElectre';
		var URIpath = docRoot + "/ajax/ajax_request.aspx?idControl=2&ReferenceCat=" + Reference + "&typeCat=" + Typecat;

		RedirectionContent(URIpath,"error_Reference_" + Typecat,Reference,errorMSG1,errorMSG2,errorSecondTest);
}



//======================================================================================
//Charge les options de recherche avancee
//Add le 16/03/2007 par D.Guillard
function loadOptAdvancedSearch()
{
		var MyXhr = new XHR();
		var URIpath = docRoot + "/ajax/LoadOpt_RechercheAvancee.aspx";
		LoadContent(URIpath,"SpanOptAdvancedSearch","");

}

//======================================================================================
//Charge le formulaire de gestion de la Newsletter
//Add le 14/02/2007 par D.Guillard
function loadNewsFormNewsletter(isNoChecked)
{
		var MyXhr = new XHR();
		
		if (isNoChecked)
			{var URIpath = docRoot + "/ajax/LoadGestionNewsletter.aspx?AddCloseButton=1&disabled=false";}
		else
			{var URIpath = docRoot + "/ajax/LoadGestionNewsletter.aspx?AddCloseButton=1&disabled=true";}
		LoadContent(URIpath,"SpanGestionNewsletter","");

}
//======================================================================================
//======================================================================================
//Ecris un lien qui nous permet d'acceder aux options de Newsletter
//Add le 01/03/2007 par D.Guillard
function loadOptNewsletterLink(isChecked)
{
	if (! isYes)
	{
		isYes = true;
		document.getElementById('SpanGestionNewsletter').innerHTML='<a href="#" onclick="loadNewsFormNewsletter()" style="color: #6b442e"><i>Cliquez ici pour affiner vos crit\350res et recevoir des informations compl\350mentaires plus cibl\351es</i></a>'
	}

	if (isChecked)
	
	{
	var MyXhr = new XHR();
		var URIpath = docRoot + "/ajax/LoadGestionNewsletter.aspx?AddCloseButton=1&disabled=true";
		LoadContent(URIpath,"SpanGestionNewsletter","");
	}
	
}
//======================================================================================
//======================================================================================
//Affiche un message de confirmation au désabonnement
//Add le 15/02/2007 par D.Guillard
function Confirm_DesabonnementNewsletter()
{
	if (isYes)
	{
		/*if ( confirm("Voulez-vous vraiment vous d\351sinscrire de la lettre La Procure ? \n Attention : Toutes vos pr\351f\351rences seront \351galement supprim\351s !")) 
		{*/
			// si oui, on efface le formulaire des options newsletter
			DeleteFormNewsletter()
			isYes = false;
		/*} else {
			// sinon, on réinitialise le checBox inscrit a true
			document.getElementById('u_is_abonne_1').checked = true
		}*/
	}
}
//======================================================================================

//======================================================================================
//Charge le formulaire de gestion de la Newsletter
//Add le 15/02/2007 par D.Guillard
function DeleteFormNewsletter()
{
	// 1) On supprime le formulaire de la page
	//document.getElementById('SpanGestionNewsletter').innerHTML=''
	
	// 2) On effectuer le traitement du désabonnement à la newsletter
	var MyXhr = new XHR();
	var URIpath = docRoot + "/ajax/LoadGestionNewsletter.aspx?action=delete&u_is_abonne=0";
	LoadContent(URIpath,"NoDiv","");
	
	//document.location.reload();

}
//======================================================================================


//======================================================================================
//Remplace l'accroche de la newsletter par son formulaire d'inscription
//ou de livraison (typeAdr)
function loadNewsForm()
{
		var MyXhr = new XHR();
		var URIpath = docRoot + "/_application/_functions/loadNewsForm.aspx";
		LoadContent(URIpath,"NewsSpanAccroche","");

}
//======================================================================================

//======================================================================================
//Remplace le formulaire d'inscription par le message d'erreur ou de confirmation
// Add by D.Guillard le 22/11/2006
function loadNewsFormInscrit(Email)
{
		var MyXhr = new XHR();
		var URIpath = docRoot + "/_application/_functions/loadNewsFormInscrit.aspx?txt_email=" + Email;
		LoadContent(URIpath,"NewsSpanAccroche","");

}
//======================================================================================

//======================================================================================
//Charge le filtre des familles pour le formulaire de recherche avancee
function loadFiltre_RechercheAvancee(Genre,Famille,SousFamille,SousSousFamille)
{
		var MyXhr = new XHR();
		var URIpath = docRoot + "/ajax/loadFiltre_RechercheAvancee.aspx?idTypeGenre=" + Genre + "&idFam=" + Famille + "&idSousFam=" + SousFamille + "&idSousSousFam=" + SousSousFamille;
		LoadContent(URIpath,"Filtre_RechercheAvancee","");

}
//======================================================================================

//======================================================================================
//Affiche les formulaires ,necessaire a l'affichage du bloc "mot de passe oublié"
// Add by D.Guillard le 02/01/2007
function loadFormLostPassword(page, Email)
{
	var MyXhr = new XHR();
	var URIpath;
	
	if (page=='checkemail')
	{
		URIpath = docRoot + "/_application/_functions/CheckEmail_LostPassword.aspx";
		LoadContent(URIpath,"NewsSpanAccroche","");
	}
	else if (page=='confirm')
	{
		document.getElementById('NewsSpanAccroche').innerHTML = 'Traitement en cours...';
		URIpath = docRoot + "/_application/_functions/Confirm_LostPassword.aspx?txt_email=" + Email;
		LoadContent(URIpath,"NewsSpanAccroche","","var valid2 = new Validation('LostPasswordForm', {immediate : true, onFormValidate : formCallback});");
	}
	else if (page=='extranet')
	{
		document.getElementById('NewsSpanAccroche').innerHTML = 'Traitement en cours...';
		URIpath = docRoot + "/_application/_functions/Confirm_LostPassword_extranet.aspx?txt_email=" + Email;
		LoadContent(URIpath,"NewsSpanAccroche","","var valid2 = new Validation('LostPasswordForm', {immediate : true, onFormValidate : formCallback});");	
	}
}

//======================================================================================
//======================================================================================
//======================================================================================
//Charge un menu déroulant des super famillen, familles et sous famille
function loadRayonCombo(path,idSupFam,idFam,idSsFam,idSsSsFam)
{
	
		var URIpath = path; 
		var spanID;
		if (idSupFam!='') 
		{
			URIpath += "&SupfamID=" + idSupFam;
			spanID = "ComboFam";	
			
			if (document.getElementById('ComboFam'))
			{
				document.getElementById('ComboFam').innerHTML = "";
			}
			
			if (document.getElementById('CombossFam'))
			{
				document.getElementById('CombossFam').innerHTML = "";
			}
			
			if (document.getElementById('ComboSssousFam'))
			{
				document.getElementById('ComboSssousFam').innerHTML = "";
			}
			
		}			
		if (idFam!='') 
		{
			URIpath += "&famID=" + idFam;
			spanID = "CombossFam";
				
			if (document.getElementById('CombossFam'))
			{
				document.getElementById('CombossFam').innerHTML = "";
			}
			
			if (document.getElementById('ComboSssousFam'))
			{
				document.getElementById('ComboSssousFam').innerHTML = "";
			}						
		}
		if (idSsFam!='') 
		{ 
			spanID = "ComboSssousFam";
			URIpath += "&SousFamID=" + idSsFam;
			
			if (document.getElementById('ComboSssousFam'))
			{
				document.getElementById('ComboSssousFam').innerHTML = "";
			}			
		}
		
		//Add le 13/03/2007 par D.Guillard
		// Gestion de la sous sous famille
		//if (idSsSsFam!='') 
		//{ 
		//	spanID = "ComboSssousFam";
		//	URIpath += "&SousSousFamID=" + idSsSsFam;
			
		//	if (document.getElementById('ComboSssousFam'))
		//	{
		//		document.getElementById('ComboSssousFam').innerHTML = "";
		//	}			
		//}		
		

	if (document.getElementById)
	{
		SpanCartObj = document.getElementById(spanID);
		SpanCartObj.innerHTML="loading ..."	
		LoadContent(URIpath,spanID,"Chargement des rayons...");	
		
	}		
}






//======================================================================================
//Charge l'historique des objets consultés dans le div "history"
function loadHistory(page)
{
	
		var MyXhr = new XHR();
		var URIpath = docRoot + "/_application/_functions/_ajax/loadHistory.aspx?Histpage=" + page;
		
		LoadContent(URIpath,"history","");
		
}

//======================================================================================
//Charge l'historique des objets consultés dans le table "colDroiteHistory" de la colonne de droite
function loadHistoryColDroite(page)
{

		var MyXhr = new XHR();
		var URIpath = docRoot + "/_application/_functions/_ajax/loadHistory.aspx?viewMode=2&Histpage=" + page + "&ajax=1";
		
		LoadContent(URIpath, "colDroite_historique", "");
}



//======================================================================================
//Recharge les objets dans le table "colDroitePanier" ou "colDroiteSelection" de la colonne de droite
function delArt(idLigne, type, idTable)
{
		var MyXhr = new XHR();
		var URIpath = docRoot + "/_application/_functions/_ajax/loadCartColonneDroite.aspx?type=" + type + "&action=delArt&idLigne=" + idLigne + "&ajax=1";
		
		LoadContent(URIpath, idTable, "");
}


//======================================================================================




function fadeIn(objId,opacity) {
	if (document.getElementById && canFadeIn) {
		obj = document.getElementById(objId);
		obj.style.visibility='visible';
		if (opacity <= 100) {
			setOpacity(obj, opacity);
			opacity += 10;
			window.setTimeout("fadeIn('"+ objId +"',"+opacity+")", 100);
		}
	}
}

function fadeOut(objId,opacity) {
	if (document.getElementById) {
		obj = document.getElementById(objId);
		if (opacity > 0) {
			setOpacity(obj, opacity);
			opacity -= 10;
			timerFader = window.setTimeout("fadeOut('"+ objId +"',"+opacity+")", 100);
		}
	}
}

function fadeOutThis(obj, opacity)
{
	if (opacity > 0) {
		setOpacity(obj, opacity);
		opacity -= 10;
		timerFader = window.setTimeout("fadeOutThis('"+ obj +"',"+opacity+")", 100);
	}
}

function fadeInTop(objId,opacity) {

	if (document.getElementById) {
		obj = parent.document.getElementById(objId);
		obj.style.visibility='visible';
		if (opacity <= 100) {
			setOpacity(obj, opacity);
			opacity += 10;
			window.setTimeout("fadeInTop('"+ objId +"',"+opacity+")", 100);
		}
	}
}

function fadeOutTop(objId,opacity) {
	if (document.getElementById) {
		obj = parent.document.document.getElementById(objId);
		if (opacity > 0) {
			setOpacity(obj, opacity);
			opacity -= 10;
			timerFader = window.setTimeout("fadeOutTop('"+ objId +"',"+opacity+")", 100);
		}
	}
}

function setOpacity(obj, opacity) {

	opacity = (opacity == 100)?99.999:opacity;
	// IE/Win
	obj.style.filter = "alpha(opacity:"+opacity+")";
	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = opacity/100;
	// Older Mozilla and Firefox
	obj.style.MozOpacity = opacity/100;
	// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity = opacity/100;
	


}

	/***********************************************************************************************************
	 * Fonction appelée au chargement de la page 
	 * permettant de conserver les champs déjà saisis en cas de rechargement de page, 
	 * et d'afficher ou masquer le bouton submit pour la recherche étendue. 
	 */
	function checkFields()
	{
		var tab = new Array();
		tab = getParams(); // paramètres de l'url 
		alert('checkFields...');
		if (tab != null) 
		{
			for (i=0; i < tab.length; i++) 
			{
				if ( tab[i][0].indexOf("titre") != -1 ) 
				{
					if ( tab[i][1] != '' ) {
						document.getElementById("titre").value = tab[i][1];
					}
				}
				else if ( tab[i][0].indexOf("auteur") != -1 ) 
				{
					if ( tab[i][1] != '' ) {
						document.getElementById("auteur").value = tab[i][1];
					}
				}
				else if ( tab[i][0].indexOf("editeur") != -1 ) 
				{
					if ( tab[i][1] != '' ) {
						document.getElementById("editeur").value = tab[i][1];
					}
				}
				else if ( tab[i][0].indexOf("collection") != -1 ) 
				{
					if ( tab[i][1] != '' ) {
						document.getElementById("collection").value = tab[i][1];
					}
				}
				else if ( tab[i][0].indexOf("isbn") != -1 ) 
				{
					if ( tab[i][1] != '' ) {
						document.getElementById("isbn").value = tab[i][1];
					}
				}
				else if ( tab[i][0].indexOf("inflechi") != -1 ) 
				{
					if ( tab[i][1] == "true" ) {
						document.getElementById("inflechi").checked = true;
					}
					else {
						document.getElementById("inflechi").checked = false;
					}
				}
				else if ( tab[i][0].indexOf("phonetique") != -1 ) 
				{
					if ( tab[i][1] == "true" ) {
						document.getElementById("phonetique").checked = true;
					}
					else {
						document.getElementById("phonetique").checked = false;
					}
				}
				
			} // End for (i=0; i < tab.length; i++) 
			
			//document.getElementById("chercher2").style.visibility = "visible";
			
		} // End if (tab != null) 
		else 
		{
			document.getElementById("inflechi").checked = true;
			//document.getElementById("chercher2").style.visibility = "hidden";
		}
	}
		

	
	
	/***********************************************************************************************************
	 * Fonction de vérification des champs du formulaire Form_adv_search 
	 */
	function validForm_adv_search() 
	{
		var titre = document.getElementById("titre");
		var auteur = document.getElementById("auteur");
		var editeur = document.getElementById("editeur");
		var collection = document.getElementById("collection");
		var isbn = document.getElementById("isbn");
		var SousSousFam = document.getElementById("SousSousFamID");
		
		//Add le 08/02/2007 par D.Guillard	
		// On test la validité du select SousSousFamille				
		if ( SousSousFam != null )
		{
			if ( SousSousFam.value == 0 )
			{
				var bool_SousSousFam = false;
			} else {
				var bool_SousSousFam = true;
			}
		} else {
			var bool_SousSousFam = false;
		}
		// Fin du test sur SousSousFamille
		
		var bool_titre = ( titre.value != "" );
		var bool_auteur = ( auteur.value != "" );
		var bool_editeur = ( editeur.value != "" );
		var bool_collection = ( collection.value != "" );
		var bool_isbn = ( isbn.value != "" );
		
		if ( !bool_titre && !bool_auteur && !bool_editeur && !bool_collection && !bool_isbn && !bool_SousSousFam) 
		{
			var form_empty = "Vous devez saisir au moins un champ parmi :\n\n";
			form_empty += " - Mot(s) du titre,\n";
			form_empty += " - Auteur,\n";
			form_empty += " - Editeur,\n";
			form_empty += " - Collection,\n";
			form_empty += " - ISBN / EAN,\n";
			form_empty += " - ou une Sous-sous Famille.\n";
			alert(form_empty);
			return false;
		}
		else 
		{
		//alert(bool_isbn);
			if ( bool_isbn ) 
			{
				isbn.value = trim(isbn.value); // function trim(s) : /j/nv/panier.js 
			
				var info_ean = "Un EAN doit \352tre compos\351 de 13 chiffres exactement.";
				
			var info_isbn = "Un ISBN doit \352tre compos\351 de 10 ou 13 chiffres, ";
			info_isbn += "soit r\351partis sur 4 ou 5 segments s\351par\351s par un tiret ' - ' .\n";
			info_isbn += "soit sans s\351paration. \n"
			info_isbn += "ex : 978-0-1234-5678-9, 0-1234-5678-9 \n";
			info_isbn += "ex : 9780123456789, 0123456789 \n";
				
				if ( check_isbn_ean(isbn.value) == 1 ) {
					// EAN correct 
					return true;
				}
				else if ( check_isbn_ean(isbn.value) == -1 ) {
					// EAN incorrect 
					var msg = "Votre EAN est incorrect !\n\n" + info_ean;
					alert(msg);
					isbn.select();
					isbn.focus();
					return false;
				}
				else if ( check_isbn_ean(isbn.value) == 2 ) {
					// ISBN correct 
					return true;
				}
				else if ( check_isbn_ean(isbn.value) == -2 ) {
					// ISBN incorrect 
					var msg = "Votre ISBN est incorrect !\n\n" + info_isbn;
					alert(msg);
					isbn.select();
					isbn.focus();
					return false;
				}
				else if ( check_isbn_ean(isbn.value) == 0 ) {
					var msg = "Vous devez taper un ISBN ou un EAN valide !\n\n" + info_ean + "\n\n" + info_isbn;
					alert(msg);
					isbn.select();
					isbn.focus();
					return false;
				}
				
			} 
		}
		
	} 
	
	//¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
	//Add le 19/04/2007 par D.Guillard
	// test pour l'instant
	function GotoCBmod()
	{
		if (opener != null)
		{
			//opener.document.getElementById('recapForm').submit();
			self.close();
		} else {
			alert("Pour effectuer cette action, votre fenetre principale dois encore etre active !");
		}
	}
	
	//¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
	//Add le 03/05/2007 par D.Guillard
	//Switch l'affichage masquage d'un div html
	// thisId = id de l'element a masquer/afficher
	
	function visible(thisId)
	{
	var targetElement;
	targetElement = document.getElementById(thisId);
	if (targetElement.style.display == "none")
		{
		targetElement.style.display = "";
			} else {
		targetElement.style.display = "none";
		}
	}
	
	//¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
	//Add le 09/05/2007 par D.Guillard
	//Fonction utilisé dans la page des dossiers,
	//masque/affiche un element et agit sur la barre d'action permettant cette action
	function SwitchBAr(ElementToSwitch,Provenance,Position)
	{
		//Traitement de la barre d'action afficher/masquer
		if (Provenance == "before")
		{
			if (document.getElementById("after_" + Position)) {document.getElementById("after_" + Position).style.display = "";}
			if (document.getElementById("before_" + Position)) {document.getElementById("before_" + Position).style.display = "none";}

		} else {
			document.getElementById("after_" + Position).style.display = "none";
			document.getElementById("before_" + Position).style.display = "";
		}
		//Switch de l'element
		visible(ElementToSwitch);
	}
	
	//¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
	// Définie la zone à imprimer
	function imprime_zone(titre, obj)
	{
	//var zi = document.getElementById(obj).innerHTML;

	// Ouvre une nouvelle fenetre
	//var f = window.open("", "ZoneImpr", "height=500, width=600,toolbar=0, menubar=0, scrollbars=1, resizable=1,status=0, location=0, left=10, top=10");

	// Définit le Style de la page
	//f.document.body.style.color = '#000000';
	//f.document.body.style.backgroundColor = '#FFFFFF';
	//f.document.body.style.padding = "10px";

	// Ajoute les Données
	//f.document.title = titre;
	//f.document.body.innerHTML += " " + zi + " ";

	// On retire le bouton d'impression
	//f.document.getElementById('Imprimer').style.display="none";

	// Imprime et ferme la fenetre
	//f.window.print();
	//f.window.close();

	window.document.getElementById('Imprimer').style.display="none";
	window.print();
	window.document.getElementById('Imprimer').style.display="";
	return true;
	}	

	//¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
	//¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
	// Fonction qui ajoute un champ hidden en javascript avant soumission du formulaire
	//on vérifie d'abord que le champ n'existe pas déjà
	function withJavascript(curForm)
	{
		
		if (!document.getElementById('isWrite'))
		{
			var newElement = document.createElement('input');
			newElement.setAttribute('type','hidden');
			newElement.setAttribute('name','isWrite');
			newElement.setAttribute('id','isWrite');
			newElement.value = '1';
					
			curForm.appendChild(newElement);
		}

		return true;
	}
	
	
	//¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
	//¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
	// Fonction qui affiche le layer des agregateur rss pour un flux (d.guillard, le 17/09/2008)
	function selectFlux(url)
	{
		var pathToSelect;
		var timeClose = 0;
		pathToSelect = url;
		if (document.getElementById)
		{
			showRssAgregators(); // Création du div contenant
			SpanLayerFluxObj = document.getElementById("layerRss");
			//Si on séléctionne un article pour le panier "principal", on update le nombre d'articles au panier.	

			//Sinon, on fait la meme action, mais sans mettre à jour le nombre d'articles au panier principal
			LoadContent(pathToSelect,"layerRss","Recherche du flux...","setCloseFunction_toBody();");
					
			//SpanLayerFluxObj.style.top = yMousePos + "px";
			//SpanLayerFluxObj.style.left = ((xMousePos - (100 / 2)) + 50) + "px";
		}
	}
	
	/* Construit le div contenant les agregateurs */
	function showRssAgregators()
	{
			var newElement = document.createElement('div');
			newElement.setAttribute('name', 'layerRss');
			newElement.setAttribute('id', 'layerRss');
			newElement.setAttribute('align', 'center');
	//		var varStyle = ';Z-INDEX:1;;;FONT-FAMILY:Arial;OVERFLOW:visible;';
	//		newElement.setAttribute('style',varStyle);

			newElement.style.position = "absolute";
			newElement.style.left = ((xMousePos - (100 / 2)) + 50) + "px";
			newElement.style.top = yMousePos + "px";
			
			document.body.appendChild(newElement);
	}
	
	/* Ajoute au body l'evenement de cloture du div */
	function setCloseFunction_toBody()
	{
		if (document.body.addEventListener)
		{
			document.body.addEventListener("click", CloseAgregators, false);
		} 
		else if (document.body.attachEvent)
		{
			document.body.attachEvent("onclick", CloseAgregators, false);
		}
	}
	
	/* Supprime le div des agregateurs, et retire l'evenement lié dans le body */
	function CloseAgregators()
	{
		if (document.getElementById('layerRss'))
		{
			/* On retire le div*/
			document.body.removeChild(document.getElementById('layerRss'));
			/* On retire l'evenement du body devenu obsolete */
			if (document.body.removeEventListener)
			{
				document.body.removeEventListener("click", CloseAgregators, false);
			} 
			else if (document.body.detachEvent)
			{
				document.body.detachEvent("onclick", CloseAgregators, false);
			}
		}	
	}
	
	
	
	//#################################################################################################################
	// Afficher les sous-sous-familles d'une sous-famille (/nous/planRayons.aspx) 
	//#################################################################################################################
	function show_sousoufam(param_sfamId)
	{
		var tabElt = getElementsByName_forIE("div", "list_sousoufam"); //document.getElementsByName("list_sousoufam");
		if (tabElt) 
		{
			//alert("tabElt.length = " + tabElt.length);
			for (i=0; i < tabElt.length; i++)
			{
				//if (tabElt.item(i).style.visibility == "visible") 
				if (tabElt[i].style.visibility == "visible") 
				{
					//hide_sousoufam(tabElt.item(i).id);
					hide_sousoufam(tabElt[i].id);
				}
			}
		}
		
		
		var divID = param_sfamId + "_sousoufam";
		var divSSfam = document.getElementById(divID);
		
		if (divSSfam != null)
		{
			divSSfam.style.display = "block";
			divSSfam.style.visibility = "visible";
			/*
			divSSfam.style.left = ((xMousePos - (100 / 2)) + 50) + "px";
			divSSfam.style.top = yMousePos + "px";
			*/
			divSSfam.onclick = function(){hide_sousoufam(divID)};
			
			/* 
			
			divSSfam.style.position = "absolute";
			divSSfam.style.width = "400px";
			
			*/
		}
	}
	
	
	//#################################################################################################################
	// Masquer les sous-sous-familles d'une sous-famille (/nous/planRayons.aspx) 
	//#################################################################################################################
	function hide_sousoufam(param_divId)
	{
		var divSSfam = document.getElementById(param_divId);
		
		if (divSSfam)
		{
			divSSfam.style.display = "none";
			divSSfam.style.visibility = "hidden";
		}
	}
	
	
	//#################################################################################################################
	// Ajoute le lien feuilleter le livre au googlebooks
	//#################################################################################################################
	function add_feuilletageLink(booksInfo)
	{
		
		for (i in booksInfo)
		{ 
			var book = booksInfo[i];
			if (book['embeddable'])
			{
				var id_feuilletage = "feuilletageLink-" + book.bib_key;
				var obj_dd_temp = document.createElement("dd");
				obj_dd_temp.setAttribute("style", "margin-bottom:5px;")
				obj_dd_temp.innerHTML = '<a href="' + document.getElementById('url-' + book.bib_key).value + '"><img style="background:none;border:none;" src="/i/Feuilleter_widget.png"/></a>';
				
				document.getElementById(id_feuilletage).innerHTML = "";
				document.getElementById(id_feuilletage).appendChild(obj_dd_temp);
	  
			}
		}
	}
	
	//#################################################################################################################
	// Ajoute le lien pop up Viewer
	//#################################################################################################################
	function add_viewerLink(booksInfo)
	{
		for (i in booksInfo)
		{ 
			var book = booksInfo[i];
			if (book['embeddable'])
			{
				document.getElementById('viewerLink-' + book.bib_key).innerHTML = '<a type="XHRPopUp-Widget" class="viewer-link" style="border:none;" href="' + document.getElementById('url-' + book.bib_key).value + '" onclick="xt_med(\'F\',\'15\',\'google::' + book.bib_key.substr(5,13) + '\');"><img style="background:none;" src="/i/google_preview_button.gif"/></a>';
			}
		}
	}





//#######################################################################################################
// Tristan - 19/01/2010 
// /comptes/Abo_Newsletter.aspx?mod=edit&email=tbatzli@nouvellevague.fr
// gestion du click sur la case "Je m'abonne à la Lettre Procure" 
//#######################################################################################################
function check_abo_NLprocure(cbox, div_id) 
{
	var toDisabled = false;
    if (cbox.checked) 
    {
        //alert('checked');
        //document.getElementById(div_id).style.visibility = "visible";
    }
    else 
    {
        //alert('UNchecked');
        // document.getElementById(div_id).style.visibility = "hidden";
        toDisabled = true;
    }
    
    var i = 0;
    var j= 1;
    var myCheckBox = document.getElementById("Box_" + i + "_" + j);
    var continu = true;
    
    do{
		
		if (toDisabled){
			myCheckBox.setAttribute("disabled", "disabled");
		}else{
			myCheckBox.removeAttribute("disabled");
		}
		
		i ++;
		
		myCheckBox = document.getElementById("Box_" + i + "_" + j);
		if (!myCheckBox){
			i = 0
			j ++;
			
			myCheckBox = document.getElementById("Box_" + i + "_" + j);
			
			if (!myCheckBox){
				continu= false;
			}			
		}
		
    }while (continu)
    if (toDisabled){
			document.getElementById("evt").setAttribute("disabled", "disabled");
		}else{
			document.getElementById("evt").removeAttribute("disabled");
		}  
}

//#######################################################################################################
// Damien - 02/08/2010 
// Vérification du formulaire de contact
//#######################################################################################################
function verif_contact_formulaire()
{
	var form_is_ok = true;
	var msg_error = 'Impossible de valider le formulaire : ';
	var radio_choix_is_ok = false;
	var radio_choix = document.getElementsByName('contact_choix');
	
	//on boucle sur les radio pour voir si il y en a au moins un de séléctionné
	for(var i=0;i<radio_choix.length;i++)
	{
		if(radio_choix[i].checked == true)
		{
			radio_choix_is_ok = true;
			
			//certain boutons radios nécessite qu'un champ particulier soit renseigné
			// - radio commande = champ numero commande renseigné et email enregistré en base
			if(radio_choix[i].id == '1')
			{
				if(document.getElementById('contact_cmd').value == '')
				{
					form_is_ok = false;
					msg_error += '\n - Veuillez saisir un num\351ro de commande.';
				}
				
				/*if(document.getElementById('email_compte_hidden').value == 'False')
				{
					form_is_ok = false;
					msg_error += '\n - Cet email ne correspond \340 aucun compte.';
				}*/
	
				// - check de la liaison entre le numero de commande et l'email
				if(document.getElementById('check_email_cmd_hidden').value == 'False')
				{
					form_is_ok = false;
					msg_error += '\n - L\'email ne correspond pas au num\351ro de commande saisi.';
				}
			}
			// - radio CV = input file CV
			if(radio_choix[i].id == '4')
			{
				if(document.getElementById('contactez_nous1_contact_cv').value == '')
				{
					form_is_ok = false;
					msg_error += '\n - Veuillez nous fournir votre CV.';
				}			
			}
		}

	}
		
	if(radio_choix_is_ok == false)
	{
		msg_error += '\n - Veuillez s\351lectionner un type de demande.';
		form_is_ok = false;
	}
	
	if(form_is_ok == false)
	{
		alert(msg_error);
	}
		
	return form_is_ok;
}

//#######################################################################################################
// Damien - 02/08/2010 
// Vérification de la liaison entre le numero de commande et l'email
//#######################################################################################################
function check_email_cmd_form_contact()
{
	var myXHR = new last_httpRequest("/ajax/ajax_request.aspx", "idControl=12&num_cmd_to_check=" + document.getElementById('contact_cmd').value + "&email_to_check=" + document.getElementById('u_email').value, "get");
	
	myXHR.createRequestObject();
	myXHR.sendGetReq();

	myXHR.xmlHttp.onreadystatechange = function()
	{
		if (myXHR.xmlHttp.readyState == 4) /* 4 : état "complete" */
		{
			document.getElementById('check_email_cmd_hidden').value = myXHR.xmlHttp.responseText;
		}
	}
}

//#######################################################################################################
// Damien - 02/08/2010 
// Vérification si l'email correspond à un compte client
//#######################################################################################################
function check_email_compte_contact()
{
	var myXHR = new last_httpRequest("/ajax/ajax_request.aspx", "idControl=13&email_to_check=" + document.getElementById('u_email').value, "get");
	
	myXHR.createRequestObject();
	myXHR.sendGetReq();

	myXHR.xmlHttp.onreadystatechange = function()
	{
		if (myXHR.xmlHttp.readyState == 4) /* 4 : état "complete" */
		{
			document.getElementById('email_compte_hidden').value = myXHR.xmlHttp.responseText;
		}
	}
}



//#################################################################################################
// Vérification du choix de la civilité dans le formulaire de création de compte
//#################################################################################################
function check_civilite() 
{
	
	var civ2 = document.getElementById('u_civ_1');
	var civ1 = document.getElementById('u_civ_2');
	var civ3 = document.getElementById('u_civ_3');
	
	var civ1_ok = (civ1.checked != '');
	var civ2_ok = (civ2.checked != '');
	var civ3_ok = (civ3.checked != '');
	
	if (!civ1_ok && !civ2_ok && !civ3_ok) {
		var msg_error = 'Veuillez s\351lectionner une civilit\351';
		//document.getElementById('validate_u_civ').innerHTML = msg_error;
		//alert(msg_error);
	}	
	
}
