﻿/************
*  FA PE
*****************/
var IS_IE = document.all && window.print && !window.opera && /MSIE [56]/.test(navigator.userAgent);
var IS_IE7 = document.all && window.print && !window.opera && /MSIE [7]/.test(navigator.userAgent);
var IS_IE_ALL = document.all && window.print && !window.opera && /MSIE/.test(navigator.userAgent);
var IE_W3C = IS_IE && /MSIE [789]/.test(navigator.userAgent);
var IS_Webkit = /Konqueror|Safari|KHTML/.test(navigator.userAgent);
var heightPropertyToUse = IS_IE ? "height" : "minHeight";

/* ecrit les classes dans le tag HTML, pas besoin d'attendre le chargement du body */
document.documentElement.className+=" hasJS"; //cette classe rajoute une classe CSS qui permet des actions afin de cacher ou afficher des elements seulement pour les visiteurs qui ont le Javascript active sur leur navigateur. (exemple le hidesubmit)
if (IS_IE) 
	document.documentElement.className+=" IS_IE"; //cette classe permet d'utiliser des hacks CSS/JS seulement pour IE6 et versions inferieures.
else if (IS_IE7)
	document.documentElement.className+=" IS_IE7"; //cette classe permet d'utiliser des hacks CSS/JS seulement pour IE7

function addEvent( obj, type, fn )
{
	if (obj.addEventListener)
		obj.addEventListener( type, fn, false );
	else if (obj.attachEvent)
	{
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
	}
}
function removeEvent(obj, eventType, functionToCall) {

	if(obj.removeEventListener)

		obj.removeEventListener(eventType, functionToCall, false);

	else if(obj.detachEvent)

		obj.detachEvent('on'+eventType, functionToCall);

}

function getStyle(oElm, strCssRule){
	var strValue = "";
	if(document.defaultView && document.defaultView.getComputedStyle) {
		try{ strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule); }
		catch(e) { strValue = ""; }
	}
	else if(oElm.currentStyle) {
		try{
			strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){
				return p1.toUpperCase();
			});
			strValue = oElm.currentStyle[strCssRule];
		} catch(e) {
			strValue = "";
		}
	}
	return strValue;
}

