// +----------------------------------------------+
// | Ouverture et fermeture de Pop-up             |
// +----------------------------------------------+
function ouvre_fen(nom,titre,l,h,s)
{
  var fen,param,largeur,hauteur;
  largeur=l;
  hauteur=h;
  pos_larg=((eval(screen.width)-largeur)/2)-5;
  pos_haut=((eval(screen.height)-hauteur)/2)-35;
  param = "scrollbars="+s+",resizable=no,status=no,location=no,toolbar=no,menubar=no,width="+largeur+",height="+hauteur+",left="+pos_larg+",top="+pos_haut;
  fen = window.open(nom,titre,param);fen.focus();
}

function ferme_fen()
{
  self.close();
}

// +----------------------------------------------+
// | Affichage d'un texte défil. en barre d'etat  |
// +----------------------------------------------+
function afficherinfo (Sortie)
{
  window.status = Sortie;
}

msg = new Array ();
msg [0] = "Orion Etudes"
msg [1] = "Etudes, calculs, maîtrise d'oeuvre, suivi de projet";
msg [2] = "Notre satisfaction quotidienne est de mettre notre expérience à votre service";
msg [3] = "E-mail : contact@orion-etudes.com";

j = 0;
i = 0;

function afficher()
{
  afficherinfo (msg [j].substring (0, i) + "_");
  i ++;
  if (i <= msg [j].length)
  {
    setTimeout ("afficher ();", 50);
  }
  else
  {
    i = 0;
    j ++;
    if (j == msg.length)
      j = 0;
    setTimeout ("afficher ();", 2000);
  }
}

// +----------------------------------------------+
// | Ajouter le site aux favoris                  |
// +----------------------------------------------+
function ajfav()
{
	if (navigator.appName != 'Microsoft Internet Explorer')
	{ 
		window.sidebar.addPanel("Orion Etudes - Etudes, calculs, maîtrise d'oeuvre, suivi de projet.","http://www.orion-etudes.com",""); 
	}
	else 
	{ 
		window.external.AddFavorite("http://www.orion-etudes.com","Orion Etudes - Etudes, calculs, maîtrise d'oeuvre, suivi de projet."); 
	}
}

// +----------------------------------------------+
// | Script anti clic droit                       |
// +----------------------------------------------+
function right(e) {
  var msg = "Par respect des droits d'auteurs,\nnous n'autorisons pas le clic droit!!!\n\nL'équipe Bistronaut.";
  if (navigator.appName == 'Netscape' && e.which == 3)
  {
    alert(msg);  // Delete this line to disable but not alert user
    return false;
  }
  else
    if (navigator.appName == 'Microsoft Internet Explorer' && event.button==2)
    {
      alert(msg); // Delete this line to disable but not alert user
      return false;
    }
  return true;
}
// document.onmousedown = right;

// +----------------------------------------------+
// | Aficher ou cacher <DIV>EMPLOI</DIV>          |
// +----------------------------------------------+
var aOldDiv = new Array();

function afficheDhtml(dhtmlobject)
{
	oDiv = document.getElementById(dhtmlobject);
	if (oDiv)
  {
	  oDiv.style.display = 'block';

  	if (aOldDiv.length > 0)
  	{
  	   oDiv2 = document.getElementById(aOldDiv.pop());
  	   if (oDiv != oDiv2)
       {
  	     oDiv2.style.display = 'none';
       }
  	}
  }
	aOldDiv.push(dhtmlobject);
}

// +----------------------------------------------+
// | Aficher ou cacher <DIV>__</DIV>              |
// +----------------------------------------------+
function displayswitch(id_object)
{
  if (document.getElementById(id_object).style.display == "none")
    document.getElementById(id_object).style.display = "block";
  else
    document.getElementById(id_object).style.display = "none";
}

/* ------------------------------------------------------------------------ */
/*                           PHOTO BOX                                      */
/* ------------------------------------------------------------------------ */
bIE = document.all && document.getElementById;
bGK = document.getElementById && !document.all;

function showBox(iId, iPosition, iNbPhoto, sRepertoire)
{
  oBox = document.getElementById('box');
  oImg = document.getElementById('box_img');
  oLoad = document.getElementById('load');
  oBtPrev = document.getElementById('bt_prev');
  oBtNext = document.getElementById('bt_next');
  
  oImg.style.width = null;
  oImg.style.height = null;
  oImg.style.visibilty = "hidden";
  oLoad.style.display = "block";
  oBtPrev.style.display = "none";
  oBtNext.style.display = "none";
    
  if(iPosition > 1)
    oBtPrev.style.display = "block";

  if(iPosition < iNbPhoto)
    oBtNext.style.display = "block";    

  oBtPrev.href = "javascript:showBox(" + iId + ", " + (Number(iPosition)-1) + ", " + iNbPhoto + ", '" + sRepertoire + "');";
  oBtNext.href = "javascript:showBox(" + iId + ", " + (Number(iPosition)+1) + ", " + iNbPhoto + ", '" + sRepertoire + "');";

  var iTop = parseInt(oBox.offsetTop);
	if (bGK)
  {
		var iScrool = parseInt(window.pageYOffset);
		var iTotal = window.innerHeight;
	}
	else if (bIE)
  {
		var iScrool = document.body.scrollTop ? parseInt(document.body.scrollTop) :  parseInt(document.documentElement.scrollTop);
		var iTotal = document.body.clientHeight;
	}
/*
  oBox.onclick = function () 
  {
    oBox = document.getElementById('box');
    oBox.style.display = "none";
  }
*/
  oImg.onload = function () 
  {
    oImg.style.visibilty = "visible";
    oLoad = document.getElementById('load');
    oLoad.style.display = "none";
  }

  oBox.style.display = "block";
  oBox.style.top = iScrool + "px";

  oImg.src = "/images/"+ sRepertoire + "/" + iId + "_" + iPosition + "_gd.jpg";
}
