// objet    scripts pour récupérer l'état connecté/non connecté de l'utilisateur via le cookie de session - Permet de changer le lien sur la map "retour à l'accueil"
// auteur   M. Claudel
// MAJ      2 juillet 2002


// ouverture d'une fenêtre secondaire
function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
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 gotoindex()
{
    var id = GetCookie('p_id_secure');
    if (id) {
        window.location.href = '/priv_index.php';
    }
    else {
     window.location.href = '/';
    }
}


if (parent.frames.length > 0) {
    if (location.href!= 'http://www.universalis.fr/') {
        window.top.location.href = location.href;
    }
}



    

//*****************************************************************************
// Do not remove this notice.
//
// Copyright 2001 by Mike Hall.
// See http://www.brainjar.com for terms of use.
//*****************************************************************************

// Determine browser and version.

function Browser() {

  var ua, s, i;

  this.isIE    = false;
  this.isNS    = false;
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

var browser = new Browser();

// Global object to hold drag information.

var dragObj = new Object();
dragObj.zIndex = 0;

function dragStart(event, id) {

  var el;
  var x, y;

  // If an element id was given, find it. Otherwise use the element being
  // clicked on.

  if (id)
    dragObj.elNode = document.getElementById(id);
  else {
    if (browser.isIE)
      dragObj.elNode = window.event.srcElement;
    if (browser.isNS)
      dragObj.elNode = event.target;

    // If this is a text node, use its parent element.

    if (dragObj.elNode.nodeType == 3)
      dragObj.elNode = dragObj.elNode.parentNode;
  }

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Save starting positions of cursor and element.

  dragObj.cursorStartX = x;
  dragObj.cursorStartY = y;
  dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left, 10);
  dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,  10);

  if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
  if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = 0;

  // Update element's z-index.

  dragObj.elNode.style.zIndex = ++dragObj.zIndex;

  // Capture mousemove and mouseup events on the page.

  if (browser.isIE) {
    document.attachEvent("onmousemove", dragGo);
    document.attachEvent("onmouseup",   dragStop);
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS) {
    document.addEventListener("mousemove", dragGo,   true);
    document.addEventListener("mouseup",   dragStop, true);
    event.preventDefault();
  }
}

function dragGo(event) {

  var x, y;

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Move drag element by the same amount the cursor has moved.

  dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
  dragObj.elNode.style.top  = (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";

  if (browser.isIE) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS)
    event.preventDefault();
}

function dragStop(event) {

  // Stop capturing mousemove and mouseup events.

  if (browser.isIE) {
    document.detachEvent("onmousemove", dragGo);
    document.detachEvent("onmouseup",   dragStop);
  }
  if (browser.isNS) {
    document.removeEventListener("mousemove", dragGo,   true);
    document.removeEventListener("mouseup",   dragStop, true);
  }
}



/*****************************************************************************/
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
function popUp(strURL,strType,strHeight,strWidth) {
var strOptions="";
if (strType=="console") strOptions="resizable,height="+strHeight+",width="+strWidth;
if (strType=="fixed") strOptions="status,height="+strHeight+",width="+strWidth;
if (strType=="elastic") strOptions="toolbar,menubar,scrollbars,resizable,location,height="+strHeight+",width="+strWidth;
window.open(strURL, 'newWin', strOptions);
}
/*****************************************************************************/

// les active ou pas ... onglets
var onglets = new Array();
function initOnglet(id)
{
    onglets[id] = 1;
}
function activeOnglet(id)
{
    for (i in onglets)
    {
        setModeOnglet(i,"");
    }
    setModeOnglet(id,"active");
}
function setModeOnglet(id,mode)
{
    if (document.getElementById) {
      document.getElementById(id).className=mode;
    } else if (document.all) {
      document.all[id].style.className=mode;
    } else if (document.layers) {
      document.layers[id].className=mode;
    }
}
function switchonglet2(id,id2)
{
    activeOnglet(id2);
    var d = document.getElementById(id);
    for (var i = 1; i<=10; i++) {
        if (document.getElementById('onglet'+i)) {document.getElementById('onglet'+i).style.display='none';}
    }
    if (d) {d.style.display='block';}
}




// montrer un cacher les autres

function switchonglet(id) {
var d = document.getElementById(id);
    for (var i = 1; i<=10; i++) {
        if (document.getElementById('onglet'+i)) {document.getElementById('onglet'+i).style.display='none';}
    }
if (d) {d.style.display='block';}
}
// montrer un cacher les autres

function montre2(id) {
var d = document.getElementById(id);
    for (var i = 1; i<=12; i++) {
        if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
    }
if (d) {d.style.display='block';}
}

// fonctions pour redimentionner des div via leur ID
function augmente(id,noCookie) {
    if (!noCookie)
        PutCookies('View'+id,'o');
  if (document.getElementById) {
        if (document.getElementById(id))
            document.getElementById(id).style.height="200px";
    } else if (document.all) {
            if (document.all[id])
            document.all[id].style.height="200px";
    } else if (document.layers) {
        if (document.layers[id])
          document.layers[id].height="200px";
    } }

function reduit(id,noCookie) {
    if (!noCookie)
        PutCookies('View'+id,'o');
  if (document.getElementById) {
        if (document.getElementById(id))
            document.getElementById(id).style.height="140px";
    } else if (document.all) {
            if (document.all[id])
            document.all[id].style.height="140px";
    } else if (document.layers) {
        if (document.layers[id])
          document.layers[id].height="140px";
    } }


