function menuClick (menu) {
	switch (menu) {
		case 1: //Livres
			window.location=("/affichage/rubriques.jsp?noCentre=1");
			break;
		case 2: //Musique
			window.location=("/affichage/sousrubriques.jsp?noCentre=2&noRubriquePrincCourant=5109");
			break;
		case 3: //DVD
			window.location=("/affichage/sousrubriques.jsp?noCentre=2&noRubriquePrincCourant=6010");
			break;
		case 4: //Multimedia
			window.location=("/affichage/sousrubriques.jsp?noCentre=3&noRubriquePrincCourant=5611");
			break;
		case 5: //Photo
			window.location=("/photo/photonumerique.jsp?listeProduitsPageBis=500&noPage=1&noCentre=5");
			break;
		case 6: //Jeunesse
			window.location=("/affichage/rubriques.jsp?noCentre=4");
			break;
		case 7: //Club Extra
			window.location=("/leclubextra/index.jsp?noCentre=6");
			break;
		default: //Accueil par defaut
			window.location=("/index.jsp?noCentre=0");
			break;
	}
}

function produitBoxSwitch (sel) {
	var Selection = document.getElementById (sel);
	var SelectionTab = document.getElementById (sel+"Tab");

	if (!Selection) {
		return;
	}

	if (document.getElementById ("sommaire") != null) {
		document.getElementById ("sommaire").style.display = "none";
		document.getElementById ("sommaireTab").className = "produitmenu";
	}
	if (document.getElementById ("auteur") != null) {
		document.getElementById ("auteur").style.display = "none";
		document.getElementById ("auteurTab").className = "produitmenu";
	}
	if (document.getElementById ("commentaires") != null) {
		document.getElementById ("commentaires").style.display = "none";
		document.getElementById ("commentairesTab").className = "produitmenu";
	}
	if (document.getElementById ("extraits") != null) {
		document.getElementById ("extraits").style.display = "none";
		document.getElementById ("extraitsTab").className = "produitmenu";
	}
	if (document.getElementById ("coupdecoeur") != null) {
		document.getElementById ("coupdecoeur").style.display = "none";
		document.getElementById ("coupdecoeurTab").className = "produitmenu";
	}
	if (document.getElementById ("extraitmusicaux") != null) {
		document.getElementById ("extraitmusicaux").style.display = "none";
		document.getElementById ("extraitmusicauxTab").className = "produitmenu";
	}
	if (document.getElementById ("entrevue") != null) {
		document.getElementById ("entrevue").style.display = "none";
		document.getElementById ("entrevueTab").className = "produitmenu";
	}
	if (document.getElementById ("presse") != null) {
		document.getElementById ("presse").style.display = "none";
		document.getElementById ("presseTab").className = "produitmenu";
	}
	if (document.getElementById ("avis") != null) {
		document.getElementById ("avis").style.display = "none";
		document.getElementById ("avisTab").className = "produitmenu";
	}

	if (sel == "sommaire") {
		document.getElementById ("leftTab").style.height = "25px";
	} else {
		document.getElementById ("leftTab").style.height = "24px";
	}
	Selection.style.display = "block";
	SelectionTab.className = "produitmenusel";
}

function osBoxSwitch (sel) {
	var Selection = document.getElementById (sel);
	var SelectionTab = document.getElementById (sel+"Tab");

	if (!Selection) {
		return;
	}

    document.getElementById ("roman").style.display = "none";
	document.getElementById ("romanTab").className = "produitmenu";
	document.getElementById ("ouverture").style.display = "none";
	document.getElementById ("ouvertureTab").className = "produitmenu";
	document.getElementById ("suspense").style.display = "none";
	document.getElementById ("suspenseTab").className = "produitmenu";
	document.getElementById ("jeunesse").style.display = "none";
	document.getElementById ("jeunesseTab").className = "produitmenu";
	document.getElementById ("viepratique").style.display = "none";
	document.getElementById ("viepratiqueTab").className = "produitmenu";

	if (sel == "roman") {
		document.getElementById ("leftTab").style.height = "25px";
	} else {
		document.getElementById ("leftTab").style.height = "24px";
	}
	Selection.style.display = "block";
	SelectionTab.className = "produitmenusel";
}

function loginCheck (type, e) {
	if (type == 0) { //Size check pour numero
		if (document.parMotPasse.client.value.length >= 8) {
			document.parMotPasse.motDePasseClient.focus();
		}
	} else if (type == 1) { //Enter check
		var keynum

		if (window.event) //IE
		{
			keynum = e.keyCode
		}
		else if (e.which) //Others
		{
			keynum = e.which
		}

		if (keynum == 13) {
			document.getElementById ("parMotPasse").submit();
			return false;
		}
	}
}

