var G_arrayImgs = new Array();
var G_arrayDivContenus = new Array();
var G_currentOnglet = "";
var G_nextContenu = new Array();
G_nextContenu ['financer-circuit'] = 'nous';
G_nextContenu ['nous'] = 'donner';
G_nextContenu ['donner'] = 'exploiter';
G_nextContenu ['exploiter'] = 'polluer';
G_nextContenu ['polluer'] = 'biens';
G_nextContenu ['biens'] = 'ethique';
G_nextContenu ['ethique'] = 'nous';

// alert("on reprend dans une heure ou deux ?");

function show (rubrique) {
  if(document.getElementById( rubrique ))
    document.getElementById( rubrique ).style.visibility ="visible";
}
function unShow (rubrique) {
  if(document.getElementById( rubrique ))
    document.getElementById( rubrique ).style.visibility ="hidden";
}
function emphasing (s_rubrique) {
    if(s_rubrique != G_currentOnglet && G_currentOnglet=="") {
        document.images[s_rubrique].src = G_arrayImgs['over'+ s_rubrique].src;
        document.getElementById( 'id-'+ s_rubrique ).style.zIndex = 100;
    }
}
function unEmphasing (s_rubrique) {
  if(s_rubrique != G_currentOnglet) {
    document.images[s_rubrique].src = G_arrayImgs['lien'+ s_rubrique].src;
    document.getElementById( 'id-'+ s_rubrique ).style.zIndex = 0;
  }
}
function showSelectedItem (s_rubrique) {
    unShow('id-'+ s_rubrique);
    document.images[s_rubrique].src = G_arrayImgs['over'+ s_rubrique].src;
    show('id-'+ s_rubrique);
    //document.images[s_rubrique].focus(false);
}
function showContenu ( s_name ) {

  unShowContenu();
  G_currentOnglet = s_name;
  show('id-fond-cont-'+ s_name);
  show('id-close-contenu');
  show('id-next-contenu');
  showSelectedItem(s_name);
}

function unShowContenu ( ) {

  G_currentOnglet = "";

  for (var i_divId in G_arrayDivContenus) {
    unEmphasing(G_arrayDivContenus[i_divId]);
    unShow ('id-fond-cont-'+ G_arrayDivContenus[i_divId]);
  }
  unShow('id-close-contenu');
  unShow('id-next-contenu');
}

function nextContenu() {
   showContenu(G_nextContenu[G_currentOnglet]);
}

function writeLink ( s_name, s_posX, s_posY, s_url) {
  
  var imgLien = new Image (); imgLien.src ='imgs/lien'+ s_name +'.jpg' ;
  var imgOver = new Image (); imgOver.src ='imgs/over'+ s_name +'.jpg' ;
  G_arrayImgs['lien'+ s_name] = imgLien;
  G_arrayImgs['over'+ s_name] = imgOver;
  
  document.write('<div id="id-'+ s_name +'" style="position:absolute; top:'+ s_posY +'px; left:'+ s_posX +'px;">');
  if (!s_url)
    s_url = s_name + '/index.html';
  document.write('<a href="'+ s_url +'" onmouseover="emphasing(\''+ s_name +'\');" onmouseout="unEmphasing(\''+ s_name +'\');" border="0px" >');
  document.write('  <img name="'+ s_name +'" src="'+ imgLien.src +'" border="0px" />');
  document.write('</a>');
  document.write('</div>');
}
/**
  * writeLinkOnglet
  * Ecrit un lien qui une fois clicked affichera le div d'id id-cont-s_name
  **/
function writeLinkOnglet ( s_name, s_posX, s_posY ) {

  var imgLien     = new Image (); imgLien.src     ='imgs/lien'+ s_name +'.jpg' ;
  var imgOver     = new Image (); imgOver.src     ='imgs/over'+ s_name +'.jpg' ;
  var imgSelected = new Image (); imgSelected.src ='imgs/selected'+ s_name +'.jpg' ;
  G_arrayImgs['lien'+ s_name] = imgLien;
  G_arrayImgs['over'+ s_name] = imgOver;
  G_arrayImgs['selected'+ s_name] = imgSelected;

  G_arrayDivContenus[G_arrayDivContenus.length] = s_name;

  document.write('<div id="id-'+ s_name +'" style="position:absolute; top:'+ s_posY +'px; left:'+ s_posX +'px;">');
  document.write('<a href="javascript:showContenu(\''+ s_name +'\');" onmouseover="emphasing(\''+ s_name +'\');" onmouseout="unEmphasing(\''+ s_name +'\');" border="0px" >');
  document.write('  <img name="'+ s_name +'" src="'+ imgLien.src +'" border="0px" />');
  document.write('</a>');
  document.write('</div>');
}

