
    /* 2 fonctions qui marchent pour IE et FireFox pour aider à positionner au centre */
    /* Tout ca parce que IE ne prend pas l'attribut CSS 'position : fixed' fonctionnant sous firefox, évidemment */
    function getWindowHeight() {
     var windowHeight = 0;
       if (typeof(window.innerHeight) == 'number') { windowHeight = window.innerHeight; }
        else {
          if (document.body && document.body.clientHeight) { windowHeight = document.body.clientHeight; }
        else {
          if (document.documentElement && document.documentElement.clientHeight) {
            windowHeight = document.documentElement.clientHeight;
          }
        }
       }
     return windowHeight;
    }

    function getWindowWidth() {
     var windowWidth = 0;
       if (typeof(window.innerWidth) == 'number') { windowWidth = window.innerWidth; }
            else {
              if (document.body && document.body.clientWidth) {  windowWidth = document.body.clientWidth; }
            else {
              if (document.documentElement && document.documentElement.clientWidth) {
                windowWidth = document.documentElement.clientWidth;
              }
            }
       }
     return windowWidth;
    }


    function fade_in(id,op,max) {
      if (element = document.getElementById(id)) {
          if (op>max) op=max;
          if (navigator.appName == "Microsoft Internet Explorer")
            element.style.filter = "alpha(opacity=" + op + ")";
          else {
            element.style.opacity = (op / 100);
            element.style.MozOpacity = (op / 100);
          }
          if (op<max) setTimeout('fade_in("'+id+'",'+(op+10)+','+max+');',55);
          if (op==0) element.style.visibility = "visible";
      }
    }

    function fade_out(id,op,min) {
      if (element = document.getElementById(id)) {
          if (op<min) op=min;
          if (navigator.appName == "Microsoft Internet Explorer")
            element.style.filter = "alpha(opacity="+op+")";
          else {
            element.style.opacity = (op / 100);
            element.style.MozOpacity = (op / 100);
          }
          if (op>min) setTimeout('fade_out("'+id+'",'+(op-20)+','+min+');',55);
          if (op==0) element.style.visibility = "hidden";
      }
    }

    function sz_CentrerElement(element) {
        var h = getWindowHeight();
        var w = getWindowWidth();
        if (element.scrollHeight < h)
            element.style.top = (document.body.scrollTop + Math.ceil((h-element.scrollHeight)/3))+"px";
        else
            element.style.top = document.body.scrollTop+'px';

        if (element.scrollWidth < w)
            element.style.left = (document.body.scrollLeft + Math.ceil((w-element.scrollWidth)/2))+"px";
        else
            element.style.left = document.body.scrollLeft+'px';

        
        if (h < 700) h = 700;
        if (w < 1000) w = 1000;
        
        filtre = document.getElementById('sz_filtre_bg');
        filtre.style.height = h+"px";
        filtre.style.width = w+"px";
        filtre.style.top = document.body.scrollTop+'px';
        filtre.style.left = document.body.scrollLeft+'px';
        
        window.onresize = function() {
            var h = getWindowHeight();
            var w = getWindowWidth();
            if (element.scrollHeight < h)
                element.style.top = (document.body.scrollTop + Math.ceil((h-element.scrollHeight)/3))+"px";
            else
                element.style.top = document.body.scrollTop+'px';

            if (element.scrollWidth < w)
                element.style.left = (document.body.scrollLeft + Math.ceil((w-element.scrollWidth)/2))+"px";
            else
                element.style.left = document.body.scrollLeft+'px';

            
            if (h < 700) h = 700;
            if (w < 1000) w = 1000;

            filtre = document.getElementById('sz_filtre_bg');
            filtre.style.height = h+"px";
            filtre.style.width = w+"px";
            filtre.style.top = document.body.scrollTop+'px';
            filtre.style.left = document.body.scrollLeft+'px';

        };
    }
    
    function balise(id,balisedebut,balisefin){
        var texte = document.getElementById(id);
        if (document.selection) { /*IE*/
            texte.focus();
            sel = document.selection.createRange();
            sel.text = balisedebut+(sel.text)+balisefin;
        }
        else if (texte.selectionStart || texte.selectionStart == '0') { /* autres navigateurs */

            var startPos = texte.selectionStart;
            var endPos = texte.selectionEnd;
            var texteSelection = texte.value.substring(startPos, endPos);
            texte.value = texte.value.substring(0, startPos)+ balisedebut + texteSelection + balisefin + texte.value.substring(endPos, texte.value.length);
        }
        else {
            texte.value = balisedebut+balisefin;
        }
    }