function runSubmitLogin() {
	if(document.parMotPasse.motDePasseClient.value == "") {
		document.parMotPasse.motDePasseClient.focus();
		alert("Veuillez svp entrer votre mot de passe.");
		return
  	}
  	if(document.parMotPasse.client.value == "") {
		document.parMotPasse.client.focus();
		alert("Veuillez svp entrer votre numero de membre.");
		return
 	}
	document.parMotPasse.submit();
}

function GetXmlHttpObject()
{
	var xmlHttp=null;

	try { // Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e) {// Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
    }

	return xmlHttp;
}

function listeProduitStateChanged () {
	switch (xmlHttp.readyState) {
		case 4:
			document.getElementById ("ListeProduits").innerHTML=xmlHttp.responseText;
			break;
		case 1:
			document.getElementById ("ListeProduits").innerHTML="Demande en cours...";
			break;
		default:
			break;
	}
}

function listeProduitStateChangedParrainage () {
	switch (xmlHttp.readyState) {
		case 4:
			document.getElementById ("ListeProduitsParrainage").innerHTML=xmlHttp.responseText;
			break;
		case 1:
			document.getElementById ("ListeProduitsParrainage").innerHTML="Demande en cours...";
			break;
		default:
			break;
	}
}

function showPages (page, maxpages, typeAffichage,passoverurl) {
	var content;
	content = "<b>Pages :</b> ";

	for (i=0;i<maxpages;i++) {
		if (page-1 == i) {
			content += "<b>"+(i+1)+"</b> ";
		} else {
			content += "<a href=\"javascript:void(0)\" onclick=\"javascript:getListeProduits("+(i+1)+", "+maxpages+", "+typeAffichage+", '"+ passoverurl +"')\">"+(i+1)+"</a> ";
		}
	}
	document.getElementById("pageCountUp").innerHTML = content;
	document.getElementById("pageCountDown").innerHTML = content;
}


function showPagesParrainage (page, maxpages, typeAffichage) {
	var content;
	content = "<b>Pages :</b> ";

	for (i=0;i<maxpages;i++) {
		if (page-1 == i) {
			content += "<b>"+(i+1)+"</b> ";
		} else {
			content += "<a href=\"javascript:void(0)\" onclick=\"javascript:getListeProduitsParrainage("+(i+1)+", "+maxpages+", "+typeAffichage+")\">"+(i+1)+"</a> ";
		}
	}
	document.getElementById("pageCountUp").innerHTML = content;
	document.getElementById("pageCountDown").innerHTML = content;
}

function showPagesAdisq (page, maxpages, typeAffichage, passoverurl) {
	var content;
	content = "<b>Pages :</b> ";

	for (i=0;i<maxpages;i++) {
		if (page-1 == i) {
			content += "<b>"+(i+1)+"</b> ";
		} else {
			content += "<a href=\"javascript:void(0)\" onclick=\"javascript:getListeProduitsAdisq("+(i+1)+", "+maxpages+", "+typeAffichage+", '"+ passoverurl +"')\">"+(i+1)+"</a> ";
		}
	}
	document.getElementById("pageCountUp").innerHTML = content;
	document.getElementById("pageCountDown").innerHTML = content;
}

function getListeProduitsAdisq (page, maxpages, typeAffichage, passoverurl) {
	showPagesAdisq (page, maxpages, typeAffichage,passoverurl);

	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
		alert ("Your browser does not support AJAX!");
		return;
	}

	var url="/affichage/ajaxGetListeProduitAdisq.jsp";
	url=url+"?noPage="+page;
	url=url+"&"+passoverurl;
	url=url+"&sid="+Math.random();
	url=url+"&typeAffichage="+typeAffichage;
	xmlHttp.onreadystatechange=listeProduitStateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function getListeProduits (page, maxpages, typeAffichage, passoverurl) {
	showPages (page, maxpages, typeAffichage,passoverurl);

	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
		alert ("Your browser does not support AJAX!");
		return;
	}

	var url="/affichage/ajaxGetListeProduit.jsp";
	url=url+"?noPage="+page;
	url=url+"&"+passoverurl;
	url=url+"&sid="+Math.random();
	url=url+"&typeAffichage="+typeAffichage;
	xmlHttp.onreadystatechange=listeProduitStateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function getListeProduits2 (page, maxpages, typeAffichage, passoverurl,fichier) {
	showPages (page, maxpages, typeAffichage,passoverurl);

	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
		alert ("Your browser does not support AJAX!");
		return;
	}

	var url="/affichage/ajaxGetListeProduit.jsp";
	url=url+"?noPage="+page;
	url=url+"&"+passoverurl;
	url=url+"&sid="+Math.random();
	url=url+"&typeAffichage="+typeAffichage;
	url=url+"&nomFichierAffichage="+fichier;
	xmlHttp.onreadystatechange=listeProduitStateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}