/**
  * writeContBackground
  * Ecrit le fond du nom fond-s_name.jpg qui s'affichera aussi 
  **/
function writeContBackground ( s_name, s_posX, s_posY) {

  /** fond **/
  document.write('<div id="id-fond-cont-'+s_name+'" class="fond-contenu" style="top:'+ s_posY +'px; left:'+ s_posX+'px;">');
  document.write('  <img src="imgs/fond-cont-'+s_name+'.jpg" border="0" />');
  document.write('</div>');

}

/**
  * writeContOver
  * Ecrit le fond du nom fond-s_name.jpg qui s'affichera aussi 
  **/
function writeContOver ( s_name, s_posX, s_posY) {

  /** fond **/
  document.write('<div id="id-fond-cont-'+s_name+'" class="fond-contenu" style="top:'+ s_posY +'px; left:'+ s_posX+'px;">');
  document.write('  <img src="imgs/fond-cont-'+s_name+'.jpg" border="0" />');
  document.write('  <div style="position:absolute; top:50px; left:60px;">');
  document.write('    <a href="#" onmouseout="unShow(\'id-fond-cont-'+ s_name +'\');">');
  document.write('      <img src="imgs/transparent.gif" width="250" height="250" border="0" />');
  document.write('    </a>');
  document.write('  </div>');
  document.write('</div>');

}

function writeLinkOn ( s_name, s_posX, s_posY) {

  var imgLien = new Image (); imgLien.src ='imgs/lien'+ s_name +'.jpg';
  var imgOver = new Image (); imgOver.src ='imgs/over'+ s_name +'.jpg' ;
  G_arrayImgs['lien'+ s_name] = imgLien;
  G_arrayImgs['over'+ s_name] = imgOver;
  
  document.write('<div style="position:absolute; top:'+ s_posY +'px; left:'+ s_posX +'px;">');
  document.write('<a href="#" onmouseover="show(\'id-'+ s_name +'\'); emphasing(\''+ s_name +'\');" onmouseout="unShow(\'id-'+ s_name +'\'); unEmphasing(\''+ s_name +'\');">');
  document.write('  <img alt="" name="'+ s_name +'" src="imgs/lien'+ s_name +'.jpg" border="0px" />');
  document.write('</a>');
  document.write('</div>');
}

function writeLinkOnSpecialOver ( s_name, s_posX, s_posY) {

  document.write('<div style="position:absolute; top:'+ s_posY +'px; left:'+ s_posX +'px;">');
  document.write('<a href="#" onmouseover="show(\'id-fond-cont-'+ s_name +'\');">');
  document.write('  <img alt="" name="'+ s_name +'" src="imgs/lien'+ s_name +'.jpg" border="0px" />');
  document.write('</a>');
  document.write('</div>');
}

function popup(p_mypage, p_w, p_h, p_scroll) {
  var winl = (screen.width - p_w) / 2;
  var wint = (screen.height - p_h) / 2;
  if(!p_scroll)
    p_scroll = "auto";
  winprops = "height="+ p_h +",width="+ p_w +",top="+ wint +",left="+ winl +",scrollbars=auto,resizable";
  win = window.open(p_mypage, p_mypage, winprops);
  if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function init_showEnter () {
//     alert("prout");
    // DETERMINAISON DU LIEU INITIAL DU BONHOMME
    var URL = self.location.href;
    var theFirstTimeOnPage = (URL.lastIndexOf("?") <= -1);
    if(theFirstTimeOnPage){
        window.clearInterval(interval);
        if(document.getElementById( 'chargement' )) {
            document.getElementById( 'chargement' ).innerHTML = 'Page chargée ---&gt; <a class="entrer" href="javascript:unShow(\'id-chargement\');">ENTRER</a>';
        }
    }
    else {
        unShow('id-chargement');
    }
  //window.setTimeout("unShow('id-chargement');",500);
//  unShow('id-chargement');
}
function init () {
    unShow('id-chargement');
}