// function pour monter et cacher des div via leur ID
function montre(id,noCookie) {
    if (!noCookie)
        PutCookies('View'+id,'o');
  if (document.getElementById) {
        if (document.getElementById(id))
            document.getElementById(id).style.display="block";
    } else if (document.all) {
            if (document.all[id])
            document.all[id].style.display="block";
    } else if (document.layers) {
        if (document.layers[id])
          document.layers[id].display="block";
    } }

function cache(id,noCookie) {
    if (!noCookie)
       PutCookies('View'+id,'c');

  if (document.getElementById) {
        if (document.getElementById(id))
          document.getElementById(id).style.display="none";
    } else if (document.all) {
        if (document.all[id])
            document.all[id].style.display="none";
    } else if (document.layers) {
        if (document.layers[id])
          document.layers[id].display="none";
    } }

var DaysToLive = 1;
ViewBox = new Array();

function InitView2(id,def)
{
    var test =  GetCookies('View'+id);

    ViewBox[id] = def;

    if (test == 'c')
        ViewBox[id] = 1;
    if (test == 'o')
        ViewBox[id] = 0;


    switchBox(id,1)
}
function InitView(id)
{
    var test =  GetCookies('View'+id);

    ViewBox[id] = 0;

    if (test == 'c')
        ViewBox[id] = 1;
    if (test == 'o')
        ViewBox[id] = 0;


    switchBox(id,1)
}
ViewBoxPrint = new Array();
function InitViewPrint(id)
{
    var test =  GetCookies('View'+id);

    ViewBoxPrint[id] = 0;

    if (test == 'c')
        ViewBoxPrint[id] = 1;
    if (test == 'o')
        ViewBoxPrint[id] = 0;


    switchBoxPrint(id,1)
}
function PutCookies(n,v)
{
    var exp = '';
    if(DaysToLive > 0)
    {
        var now = new Date();
        then = now.getTime() + (DaysToLive * 24 * 60 * 60 * 1000);
        now.setTime(then);
        exp = '; expires=' +
        now.toGMTString();
    }
    document.cookie = n + "=" + v + '; path=/' + exp;
}
function GetCookies(Name)
{
    var s = '; '+document.cookie+';';
    var i = s.indexOf('; '+Name+'=');
    if (i == -1) {
        return '';
    }
    else
    {
        i += 3 + Name.length;
        var j = s.indexOf(';', i);
        return unescape(s.substring(i, j));
    }
}
function switchBox(id,c)
{
    if (ViewBox[id])
    {
        cache(id,c);
        ViewBox[id] = 0;
    }
    else
    {
        montre(id,c);
        ViewBox[id] = 1;
    }
}
// pour l'impression d'un article
function switchBoxPrint(id,c)
{
    if (ViewBoxPrint[id])
    {
        unCheckBox(id);
        ViewBoxPrint[id] = 0;
    }
    else
    {
        CheckBox(id);
        ViewBoxPrint[id] = 1;
    }
}
// function pour cocher  les checkbox
function CheckBox(id) {
  if (document.getElementById) {
        if (document.getElementById('check'+id))
            document.getElementById('check'+id).checked=true;
    } else if (document.all) {
            if (document.all['check'+id])
            document.all['check'+id].checked = true;
    } else if (document.layers) {
        if (document.layers['check'+id])
          document.layers['check'+id].checked = true;
    }
}
// function pour  décocher les checkbox
function unCheckBox(id) {
  if (document.getElementById) {
        if (document.getElementById('check'+id))
            document.getElementById('check'+id).checked= false;
    } else if (document.all) {
            if (document.all['check'+id])
            document.all['check'+id].checked = false;
    } else if (document.layers) {
        if (document.layers['check'+id])
          document.layers['check'+id].checked = false;
    }
}

// pose le cookie par défaut pour le menu choisi
function defautMenuSelected(value, tabMenu)
{
    var info = GetCookies('Selectmenu');

    // cas du mode simple / expert
    if(value=='simple' )
    {
        var simplex = GetCookies('Viewexpert');
        if(simplex != 'o')
            PutCookies('Selectmenu',value);
    }
    else
        PutCookies('Selectmenu',value);

    verifSelected(tabMenu);
}

// pose le cookie pour le menu choisi
function menuSelected(value)
{
    PutCookies('Selectmenu',value);
}

// Pour vérifier quel est le mode à sélectionner dans le menu
function verifSelected(tabMenu)
{
    var taille = tabMenu.length;
    var info ="vide";

    for (var i = 0; i<taille; i++)
    {
        info = GetCookies('Selectmenu');

        // on sélectionne
        if(info == tabMenu[i][0])
        {
          if (document.getElementById) {
                if (document.getElementById(tabMenu[i][1]))
                  document.getElementById(tabMenu[i][1]).className="activelink";
            } else if (document.all) {
                if (document.all[tabMenu[i][1]])
                    document.all[tabMenu[i][1]].className="activelink";
            } else if (document.layers) {
                if (document.layers[tabMenu[i][1]])
                  document.layers[tabMenu[i][1]].className="activelink";
            }
        }
        else
        {
          if (document.getElementById) {
                if (document.getElementById(tabMenu[i][1]))
                  document.getElementById(tabMenu[i][1]).className="none";
            } else if (document.all) {
                if (document.all[tabMenu[i][1]])
                    document.all[tabMenu[i][1]].className="none";
            } else if (document.layers) {
                if (document.layers[tabMenu[i][1]])
                  document.layers[tabMenu[i][1]].className="none";
            }
        }
        info = "";
    }
}