function getListeProduitsParrainage(page, maxpages, typeAffichage, passoverurl) {
	showPagesParrainage (page, maxpages, typeAffichage);

	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
		alert ("Your browser does not support AJAX!");
		return;
	}

	var url="/affichage/ajaxGetListeProduitParrainage.jsp";
	url=url+"?noPage="+page;
	url=url+"&"+passoverurl;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=listeProduitStateChangedParrainage;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

var fenetre=null;
function PopupCentrer(page,largeur,hauteur,options) {
	var top=(screen.height-hauteur)/2;
	var left=(screen.width-largeur)/2;
	if(fenetre != null){fenetre.close();}
	fenetre = window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options);
}

function ClosePopupCentrer(){
    if(fenetre != null){fenetre.close();}
}

function PopupWindow (Link, Name, Width, Height, Popup) {
	if (Popup == null)
		Popup=false;
	if (Popup == true)
		window.open (Link, Name, 'width='+Width+',height='+Height);
	else
		window.open (Link, Name, 'width='+Width+',height='+Height+'location=yes,menubar=yes,status=yes, toolbar=yes, resizable=yes, scrollbars=yes');
}

function openCmdRapide () {
	var cmdRapideWindow = document.getElementById ("cmdRapide");

	if (cmdRapideWindow.style.display == "none") {
		cmdRapideWindow.style.display = "block";
	} else {
		cmdRapideWindow.style.display = "none";
	}
}

function ajouterCmdRapide () {

	var addpanier = 0;
	var cmdListeRapide = document.getElementsByName("CmdRapide");

	for (i=0;i<cmdListeRapide.length;i++) {
		if (!cmdListeRapide[i].value) {
			continue;
		}
		if (cmdListeRapide[i].value.length == 6) {
			if (addpanier != 0) {
				document.addCmdRapide.ajouterListeProduitsAuPanier.value += "-"
			}
			cmdListeRapide[i].value = "0" + cmdListeRapide[i].value;
			document.addCmdRapide.ajouterListeProduitsAuPanier.value += cmdListeRapide[i].value;
			addpanier++;
		} else if (cmdListeRapide[i].value.length == 7) {
			if (addpanier != 0) {
				document.addCmdRapide.ajouterListeProduitsAuPanier.value += "-"
			}
			document.addCmdRapide.ajouterListeProduitsAuPanier.value += cmdListeRapide[i].value;
			addpanier++;
		}
	}

	document.addCmdRapide.action = location.href;
	document.addCmdRapide.submit();
}

function ajouterCmdRapideServiceCadeau() {

	var addpanier = 0;
	var cmdListeRapide = document.getElementsByName("CmdRapideSC");

	for (i=0;i<cmdListeRapide.length;i++) {
		if (!cmdListeRapide[i].value) {
			continue;
		}
		if (cmdListeRapide[i].value.length == 6) {
			if (addpanier != 0) {
				document.addCmdRapideSC.ajouterListeProduitsAuPanier.value += "-"
			}
			cmdListeRapide[i].value = "0" + cmdListeRapide[i].value;
			document.addCmdRapideSC.ajouterListeProduitsAuPanier.value += cmdListeRapide[i].value;
			addpanier++;
		} else if (cmdListeRapide[i].value.length == 7) {
			if (addpanier != 0) {
				document.addCmdRapideSC.ajouterListeProduitsAuPanier.value += "-"
			}
			document.addCmdRapideSC.ajouterListeProduitsAuPanier.value += cmdListeRapide[i].value;
			addpanier++;
		}
	}

	document.addCmdRapideSC.action = location.href;
	document.addCmdRapideSC.submit();
}


function OpenWin(noRefImage){
	chaine = '/abonnementsmagazines/kiosquePopup.jsp?produitAccedeAvecCatalogue=' + noRefImage;
	remoteWin = window.open(chaine,'popup','height=400,width=550 toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,resizable=yes');
  window.remoteWin.focus();
}

function my_trim (myString) {
    return myString.replace(/^\s+/g,'').replace(/\s+$/g,'')
}