function intStyle(oElm, strCSSRule) {
	var val = parseInt(getStyle(oElm, strCSSRule));
	if (isNaN(val)) val=0;
	return val;
}
function floatStyle(oElm, strCSSRule) {
	var val = parseFloat(getStyle(oElm, strCSSRule));
	if (isNaN(val)) val=0;
	return val;
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function getMouse(e){
	var x,y; var elt = (navigator.userAgent.indexOf("MSIE 5")!=-1) ? document.body : document.documentElement;
	if ( document.captureEvents ) {
		x = e.pageX;
		y = e.pageY;
	} else if ( window.event.clientX ) {
		x = window.event.clientX+elt.scrollLeft;
		y = window.event.clientY+elt.scrollTop;
	}
	window.mouseX = x;
	window.mouseY = y;
}

function mouseMove(evt) {
	var x = 0;
	var y = 0;
	var plusX = 0;
	var plusY = 0;
	if (document.layers) {
		x = evt.x;
		y = evt.y;
		plusX = window.pageXOffset;
		plusY = window.pageYOffset;
	} else	if (document.all) {
		x = event.clientX;
		y = event.clientY;
		plusX = document.body.scrollLeft;
		plusY = document.body.scrollTop;
	} else if (document.getElementById) {
		x = evt.clientX;
		y = evt.clientY;
		plusX = window.pageXOffset;
		plusY = window.pageYOffset;
	}
	if(global_element_name)
	{
         document.getElementById(global_element_name).style.left = (x+plusX+15)+"px";
	     document.getElementById(global_element_name).style.top = (y+plusY+5)+"px";
        }
} 

var ifrlayer = {
	make:function(obj) {
		if(!obj) return; obj = (typeof(obj)=="string") ? document.getElementById(obj) : obj; if(!obj) return;
		if(document.all && !window.opera && document.getElementById) {
			if(obj.parentNode && !obj.iframelayer) {
			    var ifr = obj.parentNode.insertBefore(document.createElement('<iframe src="javascript:false"></iframe>'), obj);
			    if(obj.currentStyle.zIndex != "" && parseInt(obj.currentStyle.zIndex)>1 ) {
				    ifr.style.zIndex = parseInt(obj.currentStyle.zIndex)-1;
			    }
			    with(ifr.style) {
				    filter = "mask()";
				    position = "absolute";
			    }
                obj.iframelayer = ifr;
            }
		}
		if(obj.iframelayer) {
		    obj.iframelayer.style.visibility="visible";
            ifrlayer.resize(obj);
            ifrlayer.move(obj)
        }
	},
	hide:function(obj) {
		if(!obj) return; obj = typeof(obj)=="string" ? document.getElementById(obj) : obj; if (!obj) return;
		var ifr = obj.iframelayer;
		if(ifr) {
			ifr.style.visibility="hidden";
		}
	},
	move:function(obj) {
		if(obj && obj.iframelayer) {
		    with(obj.iframelayer.style) {
			    top = obj.offsetTop+"px";
			    left = obj.offsetLeft+"px"
		    }
		}
	},
	resize:function(obj) {
	    if(obj && obj.iframelayer) {
	        with(obj.iframelayer.style) {
	            width =  obj.offsetWidth+"px";
		        height =  obj.offsetHeight+"px";
		    }
		}
	}
}
function addHover(elm) {
	elm.style.behavior = " ";
	elm.onmouseenter = function() {
		this.className+= ' hover';
	}
	elm.onmouseleave = function() {
		this.className = this.className.replace(/\bhover\b/,"");
	}
}
var CSSBottomCorners=[]; //array pouvant contenir les coins absolu positionnes en bottom
var currentBlockToFixCorners=null; //variable gloable utilisee lorsqu'on veux fixer les coins sur un seul bloc
function cssRight(elm) {
	elm.style.right=(parseInt(elm.currentStyle.right)-(elm.parentNode.offsetWidth%2))+"px";
}
function cssBottom(elm, pushElement) {
	if (pushElement && !elm.CSSBottomAlreadyCSS) {
		CSSBottomCorners.push(elm);
		elm.CSSBottomAlreadyCSS=true;
	}
	elm.style.bottom=(parseInt(elm.currentStyle.bottom)-(elm.parentNode.offsetHeight%2))+"px";
}

function fixCorners(block) {
	if (IS_IE) {
		for (i=CSSBottomCorners.length-1; i>-1; --i) {
			CSSBottomCorners[i].style.bottom="";
		}
	} else {
		if (IS_Webkit || /Gecko\/200[56]|Opera 8.5/i.test(navigator.userAgent)) fixCornersOnBlocks(block);
	}
}

function fixCornersOnBlocks(block) {
	currentBlockToFixCorners = block || document.body;
	currentBlockToFixCorners.className+=" hidecorners";
	setTimeout("fixCornersOnBlocksShowCorners()",5);
}

function fixCornersOnBlocksShowCorners() {
	if (currentBlockToFixCorners) currentBlockToFixCorners.className=currentBlockToFixCorners.className.replace(/\bhidecorners\b/g,"");
	currentBlockToFixCorners=null;
}
var evaluationMaxNote = 5;
function evaluationInitFields() {
	var p = document.getElementsByTagName("p");
	for (var i=0; i<p.length; i++) {
		var x = p[i];
		if (x.className.match(/\beval\b/)) {
			var img = x.getElementsByTagName("img");
			if (img.length>0) {
				img = img[0];
				img.onmousemove=function(e) {
					evaluationAnimation(this,e);
				}
				img.onmouseout=function() {
					evaluationClearAnim(this)
				}
				img.onclick=function() {
					evaluationSetGrade(this, this.overGrade, true)
				}
			}
		}
	}
}

function evaluationAnimation(img,e) {
	getMouse(e);
	var starWidth = img.offsetWidth/evaluationMaxNote;
	var imgX = findPos(img)[0];
	var mousePosX = window.mouseX-imgX;
	var note = parseInt(mousePosX/starWidth)+1;
	note = note>evaluationMaxNote ? evaluationMaxNote : note<1 ? 1 : note;
	img.overGrade = note;
	if (!img.protectedGrade) evaluationSetGrade(img, note);
}

function evaluationSetGrade(img, note, saveGrade) {
	img.src=img.src.replace(/\d{1}sur/,note+"sur");
	if (saveGrade) {
		img.savedGrade = note;
		evaluationSendGradeByAjax(note);
	}
}

function evaluationClearAnim(img) {
	if (!img.savedGrade) img.savedGrade = 0;
	evaluationSetGrade(img, img.savedGrade);
}

function DisplayFlash(flashFile,width,height,quality,wmode,idHtml,background) {
  document.write('<object id="'+ idHtml +'" type="application/x-shockwave-flash" data="'+ flashFile +'" width="'+ width +'" height="'+ height +'">');
  document.write('  <param name="movie" value="'+ flashFile +'" />');
  document.write('  <param name="allowScriptAccess" value="sameDomain" />');
  document.write('  <param name="quality" value="'+ quality +'" />');
  document.write('  <param name="wmode" value="'+ wmode +'" />');
  document.write('  <param name="bgcolor" value="'+ background +'" />');
  document.write('  <embed src="'+ flashFile + '" quality="high" wmode="'+ wmode +'" width="'+ width +'" height="'+ height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
  document.write('</object>');
}
function getElementsByClassName(oElm, sTagName, sClassName)
{
  var aElements = (sTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(sTagName);
  var aReturnElements = new Array();
  sClassName = sClassName.replace(/\-/g, "\\-");
  var oRegExp = new RegExp("(^|\\s)" + sClassName + "(\\s|$)");
  var oElement;
  for(var i=0; i < aElements.length; i++)
  {
    oElement = aElements[i];
    if(oRegExp.test(oElement.className))
    aReturnElements.push(oElement);
  }
  return aReturnElements
}

function sousMenuAddHover(elm, position) {
  elm.style.behavior = " ";
  var menu = elm.getElementsByTagName("ul");
  if (menu.length>0) {
    elm.theUl = menu[0];
    ifrlayer.make(elm.theUl);
    elm.onmouseenter = function() {
      this.className+= ' currentJs';
      ifrlayer.make(elm.theUl);
    }
    elm.onmouseleave = function() {
      this.className = this.className.replace(/\b(right)?currentJs\b/,"");
      ifrlayer.hide(this.theUl);
    }
  }
}
function sousMenuActivation(obj,evt,boucle)
{
//  printDebug(evt.keyCode,0);
  function killSousMenu()
  {
    var allLi = obj.parentNode.getElementsByTagName("li");
    for (var i = 0; i < allLi.length; i++)
    {
      allLi[i].className = allLi[i].className.replace(/\b(right)?currentJs\b/,"");
      ifrlayer.hide(this.theUl);
    }
  }
// touche echap
  if (evt.keyCode==27)
  {
    killSousMenu();
  }
// fleche haut
  if (evt.keyCode==38)
  {
    if(!obj.id=="")
    {
      return;
    }
    else
    {
      killSousMenu();
    }
  }
// fleche droite
  if (evt.keyCode==39)
  {
    if(obj.id=="m_photo_camescope")
    {
      killSousMenu();
      document.getElementById("m_livres").getElementsByTagName("a")[0].focus();
      document.getElementById("m_livres").className+=" currentJs";
    }
    else
    {
      killSousMenu();
      var droiteMenu = (IS_IE_ALL) ? obj.nextSibling : obj.nextSibling.nextSibling;
//      var droiteMenu = obj.nextSibling.nextSibling;
      droiteMenu.getElementsByTagName("a")[0].focus();
      droiteMenu.className+=" currentJs";
    }
  }
// fleche bas
  if (evt.keyCode==40)
  {
    return;//non actif encore
    if(!obj.id=="")
    {
      var lesA = obj.parentNode.getElementsByTagName("a");
      for (var j=0;j > lesA.length; j++)
      {
        if(lesA[j])
        {
        }
      }
    }
    killSousMenu();
  }
// fleche gauche
  if (evt.keyCode==37)
  {
    if(obj.id=="m_livres")
    {
      killSousMenu();
      document.getElementById("m_photo_camescope").getElementsByTagName("a")[0].focus();
      document.getElementById("m_photo_camescope").className+=" currentJs";
      ifrlayer.make(elm.theUl);
    }
    else
    {
      killSousMenu();
      var gaucheMenu = (IS_IE_ALL) ? obj.previousSibling : obj.previousSibling.previousSibling;
//       var gaucheMenu = obj.previousSibling.previousSibling;
      gaucheMenu.getElementsByTagName("a")[0].focus();
      gaucheMenu.className+=" currentJs";
      ifrlayer.make(elm.theUl);
    }
  }
}

function printDebug(debug, ecrase){
  var monId = document.getElementById("header");
  if (document.getElementById("debugJS"))
  {
    if(ecrase==0)
    {
      nouveauDiv.innerHTML+="<pre>"+debug+"</pre>";
    }
    else
    {
      nouveauDiv.innerHTML="<pre>"+debug+"</pre>";
    }

  }
  else{
    nouveauDiv = document.createElement("div");//creation  de l objet
    nouveauDiv.id="debugJS";//identification
    nouveauDiv.style.display="block";//on le stylise un peu
    nouveauDiv.style.position="absolute";
    nouveauDiv.style.top="20px";
    nouveauDiv.style.left="0px";
    nouveauDiv.style.background="black";
    nouveauDiv.style.border="solid 1px #900";
    nouveauDiv.style.zIndex="60";
    nouveauDiv.style.fontSize="11px";
    nouveauDiv.style.overflow="auto";
    nouveauDiv.style.height="600px";
    nouveauDiv.style.width="auto";
    nouveauDiv.style.padding="5px";
    nouveauDiv.innerHTML="<pre>"+debug+"</pre>";
    monId.parentNode.insertBefore(nouveauDiv, monId);//on insert l'objet avant la balise appele
  }
}

function popinIt(obj, id, tag, className, noeuxParent, popinClassName, onOff){
  if (onOff=="on"){
    //ici on supprime tout popup deja affiche pour eviter qu ils se montent les uns sur les autres, mais a voir a passer en variable
    if (document.getElementById("jeVeuxEtreSupprimer")){
      var del = document.getElementById("jeVeuxEtreSupprimer");
      del.parentNode.removeChild(del);
    }
    var remplissage = getElementsByClassName(document.getElementById(id), tag, className)[0].innerHTML; //recup le HTML
    nouveauDiv = document.createElement("div");//creation  de l objet
    nouveauDiv.id="jeVeuxEtreSupprimer";//identification
    nouveauDiv.className="popin "+popinClassName;//on le classifie
    nouveauDiv.style.display="block";//on le display block car en none en css
    nouveauDiv.innerHTML = remplissage;// on rempli le bloc
    obj.parentNode.insertBefore(nouveauDiv, obj);//on l insert l objet avant la balise appele
    var leNouveauDiv = document.getElementById("jeVeuxEtreSupprimer");
    var leParentLeNouveauDiv = noeuxParent;// on selectionne l element parent pour calculer sa difference de positionnement
    var ouLeNouveauDiv = leNouveauDiv.offsetHeight+leNouveauDiv.offsetTop;
    var ouLeParentLeNouveauDiv = leParentLeNouveauDiv.offsetHeight+leParentLeNouveauDiv.offsetTop;
    //si il depasse en bas, alors on le deroule vers le haut
    if (ouLeNouveauDiv>ouLeParentLeNouveauDiv){
      leNouveauDiv.getElementsByTagName("span")[0].className="popbr";
      leNouveauDiv.style.marginTop="-"+leNouveauDiv.offsetHeight+"px";
    }
    //si il depasse a gauche, on le deroule a droite
    if (leNouveauDiv.offsetLeft<1){
      leNouveauDiv.getElementsByTagName("span")[0].className="popbl";
      leNouveauDiv.className+=" popInDerouleDroite";
    }
  }
  else{
      var del = document.getElementById("jeVeuxEtreSupprimer");
      del.parentNode.removeChild(del);
  }
}

function toggle() {
 for (i=0;i<document.getElementsByTagName("div").length; i++) {
	if (document.getElementsByTagName("div").item(i).className == "event"){

			if (document.getElementsByTagName("div").item(i).style.display == "none"){
				document.getElementsByTagName("div").item(i).style.display = "";
			} else {
				document.getElementsByTagName("div").item(i).style.display = "none";
			}
		}
	}
 }

function toggleAndWrite(artlink,Title,TypeId, gauche, haut)
{

	var listArt = artlink.toString();
	listArt = listArt.replace(/\|\|/g, ', ');
	listArt = listArt.replace(/,\s+$/, '.');
	
	for (i=0;i<document.getElementsByTagName("div").length; i++) {
		if (document.getElementsByTagName("div").item(i).className == "event"){
		
			if (document.getElementsByTagName("div").item(i).style.display == "none"){
				document.getElementsByTagName("div").item(i).style.display = "";
				document.getElementsByTagName("div").item(i).style.position = "absolute";
				document.getElementsByTagName("div").item(i).style.left = gauche+"px";
				document.getElementsByTagName("div").item(i).style.top = haut+"px";

				document.getElementsByTagName("div").item(i).innerHTML = "<span class='toggle'><a href='/' onclick='toggle(1); return false' title='Masquer l explication'>X</a></span><p style='padding: 0 7px; background-color: #A3A3A3; color: #fff;'>Nous vous proposons " + TypeId + " <strong>" + Title + "</strong> parce que vous avez consult&eacute;<br /></p><p style='padding: 7px; background-color: #fff; color: #A3A3A3;'><strong>" + listArt + "</strong></p>";
			} else if (document.getElementsByTagName("div").item(i).style.display == "") {
				
				document.getElementsByTagName("div").item(i).style.position = "absolute";
				document.getElementsByTagName("div").item(i).style.left = gauche+"px";
				document.getElementsByTagName("div").item(i).style.top = haut+"px";
				
				document.getElementsByTagName("div").item(i).innerHTML = "<span class='toggle'><a href='/' onclick='toggle(1); return false' title='Masquer l explication'>X</a></span><p style='padding: 0 7px; background-color: #A3A3A3; color: #fff;'>Nous vous proposons " + TypeId + " <strong>" + Title + "</strong> parce que vous avez consult&eacute;<br /></p><p style='padding: 7px; background-color: #fff; color: #A3A3A3;'><strong>" + listArt + "</strong></p>";
			} else {
				document.getElementsByTagName("div").item(i).style.display = "none";
			}
		 }
	}
}

//http://www.diplok.com/1ppl/html/article103.html
var sldValue=0
var sldTop=0
var sldLeft=0
var doDrag=false
var sldMouseLeft=0
var sldMouseTop=0

function getAbsLeft(o) {
	var oLeft = o.offsetLeft
	while(o.offsetParent!=null) {
		oParent = o.offsetParent
		oLeft += oParent.offsetLeft
		o = oParent
	}
	return oLeft
}

function getAbsTop(o) {
	var oTop = o.offsetTop
	while(o.offsetParent!=null) {
		oParent = o.offsetParent
		oTop += oParent.offsetTop
		o = oParent
	}
	return oTop
}

function setLeft(o,oLeft) {
	o.style.left = oLeft + "px"
}

function setTop(o,oTop) {
	o.style.top = oTop + "px"
}

function setPosition(o,oLeft,oTop) {
	setLeft(o,oLeft)
	setTop(o,oTop)
}

function sldMouseDown(e)
{
	if (!e) {e = window.event}
	doDrag=true
	o=document.getElementById("event1")
	sldLeft=getAbsLeft(o)
	sldTop=getAbsTop(o)
	sldMouseLeft=e.clientX-sldLeft
	sldMouseTop=e.clientY-sldTop
}

function sldMouseUp(e)
{
	doDrag=false
}

function sldMouseMove(e)
{
	if (!e) {e = window.event}
	if (doDrag)
	{
		o=document.getElementById("event1")
		setPosition(o,e.clientX-sldMouseLeft,e.clientY-sldMouseTop)
		return false
	}
}

document.onmousemove = sldMouseMove;

function getTaille(Elem) {


   if(document.getElementById) {
      var elem = document.getElementById(Elem);
   } else if (document.all){
      var elem = document.all[Elem];
   }
   window.wPos = elem.offsetWidth;
   window.hPos = elem.offsetHeight;


}

function popinModal(id) {
    var elem = document.getElementById(id);
    if(elem.style.display == "block") {
      elem.style.display = "none";
      if(IS_IE) {ifrlayer.hide(elem);}
    } else {

      elem.style.display = "block";
       if(IS_IE) {ifrlayer.make(elem);}
      window.getTaille(id);
      var large = (screen.availWidth - wPos)/2;
      var haut = (screen.availHeight - hPos)/2;

     elem.style.zIndex = 999;
     elem.style.position = "absolute";
     elem.style.left = large+"px";
     elem.style.top = haut+"px";
     //alert(screen.availHeight+" "+hPos);
   }
}
/* filter:  permet de filtrer un array avec une fonction passee en parametre*/ 
function filter(arr, f) {
	   	var out = new Array();
    	var j = 0;
		for(var i = 0; i<arr.length; ++i) {
	   		if(f(arr[i])) {
	       		out[j++] = arr[i];
	       	}
       	}
	return out;
}

/* getText : retourne le text d'un element */
function getText(elt) {
	if (elt.textContent) {
		return elt.textContent;
	} else {
		return elt.innerText;
	}
}
/* cancelClick, permet de supprimer la propagation du click sur un element */
var cancelClick=function(e){
	if (window.event){
		window.event.cancelBubble = true;
		return;
	}
	if (e){
		if (e.stopPropagation) {
			e.stopPropagation();
		}
	}
}

var cancelBubble=function(e) {
	if (window.event){
		window.event.cancelBubble = true;
		window.event.returnValue = false;
		return;
	}
	if (e){
		e.stopPropagation();
		e.preventDefault();
	}
}

function GetCookie (name) {
	var arg=name+"=";
	var alen=arg.length;
	var clen=document.cookie.length;
	var i=0;
	while (i<clen) {
		var j=i+alen;
		if (document.cookie.substring(i, j)==arg)
                        return getCookieVal (j);
                i=document.cookie.indexOf(" ",i)+1;
                        if (i==0) break;}
	return null;
}

function SetCookie (name, value) {
	var argv=SetCookie.arguments;
	var argc=SetCookie.arguments.length;
	var expires=(argc > 2) ? argv[2] : null;
	var path=(argc > 3) ? argv[3] : null;
	var domain=(argc > 4) ? argv[4] : null;
	var secure=(argc > 5) ? argv[5] : false;
	document.cookie=name+"="+escape(value)+
		((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
		((path==null) ? "" : ("; path="+path))+
		((domain==null) ? "" : ("; domain="+domain))+
		((secure==true) ? "; secure" : "");
}

/* Onglets Fnac */
var fnactab={
    tabClass:'domtab', //classe du block qui englobe la liste des onglets
    listClass:'domtabs', //classe du menu UL des onglets
    activeClass:'active', //classe active d'un onglet
    currentTab:0, //numero d'index de l'onglet courrant
    menuButtons:[], //tableau contenant une reference des onglets courants
    tabsElements:[], //tableau contenant une reference des blocks d'onglets courants
    init:function() {
        if(!document.getElementById || !document.createTextNode){return;}
        //find the tabbed menu
        var ul = getElementsByClassName(document, "ul",fnactab.listClass );
        if (ul.length==0) return;
        var menu=ul[0];
        
        var lis = menu.getElementsByTagName("li");
        //init buttons menu
        for (var i=0; i<lis.length; i++) {
            var b = lis[i];
            fnactab.menuButtons.push(b);
            if (b.className.match("\\b"+fnactab.activeClass+"\\b")) {
                fnactab.currentTab = i;
            }
            b.indexMenu=i;
            var a = b.getElementsByTagName("a");
            if (a.length>0) a=a[0];
            if (a) {
                a.indexMenu=i;
                a.onclick=function() {
                    fnactab.showtab(this.indexMenu);
                    return false;
                }
            }
        }
        fnactab.menuButtons[fnactab.currentTab].className=fnactab.activeClass;
        //find tabs blocks elements
        var blk = menu;
        while(blk && !blk.className.match("\\b"+fnactab.tabClass+"\\b")) blk=blk.parentNode;
        if (!blk) return;
        var childs = blk.parentNode.childNodes; //on recupere tous les enfants du block, y compris les noeuds de type textes.
        var firstDiv=true; //booleen pour eviter de passer sur le premier div
        for (var i=0; i<childs.length; i++) {
            var block = childs[i];
            if (block.nodeName=="DIV") { //on filtre pour ne recuperer que les divs
                if (firstDiv) {
                    firstDiv=false;
                } else {
                    fnactab.tabsElements.push(block);
                    block.style.display="none";
                }
            }
        }
        fnactab.tabsElements[fnactab.currentTab].style.display="block";
        fnactab.LoadTabFromCookie();
    },
    showtab:function(tabnum) {
        switch(typeof(tabnum)) {
            case "object": 
                    tabnum = tabnum.indexMenu;
                    break;
            case "string":
                    if (!isNaN(parseInt(tabnum))) {
                        tabnum=parseInt(tabnum);
                    } else {
                        tabnum = document.getElementById(tabnum);
                        if (tabnum) tabnum = tabnum.indexMenu;
                    }
                    break;
        }
        if (tabnum==null || tabnum<0 || tabnum>=fnactab.menuButtons.length) tabnum=0;
        
        fnactab.menuButtons[fnactab.currentTab].className=""; //onglet courant a off
        fnactab.menuButtons[tabnum].className=fnactab.activeClass; //nouvel onglet a on
        fnactab.tabsElements[fnactab.currentTab].style.display="none"; //block courant cache
        fnactab.tabsElements[tabnum].style.display="block"; //block nouvel onglet affiche
        fnactab.currentTab=tabnum; 
        fnactab.SaveTab();
    },
    LoadTabFromCookie:function() {
        var tab = GetCookie("fnacTab_DefaultTab");
        var url = GetCookie("fnacTab_SavedUrl");
        if (tab && url && !isNaN(parseInt(tab)) && url==document.location.toString()) {
            fnactab.showtab(tab);
        }
    },
    SaveTab:function() {
        SetCookie("fnacTab_DefaultTab",fnactab.currentTab);
        SetCookie("fnacTab_SavedUrl",document.location.toString());
    }
}

var openCloseGroup={
    groupClass:"open_close_group_parent",
    childClass:"open_close_group_child",
    childClosedClass:"open_close_group_closed_child",
    actionClass:"open_close_group_action_elt", //Element qui va etre clicable
    hideClass:"open_close_groupe_elttohide", //classe qui va afficher/cacher les elements
    init:function() {
        var home = document.getElementById("home"); if (!home) return;
        var div= home.getElementsByTagName("div");
        for(var i=0;i<div.length;i++) { //on cherche tous les groups de blocs open/close
            var thediv = div[i];
            if (thediv.className.match("\\b"+openCloseGroup.groupClass+"\\b")) { //des qu'on en trouve un
                var childs = thediv.getElementsByTagName("div");
                if(!childs.length > 0) return; // protection si le control Tracks est écrit sans contenu
                for(var j=0;j<childs.length;j++) { 
                    var thechild = childs[j];
                    if (thechild.className.match("\\b"+openCloseGroup.childClass+"\\b")) { //des qu'on a un enfant
                        thechild.parentGroup=thediv;
                        if (!thediv.currentOpenedChild) {
                            thediv.currentOpenedChild=thechild;
                        }
                        var ChildElements = thechild.getElementsByTagName("*");
                        for (var h=0; h<ChildElements.length;h++) {
                            var x = ChildElements[h];
                            if (x.className.match("\\b"+openCloseGroup.actionClass+"\\b")) {
                                x.onclick=openCloseGroup.gotoGroupAndOpenClose;
                            }
                        }
                        openCloseGroup.close(thechild);
                    }
                }
                openCloseGroup.open(thediv.currentOpenedChild);
                i+=childs.length;
            }
        }
    },
    close:function(elt) { 
        elt.className=elt.className.replace(openCloseGroup.childClass,openCloseGroup.childClosedClass);
    },
    open:function(elt) {
        elt.className=elt.className.replace(openCloseGroup.childClosedClass,openCloseGroup.childClass);
    },
    gotoGroupAndOpenClose:function() {
        var obj = this; 
        while(obj.parentNode && !new RegExp("\\b"+openCloseGroup.childClosedClass+"\\b|\\b"+openCloseGroup.childClass+"\\b").test(obj.className)) {
            obj=obj.parentNode; //on remonte jusqu'au premier parent
        }
        if (!obj.parentNode) return;
        var x=obj.parentGroup;
        openCloseGroup.close(x.currentOpenedChild);
        openCloseGroup.open(obj);
        x.currentOpenedChild=obj;
        return false;
    }
}

/* initialise le lien lire tous les avis*/
function initProductPage() {
	var tmp; //navDiaporama=false;
	var div = document.getElementsByTagName("div"); //init hoverBlock
	for (var i=0; i<div.length; i++) {
		var x = div[i]; 
		if (x.className.indexOf("hoverBlock")!=-1) { 
			with(x.style) { position="absolute"; display="none"; }
		}
	}
	//init readAdviceslink
	var advlnk = document.getElementById(readAllAdvicesLink);
	if (advlnk) { 
		advlnk.onmouseover = function(e) { popLayerMakeContent(e,"advice"); }
		advlnk.onmouseout = function() { popLayerClose() }
		advlnk.onmousemove = function(e) {popLayerShow(e);}
	}
	hoverblock.init(document);
}

var readAllAdvicesLink = "readAllAdvicesLink";
var internautesadviceId = "lastBestComment";
function popLayerMakeContent(e, type, obj) {
	var pop = popLayerShow(e);	
	if (pop && type) {
		switch (type.toLowerCase()) {
			//get first user advice
		case "advice" :	var Avislst = document.getElementById(internautesadviceId);
						if (Avislst) {
							var avis = Avislst;
							if (avis) {
								pop.innerHTML = avis.innerHTML;
								var p = pop.getElementsByTagName("p");
								for (var i=0; i<p.length; i++) {
									if (p[i].className.indexOf("ndlr")!=-1) p[i].parentNode.removeChild(p[i]);
								}
							}
						}
						break;
		case "service" : pop.innerHTML = obj.innerHTML;
						 break;
		}
	}
	ifrlayer.make(pop);
}

function popLayerShow(e,normalTop) {
	var home = document.getElementById("home");
	var html = document.getElementsByTagName((navigator.userAgent.indexOf("MSIE 5")!=-1) ? "body" : "html")[0];
	var body = document.getElementsByTagName("body")[0];
	getMouse(e);
	var popup = document.getElementById("popLayer"); 
	if (!popup) {
		var tmp = document.createElement("div");
		tmp.className="hoverBlock filledBox";
		tmp.id="popLayer";
		with(tmp.style) {position="absolute"; display="block";}
		popup = home.appendChild(tmp);
	}
	
	if (popup) {
		if (popup.className!="hoverBlock filledBox") popup.className="hoverBlock filledBox";
		with(popup.style) {
			if (display!="block") display = "block";
			left = (window.mouseX+popup.clientWidth+10>html.scrollLeft+html.clientWidth-10) ? (html.scrollLeft+html.clientWidth-popup.clientWidth-10)+"px" : window.mouseX+10+"px";
			top = (window.mouseY+popup.clientHeight+10>html.scrollTop+html.clientHeight-10 && !normalTop) ? (window.mouseY-popup.clientHeight-10)+"px" : window.mouseY+10+"px";
		}
	   popup.style.visibility = "visible";
		ifrlayer.move(popup);
		return popup;
	}
	return null;
}

function popLayerClose() {
	var popup = document.getElementById("popLayer"); 
	if (popup) {
	   popup.style.visibility = "hidden"; 
	    popup.innerHTML="";
	    ifrlayer.hide(popup);
	}
}
function closePop(str){ // ajout pour les FAPE uniquement, nouvelle fonction de fermeture des zooms
	var pop = document.getElementById(str);
	if(typeof(pop) != "undefined" && pop != null)
	{
		$(pop).children("p").children("span").children("img").attr("src","");
		$(pop).css("visibility","hidden");
		ifrlayer.hide(pop);
	}
}

var navDiaporama={
    container:null,
    container2:null,
    imagesContainer:null,
    imagesContainer2:null,
    imagesList:[],
    imagesList2:[],
    indexSoftList:null,
    currentImg:null,
	hiddenImgs:[],
	hiddenImgsSrc:[],
    zoomButton:null,
    turnpagesButton:null,
	turnpages:"false",
    arrow:{ left:null, right:null },
    popZoomId:"popZoomImage",
    popZoom:null,
    init:function() {

        var x, firstArrow=false;
        var home = document.getElementById("home"); if (!home) return;

	    var divtmp = getElementsByClassName(home, "div", "nav-diaporama");
			
        if (divtmp.length > 0) { var nav=divtmp[0]; }
        else return;
		if (divtmp.length > 1) { var nav2=divtmp[1]; }
        //else return;
        
		//on parcourt les childnodes de l'element pour ajouter les fonctionnalites necessaires.
		//Le contenu de l'element doit respecter le schema : <a flechegauche><span blockdimages><a flechedroite> 

	    navDiaporama.container=nav;
	    var childs=nav.childNodes;
	    for (var i=0; i<childs.length; i++){ 
		    var chd=childs[i];
		    switch (chd.nodeName) {
			    case "A": //si on rencontre un lien on le considere comme une fleche de nav
				    if (!firstArrow) {
					    chd.onclick=function() {
						    navDiaporama.gotoImg(1);
						    return false;
					    }
					    navDiaporama.arrow.left=chd;
					    firstArrow=true;
				    } else {
					    chd.onclick=function() {
						    navDiaporama.gotoImg(-1);
						    return false;
					    }
					    navDiaporama.arrow.right=chd;
				    }
				    break;
			    case "SPAN": //ici on doit obligatoirement rencontrer le bloc d'images
				    navDiaporama.imagesContainer=chd;
				    var imgs = chd.childNodes;
				    var k=0;
				    for (var j=0; j<imgs.length; j++) {
					    var img=imgs[j];
					    if (/A|SPAN/.test(img.nodeName)) {
						    navDiaporama.imagesList.push(img);
						    img.indexNumber=navDiaporama.imagesList.length-1;
						    if (img.nodeName=="A") {
							    img.onclick=navDiaporama.showZoomImg;
						    }
						    if (img.className.match(/\bactiveimg\b/)){
							    navDiaporama.currentImg = img;
						    }
						    else {
							    navDiaporama.hiddenImgs[k] = img;
							    navDiaporama.hiddenImgsSrc[k] = navDiaporama.hiddenImgs[k].childNodes[0].src;
							    k++;
						    }
					    }
				    }
		    }
	    }
	    
	    if (divtmp.length > 1) { 
	        navDiaporama.container2=nav2;
	        var childs2=nav2.childNodes;
	        var j = 0;
	        for (var i=0; i<childs2.length; i++){ 
	            if (childs2[i].nodeName == "A") {
			       navDiaporama.imagesList2.push(childs2[i]);
			       navDiaporama.indexSoftList=navDiaporama.imagesList2.length-1;
                   childs2[i].onclick=navDiaporama.showSoftZoomImg;
                   childs2[i].indexImg = j;
                   j++;
	            }
	        }
	    }
	    
		//initialise le lien pour zoomer l'image et les liens pour Feuilleter les pages
		var par = navDiaporama.container.parentNode;
		var a = par.getElementsByTagName("a");
		for (var i=0;i<a.length;i++) {
			if (a[i].className.match(/\b(expandimg)\b/)) {
				navDiaporama.zoomButton = a[i];
				navDiaporama.zoomButton.onclick = navDiaporama.showZoomImg;
			}
			if (a[i].className.match(/\b(turnpagesButton)\b/)) {
				navDiaporama.turnpagesButton = a[i];
				navDiaporama.turnpagesButton.onclick = navDiaporama.showTurnpagesImg;
			}
		}

		//verifie s'il y a une image par defaut, sinon on en active une
		if(navDiaporama.imagesList.length>0 && !navDiaporama.currentImg) {
			navDiaporama.currentImg = navDiaporama.imagesList[0];
			navDiaporama.showImg(0);
		}
		
		//verifie si il n' y a plus d'une image dans le diaporama, dans ce cas on affiche les fleches
		if (navDiaporama.imagesList.length>1) {
			for (elt in navDiaporama.arrow) {
				var x = navDiaporama.arrow[elt];
				if (x && x.style) { x.style.display="inline"; }
			}
		}
	},
    gotoImg:function(sens) {
        var num =  navDiaporama.currentImg.indexNumber;
        num+=sens;
        if (num<0) num = navDiaporama.imagesList.length-1;
        if (num>=navDiaporama.imagesList.length) num=0;
        navDiaporama.showImg(num);
    },
    showImg:function(imgIndex) {
        navDiaporama.currentImg.className="";
        if (!navDiaporama.imagesList[imgIndex]) return;
        navDiaporama.currentImg=navDiaporama.imagesList[imgIndex];
        navDiaporama.currentImg.className="activeimg";
        if (navDiaporama.zoomButton) {
            if (navDiaporama.currentImg.nodeName!="A" || navDiaporama.currentImg.href=="" || !/.jpg$|.bmp$|.image$|.gif$|.png$/.test(navDiaporama.currentImg.href)) {
                navDiaporama.zoomButton.parentNode.style.visibility="hidden";
            } else {
                navDiaporama.zoomButton.parentNode.style.visibility="visible";
            }
        }
    },
    showZoomImg:function(e) {
        if (navDiaporama.currentImg.nodeName=="A" && navDiaporama.currentImg.href!="" && /.jpg$|.bmp$|.image$|.gif$|.png$|.media$/.test(navDiaporama.currentImg.href)) {
            navDiaporama.turnpages = "false";
			var pop=navDiaporama.makePopZoom();
			pop.zoomImage.src = navDiaporama.currentImg.href;
            pop.move();
            ifrlayer.make(pop);
        }
		return false;
    },
    showSoftZoomImg:function(e) {
       var firingElement = e.currentTarget;
       if( firingElement != null )
       {
            navDiaporama.turnpages = "false";
            pop=navDiaporama.makePopZoom();
            pop.zoomImage.src = navDiaporama.imagesList2[firingElement.indexImg];
            pop.move();
            ifrlayer.make(pop);
       }
       return false;
    },
    showTurnpagesImg:function(e) {
	 if (navDiaporama.currentImg.nodeName=="A" || navDiaporama.currentImg.nodeName=="SPAN") {   
        //evite d'ajouter un 2e navPage
        var navPage = document.getElementById("navPage");
	    var popZoomId = document.getElementById("popZoomImage");
	    if (navPage) { popZoomId.removeChild(navPage); }
	    ///
        navDiaporama.turnpages = "true";
		var pop=navDiaporama.makePopZoom();
		pop.zoomImage.src = navDiaporama.hiddenImgsSrc[0];
        pop.move();
        ifrlayer.make(pop);
     }
	 return false;
    },
    makePopZoom:function(e){
		
		var pop = document.getElementById(navDiaporama.popZoomId);
		
		if (!pop) {
		
		    var div = document.createElement("div");
		    div.id=navDiaporama.popZoomId;
		    div.innerHTML = '<ul><li><a href="#" onclick="closePop(\'popZoomImage\');return false">Fermer</a></li></ul>';

		    div.style.visibility="hidden";
    		
		    var zoomBlock = div.appendChild(document.createElement("p"));
    		
		    zoomBlock.style.verticalAlign="middle";	
    		
		    var span = zoomBlock.appendChild(document.createElement("span"));
		    var img = span.appendChild(document.createElement("img"));
		    img.onload=function() {
			    pop.className="";
			    pop.getPositionFromWindow;
			    this.pop.move();
			    ifrlayer.resize(pop);
		    } 
    		
		    div.zoomImage = img;
		    img.pop = div;
		    div=document.body.appendChild(div);
		    pop=div;
		    navDiaporama.popZoom = div;
    		
		    var AllElt = div.getElementsByTagName("*");
		    for(var i=0; i<AllElt.length;i++) {
			    AllElt[i].onmousemove=AllElt[i].onmousedown=function() {return false};
		    }

		    pop.move        = navDiaporama.movePopZoom;
		    pop.onmousedown = navDiaporama.makePopZoomDraggable;
		    addEvent(pop,"mousedown", cancelBubble);
		    addEvent(pop,"dblclick", navDiaporama.hidePopZoom);
		    
		    
		    //gestion du copyright de l'image
            
            copyright = null;
            eltParentImg = navDiaporama.currentImg.parentNode;
            bElementCurrent = false;
            
            var i;
            for( i=0;i<eltParentImg.childNodes.length;i++ ) { 
                if( navDiaporama.currentImg == eltParentImg.childNodes[i] ) {
                    bElementCurrent = true;
                }
                else if( bElementCurrent ) {
                    // si le type du noeud n'est pas du texte et que c'est un element span, alors on recupere le copyright
                    if (eltParentImg.childNodes[i].nodeType != 3 && eltParentImg.childNodes[i].nodeName.toLowerCase() == "span" ) {
                        var span = eltParentImg.childNodes[i];
                        if (span.childNodes[0].nodeName.toLowerCase() != "img") {
                            copyright = eltParentImg.childNodes[i];
                            break;
                        }
                    }
                    if (eltParentImg.childNodes[i].nodeType != 3 && eltParentImg.childNodes[i].nodeName.toLowerCase() != "span" ) {
                        copyright = null;
                        break;
                    }
                }
            }


            if (copyright != null) {
               if (!pop.copyright ) {
                    var popCopyright = pop.appendChild(document.createElement("p"));
                    popCopyright.className = "copyright noir lienInverse";
                    pop.copyright = popCopyright;
                }
                if (/\w/.test(getText(copyright)) ) {
                    pop.copyright.innerHTML = copyright.innerHTML;
                    pop.copyright.style.display = "block";
                } else {
                    pop.copyright.style.display = "none";
                }
            }

            //fin du copyright
        }

        //gestion des fleches pour feuilletter les pages

        //pour passer du zoom "Feuilleter les pages" au zoom "Agrandir l'image" on supprime les fleches
		if (pop && navDiaporama.turnpages == "false") {
		    var navPage = document.getElementById("navPage");
		    var popZoomId = document.getElementById("popZoomImage");
		    if (navPage) { popZoomId.removeChild(navPage); }
		}
		else if (!navPage) {
            //on ne compte pas le dernier span qui contient le copyright
            if (copyright != null) var numPage = navDiaporama.hiddenImgsSrc.length-1;
            else var numPage = navDiaporama.hiddenImgsSrc.length;
			
			if (numPage > 1) {

                var navPage = pop.appendChild(document.createElement("p"));
                navPage.id = "navPage";
                navPage.className = 'txt_c';
                //navPage.style.backgroundColor = '#eee';
                navPage.style.Height = '2em';

                var aPrev = navPage.appendChild(document.createElement("a"));
                aPrev.href = "#";
                aPrev.innerHTML = '<img src="../img/pictos/arrows/picto_arrow_previous.gif" alt="previous image" />';
		        aPrev.style.verticalAlign = '-0.5em';

                var popNumPage = navPage.appendChild(document.createElement("span"));
                popNumPage.className = 'noir';
                popNumPage.style.lineHeight = '3em';
                popNumPage.style.verticalAlign = 'middle';

                var aNext = navPage.appendChild(document.createElement("a"));
                aNext.href = "#";
                aNext.innerHTML = '<img src="../img/pictos/arrows/picto_arrow_next.gif" alt="next image" />';
                aNext.style.verticalAlign = '-0.5em';

                popNumPage.innerHTML = 'Image : 1 / '+ numPage;
    		    
	            var i = 1;
	            aPrev.onclick=function() {
					i--;
					if (i < 0 || i == 0) i = numPage;
		            pop.zoomImage.src = navDiaporama.hiddenImgsSrc[i-1];
		            popNumPage.innerHTML = 'Image : '+ i +' / '+numPage;
		            return false;
	            }	
	            aNext.onclick=function() {
		            i++;
		            if (i > numPage && pop.zoomImage.src == navDiaporama.hiddenImgsSrc[numPage-1]) i = 1;
		            pop.zoomImage.src = navDiaporama.hiddenImgsSrc[i-1];
		            popNumPage.innerHTML = 'Image : '+ i +' / '+numPage;
		            return false;
	            }    
	        }
		}
		
		//fin de la gestion des fleches
		
		//if (!navPage) {
		    //la position du popin en haut a gauche de la fenetre du navigateur n'est initialise
		    //qu'a l'ouverture de la popin
			//pop.getPositionFromWindow = navDiaporama.getPositionFromWindow;					
		//}
		
		pop.style.visibility="visible";
		pop.onmousemove=function(){};
		if (pop.zoomImage.complete) {
			pop.zoomImage.onload();
		}
		return pop;
    },
    movePopZoom:function(){
       if (!isNaN(this.x)) this.style.left = this.x+"px";
       if (!isNaN(this.y)) this.style.top = this.y+"px";
       ifrlayer.move(this);
    },
    hidePopZoom:function(e){
        var pop = navDiaporama.popZoom;
        pop.style.visibility="hidden";
        ifrlayer.hide(navDiaporama.popZoom);
    },
    getPositionFromWindow:function(e){
        var doc = (/MSIE 5|Opera/.test(navigator.userAgent)) ? document.body : document.documentElement;  //document.documentElement;
        /*  
        this.x = doc.scrollLeft+parseInt((doc.clientWidth-this.offsetWidth)/2);
        this.y = doc.scrollTop+parseInt((doc.clientHeight-this.offsetHeight)/2)
        if (this.x<0) this.x=0;
        if (this.y<0) this.y=0;
        */
         this.x = doc.scrollLeft;
         this.y = doc.scrollTop;
    },
    makePopZoomDraggable:function(e) {
        getMouse(e);
        this.className+=" dragmode";
        this.mouseOffsetX = window.mouseX-this.offsetLeft;
        this.mouseOffsetY = window.mouseY-this.offsetTop;
        document.onselectstart = function() {return false};
        document.onmousemove = navDiaporama.moveFromMouse;
        this.onmouseup = function() {
            document.onmousemove=function() {}; //retire les fonctionnalite sur le deplacement
            document.onselectstart=function() {};
            this.className = this.className.replace(/dragmode/g,"");
        };
    },
    moveFromMouse:function(e) {
        var doc = document.documentElement;
        var p = navDiaporama.popZoom;
        getMouse(e);
        p.x = window.mouseX-p.mouseOffsetX;
        p.y = window.mouseY-p.mouseOffsetY;
        p.move();
    } 
}

/* Genere un message d'attente avec */
var waitingMsg={
    shadowLayer:null,
    layerId:"waitingMsg",
    defaultTimeout:15000,
    timer:null,
    show:function() {
        var div = document.getElementById(waitingMsg.layerId);
        var doc = /MSIE 5|OPERA/.test(navigator.userAgent) ? document.body : document.documentElement;
        if (!waitingMsg.shadowLayer) {
            var shadow = document.body.appendChild(document.createElement("div"));
            waitingMsg.shadowLayer = shadow;
            shadow.id="shadowLayer";
            with(shadow.style) {
                left=0;
                right=0;
                height=doc.scrollHeight+"px";
            }
        }
        waitingMsg.shadowLayer.style.display="block";
        ifrlayer.make(waitingMsg.shadowLayer);
        if (div) {
            div = document.body.appendChild(div);
            div.style.display="block";    
            ifrlayer.make(div);
            div.style.left = (doc.scrollLeft+parseInt((doc.clientWidth-div.offsetWidth)/2))+"px";
            div.style.top = (doc.scrollTop+parseInt((doc.clientHeight-div.offsetHeight)/2))+"px"
        }
    },
    hide:function() {
        var div = document.getElementById(waitingMsg.layerId);
        waitingMsg.shadowLayer.style.display="none";
        ifrlayer.hide(waitingMsg.shadowLayer);
        div.style.display="none";
        ifrlayer.hide(div);
        clearTimeout(waitingMsg.timer);
    },
    setHideTimer:function(timer) {
        var timeforTimeout = timer || waitingMsg.defaultTimeout;
        if (!waitingMsg.timer) {
            waitingMsg.timer = setTimeout("waitingMsg.hide()",timeforTimeout);
        }
    }
}



var hoverblock = {
    init:function(parentElement) {
        var tmp=null;
        parentElement = typeof(parentElement)=="string" ? document.getElementById(parentElement) : parentElement;
        if (!parentElement) return;
        var table = parentElement.getElementsByTagName("table"); //init Accessories
        for (var i=0; i<table.length;i++) {
	        if (table[i].className.match(/\btbl-accessoires\b/)) {
		        var tds = table[i].getElementsByTagName("td");
		        for (var j=0; j<tds.length;j++) {
			        var td = tds[j];
        			
			        tmp = getElementsByClassName(td,"a", "picture");
			        if (tmp.length>0) {
			            td.eltPictureLink = tmp[0];
			            td.eltPicture = tmp[0].firstChild;
                    }
                    
                    tmp = getElementsByClassName(td, "a", "element");
			        if (tmp.length>0) td.eltTitle = tmp[0];
			        
			        var hblock = getElementsByClassName(td, "div", "hoverBlock");
			        if (hblock.length>0) {td.hoverBlock = hblock[0];}
			        
			        if (td.hoverBlock) {
			            td.eltTitle.AssociatedTd = td;
			            td.eltTitle.onmouseover = hoverblock.over;
				        addEvent(td.eltTitle, "mousemove", hoverblock.move);
				        addEvent(td.eltTitle, "mouseout", hoverblock.close);
				        if (td.eltPictureLink) {
				            td.eltPictureLink.AssociatedTd = td;
				            
				         /* over on the product picture */
                         /*   td.eltPictureLink.onmouseover = hoverblock.over;
                            addEvent(td.eltPictureLink, "mousemove", hoverblock.move);
                            addEvent(td.eltPictureLink, "mouseout", hoverblock.close);
                         */
				        }
			        }
		        }
	        }
        }
    },
    over:function(e) {
        var td = this.AssociatedTd;
        popLayerMakeContent(e, "service", td.hoverBlock);
    },
    move:function(e) {
        popLayerShow(e);
    },
    close:function(e) {
        popLayerClose();
    }
}

var configurator={
    configuratorId:"configurateurAncre",
    scroll:function() {
        var conf = document.getElementById(configurator.configuratorId);
        if (!conf) return;
        var pos = findPos(conf);
        document.documentElement.scrollTop=pos[1]-10;
    }
}

var address={
	addrFind:function(){
        var home = document.getElementById("home"); if (!home) return;
		var lists = getElementsByClassName(home, 'UL', 'addrList');
		if (lists.length == 0){return;}
		for (var i = 0; i < lists.length; i++){
			var currentList = lists[i].childNodes;
			for (var j = 0; j < currentList.length; j++){
				var currentLI = currentList[j];
				if (currentLI.nodeName.toLowerCase()=='li') {
					currentLI.className += ' addrClosed';
					currentLI.onclick= function (e) {
						address.addrPli(this);
					}
					var aElt = ['input','label','a']
					for (var k=0; k < aElt.length; k++){
						var x = currentLI.getElementsByTagName(aElt[k]);
						for (var h = 0; h < x.length; h++) addEvent(x[h],'click',cancelClick, true);
					}
				}
			}
		}
	},
	addrPli:function(currentLI){
		if (currentLI.className.match(/\baddrOpen\b/)){
			currentLI.className = currentLI.className.replace('addrOpen', 'addrClosed');
		} else 	if (currentLI.className.match(/\baddrClosed\b/)){
			currentLI.className = currentLI.className.replace('addrClosed', 'addrOpen');
		}
	}
}

var GoToTabs={
    init:function() {
        var fichearticle = document.getElementById("fichearticle"); if (!fichearticle) return;
        var url = document.location.href;
        var ancre=url.split("#");

        if(ancre.length > 1)
            fnactab.showtab(ancre[1]);
   }
}

/* Fonctions Generiques */
/* global variable to store the name of the element to hide/display  */
var global_element_name = "";
/*
 show_element : display an element
*/
 function show_element(elementName)
 {
    global_element_name = elementName;
    var element = GetElementId(elementName);
    element.style.display = 'block';
 }
 
 /*
    hide_element : hide an element
 */
 function hide_element(elementName)
 {
    global_element_name = "";
    var element = GetElementId(elementName);
    element.style.display = 'none';
 }

/*
    getelementid : shortcut to document.getelementbyid 
*/
 function GetElementId(id)
 {
    return document.getElementById(id);
 } 

/*
    if the global element is visible, move it when the cursor move.
*/
 function OnMoveElement(e)
 {
    if(!e) e=window.event;
    if (global_element_name != "") 
    {  
        if (navigator.appName != "Microsoft Internet Explorer") 
        { 
            GetElementId(global_element_name).style.left = e.pageX + 5 + "px";
            GetElementId(global_element_name).style.top = e.pageY + 10 + "px";
        }
        else 
        { 
            if (document.documentElement.clientWidth > 0) 
            {
                GetElementId(global_element_name).style.left = 20 + e.clientX + document.documentElement.scrollLeft + "px";
                GetElementId(global_element_name).style.top = 10 + e.clientY + document.documentElement.scrollTop + "px";
            } 
            else 
            {
                GetElementId(global_element_name).style.left = 20+ e.clientX + document.body.scrollLeft + "px";
                GetElementId(global_element_name).style.top = 10 + e.clientY + document.body.scrollTop + "px";
            }
        }
    }
}

$(function rollHover(){
	// la nécessité d'avoir une variable globale rhChemin définie dans les pages
	if(typeof(rhChemin) == "undefined" || rhChemin == null) { return; }
	var construction = {
		process : null,
		path:function(file){
			var indice = file.lastIndexOf("/");
			var fichier = file.substring(indice+1);
			if(/on/.test(fichier))
			{
				process = fichier.replace(/on/,"off");
				return process;
			} else if(/off/.test(fichier))
			{
				process = fichier.replace(/off/,"on");
				return process;
			} else { return false; }
		}
	};
	$("a.rHover").mouseover(function(){
		var fichier = $(this).children("img").attr("src");
		if(f = construction.path(fichier))
		{
			$(this).children("img").attr("src",rhChemin+f);
		}
			
	});
	$("a.rHover").mouseout(function(){
		var fichier = $(this).children("img").attr("src");
		if(f = construction.path(fichier))
		{
			$(this).children("img").attr("src",rhChemin+f);
		}
	});
});
/* Fonctions relatives aux fiches Articles (PE/PT)*/
function centerPopin(id) {
	var elem = document.getElementById(id);
	var page = document.getElementsByTagName("BODY");
	var large = (screen.availWidth - elem.offsetWidth) / 2;
	var haut = (screen.availHeight - elem.offsetHeight) / 2;
	elem.style.left = large+"px";
	elem.style.top = haut+"px";
}
function highlightButton(){
    $(document).ready(function(){
	    $("img.rHvr").hover(function(){
		    $(this).css("opacity",0.5);
	    },function(){
		    $(this).css("opacity",1);
	    });

	    /*Plug pour les input hover */
        $("input[type='image'].rHvr").hover(function(){
            //alert("ok");
            $(this).css("opacity","0.5");
        },function(){
            $(this).css("opacity","1");
        });

	    $("a.contextHelp").click(function(){
		    if($("div.aidePopin").css("display") == "none")
		    {
			    var popin = document.createElement("DIV");
			    popin.id = "contextHelp";
			    popin.innerHTML = $("div.aidePopin").html();
			    document.body.appendChild(popin);
			    $(popin).css({position:"absolute",display:"block","z-index":999,width:"300px"});
			    if(IS_IE) { ifrlayer.make($("div#contextHelp")); }
			    centerPopin("contextHelp");
			    $(popin).fadeOut(3000);
		    }
		    return false;
	    });
    });
}
highlightButton();

function adjustCol(){
    $(document).ready(function(){
    // Fonction pour l'alignement en hauteur des guides 
        $(".guides ul li").each(function(e){
            if (e != 0) {
                // Alignement des titres sur 2 lignes
                var hautDT = $(".guides ul li dl dt").eq(e).height(); 
                if (hautDT > $(".guides ul li dl dt").eq(e-1).height()) {
                    $(".guides ul li dl dt").each(function(){
                        $(this).height(hautDT);
                    });
                }
                // Alignement des textes Editoriaux
                var hautP2 = $(".guides ul li dl dd p").eq(e).height(); 
                if (hautP2 > $(".guides ul li dl dd p").eq(e-1).height()) {
                    $(".guides ul li dl dd p").each(function(){
                        $(this).height(hautP2);
                    });
                }    
            } 
        });
    });
}
adjustCol();

// laissez cette fonction en fin de fichier, merci
$(function initpage() {
    navDiaporama.init();
	fnactab.init();
	initProductPage();
	address.addrFind();
	openCloseGroup.init();
});
