function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function Is() {
    var agent = navigator.userAgent.toLowerCase();
    this.major = parseInt(navigator.appVersion);
    this.minor = parseFloat(navigator.appVersion);
    this.ns  = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1)));
    this.ns2 = (this.ns && (this.major == 2));
    this.ns3 = (this.ns && (this.major == 3));
    this.ns4b = (this.ns && (this.minor < 4.04));
    this.ns4 = (this.ns && (this.major >= 4));
    this.ie   = (agent.indexOf("msie") != -1);
    this.ie3  = (this.ie && (this.major == 2));
    this.ie4  = (this.ie && (this.major >= 4));
    this.op3 = (agent.indexOf("opera") != -1);
    this.win   = (agent.indexOf("win")!=-1);
    this.mac   = (agent.indexOf("mac")!=-1);
    this.unix  = (agent.indexOf("x11")!=-1);
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function montre(id)
{
    var d = document.getElementById(id);
    for (var i = 0; i<=10; i++)
    {
        if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
        if (document.getElementById('smenug'+i)) {document.getElementById('smenug'+i).style.display='none';}
    }
    if (d) {d.style.display='block';}
}

function PrintThisPage(app)
{
   var sOption="toolbar=no,location=no,directories=no,menubar=no,";
       sOption+="scrollbars=no,width=520,height=400,left=0,top=0";

   var sWinHTML = document.getElementById('contentstart').innerHTML;

   var winprint=window.open("","",sOption);
       winprint.document.open();
       winprint.document.write('<html><SCRIPT LANGUAGE="JavaScript">function NoError(){return true;}');
       winprint.document.write('window.onerror=NoError;');
       winprint.document.write('function Imprimer(){ window.print(); window.close();}');
       winprint.document.write('</SCRIPT><link href="/impact/style/steelblue/style.css" rel="stylesheet" type="text/css">');
       winprint.document.write('<body onload="Imprimer();" leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0">');
       winprint.document.write(sWinHTML);
       winprint.document.write('<script></script></body></html>');
       winprint.document.close();
       winprint.focus();
}

// Fonction de popup image qui se resize automatiquement

function autoSize()
{
    if (IE5) self.resizeTo(document.images[0].width+10,document.images[0].height+31);
    else if (NN6) self.sizeToContent();
    else window.resizeTo(document.images[0].width,document.images[0].height+20);
    self.focus();
}

function goURL(url, view)
{
    document.globalForm.action = view;
    document.globalForm.externalLink.value = url;
    document.globalForm.target = "_blank";
    document.globalForm.submit();
}

function resizePopUp(monImage)
{
    w = window.open('','chargement','width=10,height=10');
    w.document.write( "<html><head><title></title>\n" );
    w.document.write( "<script type='text/javascript'>\n");
    w.document.write( "IE5=NN4=NN6=false;\n");
    w.document.write( "if(document.all)IE5=true;\n");
    w.document.write( "else if(document.getElementById)NN6=true;\n");
    w.document.write( "else if(document.layers)NN4=true;\n");
    w.document.write( "function autoSize() {\n");
    w.document.write( "if(IE5) self.resizeTo(document.images[0].width+10,document.images[0].height+31)\n");
    w.document.write( "else if(NN6) self.sizeToContent();\n");
    w.document.write( "else window.resizeTo(document.images[0].width,document.images[0].height+20)\n");
    w.document.write( "self.focus();\n");
    w.document.write( "}\n</scri");
    w.document.write( "pt>\n");
    w.document.write( "</head><body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 onLoad='javascript:autoSize();'>" );
    w.document.write( "<a href='javascript:window.close();'><img src='"+monImage+"' border=0></a>" );
    w.document.write( "</body></html>" );
    w.document.close();
}

/* Utilis pour la popup des mentions lgales */
function openWin(url)
{
    window.open(url, 'le', 'menubars=no, width=400, height=300, scrollbars=yes');
}

function printContent(node, doc, params)
{
	printContent(node, doc, params, '');
}

function printContent(node, doc, params, inner)
{
    var sOption="resizable=1,menubar=1,scrollbars=1"; 
    //var url = '../global/printContent?idCont='+idContent
    var url = '../global/printContent?node='+node;
    if(doc != '')
    {
        url += '&doc='+doc;
    }
    if(params != '')
    {
        url += '&pubparams.sform='+params;
    }
    var winContent=window.open(url,"printContent",sOption);
}