function showInfoBoxIndex_Off(){
    if(document.getElementById ("Avantages") != null){
        document.getElementById ("Avantages").style.display = "none";
        document.getElementById ("AvantagesBut").className = "toprubmenu";
    }


    if(document.getElementById ("QuiSommeNous") != null){
        document.getElementById ("QuiSommeNous").style.display = "none";
        document.getElementById ("QuiSommeNousBut").className = "toprubmenu";
        document.getElementById ("QuiSommeNousBut2").innerHTML = "<img src=\"/images/rubmenuright.jpg\" alt=\"\" /><br />";
    }

    if(document.getElementById ("Inscription") != null){
        document.getElementById ("Inscription").style.display = "none";
        document.getElementById ("InscriptionBut").className = "toprubmenu";
        document.getElementById ("InscriptionBut2").innerHTML = "<img width='9'src=\"/images/rubmenuleft.jpg\" alt=\"\" /><br />";
    }
}

function showInfoBoxIndex (box) {

	if (box == "Inscription") {
        if(document.getElementById (box).style.display == "block"){
            document.getElementById ("InscriptionBut").className = "toprubmenu";
            document.getElementById ("InscriptionBut2").innerHTML = "<img width='9'src=\"/images/rubmenuleft.jpg\" alt=\"\" /><br />";
            document.getElementById (box).style.display = "none";
        }else{
            document.getElementById ("InscriptionBut").className = "toprubmenudown";
            document.getElementById ("InscriptionBut2").innerHTML = "<img width='9'src=\"/images/rubmenuleftover.jpg\" alt=\"\" /><br />";
            document.getElementById (box).style.display = "block";
        }

        /*autres boite*/
        document.getElementById ("Avantages").style.display = "none";
        document.getElementById ("AvantagesBut").className = "toprubmenu";
        document.getElementById ("QuiSommeNous").style.display = "none";
        document.getElementById ("QuiSommeNousBut").className = "toprubmenu";
        document.getElementById ("QuiSommeNousBut2").innerHTML = "<img width='9'src=\"/images/rubmenuright.jpg\" alt=\"\" /><br />";

	} else if(box == "Avantages"){
        if(document.getElementById (box).style.display == "block"){
           document.getElementById ("Avantages").style.display = "none";
           document.getElementById ("AvantagesBut").className = "toprubmenu";
        }else{
           document.getElementById ("Avantages").style.display = "block";
           document.getElementById ("AvantagesBut").className = "toprubmenudown";

        }
        /*autres boite*/
        document.getElementById ("InscriptionBut").className = "toprubmenu";
        document.getElementById ("InscriptionBut2").innerHTML = "<img width='9'src=\"/images/rubmenuleft.jpg\" alt=\"\" /><br />";
        document.getElementById ("Inscription").style.display = "none";
        document.getElementById ("QuiSommeNousBut").className = "toprubmenu";
        document.getElementById ("QuiSommeNousBut2").innerHTML = "<img width='9' src=\"/images/rubmenuright.jpg\" alt=\"\" /><br />";
        document.getElementById ("QuiSommeNous").style.display = "none";

    } else if(box == "QuiSommeNous"){
         if(document.getElementById (box).style.display == "block"){
            document.getElementById ("QuiSommeNous").style.display = "none";
            document.getElementById ("QuiSommeNousBut").className = "toprubmenu";
            document.getElementById ("QuiSommeNousBut2").innerHTML = "<img src=\"/images/rubmenuright.jpg\" alt=\"\" /><br />";
         }else{
            document.getElementById ("QuiSommeNous").style.display = "block";
            document.getElementById ("QuiSommeNousBut").className = "toprubmenudown";
            document.getElementById ("QuiSommeNousBut2").innerHTML = "<img width='9' src=\"/images/rubmenurightover.jpg\" alt=\"\" /><br />";
         }
        document.getElementById ("InscriptionBut").className = "toprubmenu";
        document.getElementById ("InscriptionBut2").innerHTML = "<img width='9' src=\"/images/rubmenuleft.jpg\" alt=\"\" /><br />";
        document.getElementById ("Inscription").style.display = "none";
        document.getElementById ("AvantagesBut").className = "toprubmenu";
        document.getElementById ("Avantages").style.display = "none";
    }
}

function runSubmitAbonnementMagazine(index,cadeau){
    document.formAjoutMagazine.indexProduit.value = index;
    document.formAjoutMagazine.cadeau.value = cadeau;
    document.formAjoutMagazine.submit();
}


function supprimerAbonnement(noRefProduit,cadeau){
   document.formbulletinAbonnement.noRefProduitSupprime.value = noRefProduit;
   document.formbulletinAbonnement.cadeau.value = cadeau;
   document.formbulletinAbonnement.submit();
}