function sendContent(appliCode)
{
    var winContent;
    var urlToReach = document.location.href;
    var url = '../global/sendContent?appliCode='+appliCode+'&urlToSend='+urlToReach
    winContent=window.open(url,"sendContent","width=500,height=500,scrollbars=1");
}

function SortSelect(obj)
{
    var dico = new Array();
    var list = new Array();

    for( var i = 0; i < obj.length ; i ++ )
    {
        dico[obj[i].text] = obj[i].value;
        list[i] = obj[i].text;
    }

    list.sort();

    for( var i = 0; i < list.length ; i ++ )
    {
        obj[i].text = list[i];
        obj[i].value = dico[list[i]];
    }
}

function rand_number(n)
{
    var x;
    x=Math.round(Math.random()*100);
    x%=n;
    return x;
}

sfHover = function()
{
    var sfEls = document.getElementById("nav").getElementsByTagName("LI");
    for (var i=0; i<sfEls.length; i++) {
        sfEls[i].onmouseover=function() {
            this.className+=" sfhover";
        }
        sfEls[i].onmouseout=function() {
            this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
        }
    }
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

function home_ref() {
    if (document.getElementById('h1_footer')) {document.getElementById('h1_footer').className='h1_footer';}
}

// Heinle's function for retrieving a cookie.
function getCookie(name){
  var cname = name + "=";
  var dc = document.cookie;
  if (dc.length > 0) {
    begin = dc.indexOf(cname);
    if (begin != -1) {
      begin += cname.length;
      end = dc.indexOf(";", begin);
      if (end == -1) end = dc.length;
        return unescape(dc.substring(begin, end));
    }
  }
  return null;
}

// An adaptation of Dorcht's function for setting a cookie.
function setCookie(name, value, expires, path, domain, secure) {
  document.cookie = name + "=" + escape(value) +
  ((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
  ((path == null) ? "" : "; path=" + path) +
  ((domain == null) ? "" : "; domain=" + domain) +
  ((secure == null) ? "" : "; secure");
}

// An adaptation of Dorcht's function for deleting a cookie.
function delCookie (name,path,domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
    ((path == null) ? "" : "; path=" + path) +
    ((domain == null) ? "" : "; domain=" + domain) +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";

    location.reload(true);
  }
}

var firstCall = true;
var totalIncrement = 0;
var out = "";

/**
 * Permet de modifier la taille de la police dans tous les sous éléments de l'élément rootNode.
 * Cette fonction est utilisée sur tous les sites bioMérieux sauf le site US.
 */
function changeFontsize(rootNode, fSize, increment) {
    if (firstCall) {
        firstCall = false;
        if (increment != "") {
            var initfSize = '11';
            changeFontsize(rootNode, initfSize, '');
        }
    }

    if (getCookie('totalIncrement'))
    {
        totalIncrement = parseInt(getCookie('totalIncrement'));
    }

    if (increment != "")
    {
        totalIncrement += parseInt(increment);
    }

    if (totalIncrement >= 6)
    {
        document.getElementById('police_moins').style.display='block';
        document.getElementById('police_plus').style.display='none';
    }
    else if (totalIncrement <= -4)
    {
        document.getElementById('police_moins').style.display='none';
        document.getElementById('police_plus').style.display='block';
    }
    else
    {
        document.getElementById('police_moins').style.display='block';
        document.getElementById('police_plus').style.display='block';
    }

    if (((increment != "" && totalIncrement >= -4 && totalIncrement <= 6) || fSize != "") && document.getElementsByTagName) {
        var tags = new Array();
        var parentNode = document.getElementById(rootNode);
        if (parentNode != null)
        {
            getAllElements(parentNode, tags);
        }
        else
        {
            alert("Erreur : impossible de récupérer l'élément ayant l'identifiant suivant : " + rootNode);
        }

        for (i=0; i<tags.length; i++) {
            var element, elementName, currentFontSize, fontIncrease, newFontSize;

            element = tags[i];
            elementName = element.nodeName.toLowerCase();

            if (increment != "") {
                currentFontSize = parseInt(element.style.fontSize);
                fontIncrease = parseInt(increment);
                newFontSize = currentFontSize + fontIncrease;
            }
            else if (fSize != "") {
                newFontSize = parseInt(fSize);
            }

            if (fSize != "") {
                switch(elementName) {
                    case "h1": newFontSize += 9; break;
                    case "h2": newFontSize += 5; break;
                    case "h3": newFontSize += 2; break;
                    case "h4": newFontSize += 1; break;
                    case "h5": newFontSize += 1; break;
                    case "h6": newFontSize += 1;
                }
            }
            element.style.fontSize = newFontSize + "px";
            setCookie('fontSize', newFontSize);
            setCookie('totalIncrement', totalIncrement);
        }
    }
}

function initChangeFontSize(rootNode) {
    if (rootNode == null) {
        alert("Erreur : impossible d'initialiser la fonctionnalité pour changer la taille de la police.");
    }
    else {
        if (getCookie('fontSize')) {
            changeFontsize(rootNode, getCookie('fontSize'), '');
        }

        if (!getCookie('totalIncrement')) {
            document.getElementById('police_moins').style.display='block';
            document.getElementById('police_plus').style.display='block';
        }
    }
}

/**
 * Permet de modifier la taille de la police dans tous les sous éléments de l'élément rootNode.
 * Cette fonction est utilisée uniquement sur le site bioMérieux US.
 */
function changeFontsizeUS(rootNode, fSize, increment) {
    if (firstCall) {
        firstCall = false;
        if (increment != "") {
            var initfSize = '12';
            changeFontsizeUS(rootNode, initfSize, '');
        }
    }

    if (getCookie('totalIncrement'))
    {
        totalIncrement = parseInt(getCookie('totalIncrement'));
    }

    if (increment != "")
    {
        totalIncrement += parseInt(increment);
    }

    if (totalIncrement >= 6)
    {
        document.getElementById('police_moins').style.display='block';
        document.getElementById('police_plus').style.display='none';
    }
    else if (totalIncrement <= -4)
    {
        document.getElementById('police_moins').style.display='none';
        document.getElementById('police_plus').style.display='block';
    }
    else
    {
        document.getElementById('police_moins').style.display='block';
        document.getElementById('police_plus').style.display='block';
    }

    if (((increment != "" && totalIncrement >= -4 && totalIncrement <= 6) || fSize != "") && document.getElementsByTagName) {
        var tags = new Array();
        var parentNode = document.getElementById(rootNode);
        if (parentNode != null)
        {
            getAllElements(parentNode, tags);
        }
        else
        {
            alert("Erreur : impossible de récupérer l'élément ayant l'identifiant suivant : " + rootNode);
        }

        for (i=0; i<tags.length; i++) {
            var element, elementName, currentFontSize, fontIncrease, newFontSize;

            element = tags[i];
            elementName = element.nodeName.toLowerCase();

            if (increment != "") {
                currentFontSize = parseInt(element.style.fontSize);
                fontIncrease = parseInt(increment);
                newFontSize = currentFontSize + fontIncrease;
            }
            else if (fSize != "") {
                newFontSize = parseInt(fSize);
            }

            if (fSize != "") {
                switch(elementName) {
                    case "h1": newFontSize += 2; break;
                    case "h2": newFontSize += 2; break;
                    case "h3": newFontSize += 2; break;
                    case "h4": newFontSize += 1; break;
                    case "h5": newFontSize += 1; break;
                    case "h6": newFontSize += 1;
                }
            }
            element.style.fontSize = newFontSize + "px";
            setCookie('fontSize', newFontSize);
            setCookie('totalIncrement', totalIncrement);
        }
    }
}

function initChangeFontSizeUS(rootNode) {
    if (rootNode == null) {
        alert("Erreur : impossible d'initialiser la fonctionnalité pour changer la taille de la police.");
    }
    else {
        if (getCookie('fontSize')) {
            changeFontsizeUS(rootNode, getCookie('fontSize'), '');
        }

        if (!getCookie('totalIncrement')) {
            document.getElementById('police_moins').style.display='block';
            document.getElementById('police_plus').style.display='block';
        }
    }
}

/**
 * récupère tous les elements de type 1 (balise HTML)  pour un noeud donné
 */
function getAllElements(node, elementsArray) {
    var childrenNumber = node.childNodes.length;

    for (var i = 0; i < childrenNumber; i++) {
        var element = node.childNodes[i];
        var elementName = element.nodeName.toLowerCase();

        if (element.nodeType == 1) {
            elementsArray[elementsArray.length] = element;
        }

        getAllElements(element, elementsArray);
    }
}