/* 
Un JavaScript pour afficher une fausse Pop-Up DHTML pour les éléments inline 

[FG]2005-12-02 
réécriture pour 
 * ne pas dépasser à droite ou en bas
 * cacher ce qui serait resté ouvert

*/


function popUp(evt,objectID){
	if (!isDHTML) return;
	obj = findObj(objectID);
	if (toHide && toHide != obj) toHide.style.visibility = "hidden";
	toHide=obj;
	if (evt.pageY) { //Calculates the position for Navigator 4
		topVal = evt.pageY;
		leftVal = evt.pageX;
	} else if (evt.y) { // Calculates the position for IE4
	 topVal = getViewY() + evt.y + 10;
	leftVal = getViewX() + evt.x - 100;
	}

var x=1000;
y=800;
if (self.innerHeight) // all except Explorer
{
	x = self.innerWidth;
	y = self.innerHeight;
}
else if (document.documentElement && document.documentElement.clientHeight)
	// Explorer 6 Strict Mode
{
	x = document.documentElement.clientWidth;
	y = document.documentElement.clientHeight;
}
else if (document.body) // other Explorers
{
	x = document.body.clientWidth;
	y = document.body.clientHeight;
}
// [FG] Encore un problème repéré pour les images en haut
	if (topVal > (y * 0.7)) 
		obj.style.top= (topVal - obj.offsetHeight - 20)+"px";
	else 
		obj.style.top = topVal + "px"; // Positions the element from the top

	if (leftVal > (x * 0.7)) 
		obj.style.left= (leftVal - obj.offsetWidth + 100) + "px";
	else 
		obj.style.left = leftVal + "px"; // Positions the element from the left

	obj.style.visibility = "visible"; // Makes the element visable
}

var toHide;
function hide(evt,objectID) {
	if (toHide) toHide.style.visibility = "hidden";
	if (!isDHTML) return;
	obj = findObj(objectID);
	if (obj) obj.style.visibility = "hidden";
}

var toggle = 0;
var delay = 500;
function setDelay(objectID) {
   toggle = 1;
   obj = findObj(objectID,1);
   obj.visibility="visible";
}

function resetDelay(objectID) {
  toggle = 0;
  obj = findObj(objectID,1);
  setTimeout('if (toggle==0) { obj.visibility="hidden"; }', delay);
}

function getViewX(){
  var offset=0;
  if (window.pageXOffset) offset=window.pageXOffset; // gecko, nn4,opera
  else if (document.documentElement &&
document.documentElement.scrollLeft)
offset=document.documentElement.scrollLeft; // ie6 compat mode
  else if (document.body && document.body.scrollLeft)
offset=document.body.scrollLeft; // ie4up
  return offset;
}

function getViewY(){
  var offset=0;
  if (window.pageYOffset) offset=window.pageYOffset;
  else if (document.documentElement &&
document.documentElement.scrollTop)
offset=document.documentElement.scrollTop;
  else if (document.body && document.body.scrollTop)
offset=document.body.scrollTop;
  return offset;
}

/* Les fonctions nécessaires à  l'affichage des rubriques du dossier d'artiste */

/* Pour ouvrir une popup d'information (eg, adresse d'un organisme)  */

function openPopUp(x)
  {
    popupWin = window.open(x,"infos","resizable=yes,scrollbars=yes,width=300,height=300,screenX=50,screenY=50");
    popupWin.focus();
  }

/* Pour ouvrir une nouvelle fenêtre pour un dossier d'artiste */
function openDossier(x)
  {
    dossierWin = window.open(x,'','resizable=yes,width=820,height=500');
    dossierWin.focus();
  }

/* Pour ouvrir une nouvelle fenêtre pour une oeuvre */
function openOeuvre(x)
  {
    /* Pour ouvrir toutes les oeuvres dans une même fenêtre, il faut donner
    un nom à  la fenêtre entre les guillemets simples qui ne contiennent rien
    aprés le 'x'. */
    oeuvreWin = window.open(x,'','resizable=yes,scrollbars=yes,height=500,width=820');
    oeuvreWin.focus();
  }

/* Un JavaScript pour ouvrir une fenêtre pop-up présentant les oeuvres */
/* NOTE: Le calcul de la largeur et de la hauteur se fait sur la base de la
fenêtre courante du navigateur. [mp] */
function openWin(name,url,height,width)
  {
    /* On récupère les dimensions de l'image de l'oeuvre. Les dimensions de la
    fenêtre y sont proportionnelles. */
    if (name == 'image') {
      height = height + 20;
      width = width + 20;
    }
    else if (name != 'image') {
      height = height + 100;
      width = width + 100;
    }
    /* Ces deux variables peuvent servir pour ouvrir une nouvelle fenêtre
    suivant les dimensions du navigateur
    var height = window.outerHeight * 0.8;
    var width = window.outerWidth * 0.7; */
    /* Pour activer l'affichage des oeuvres dans une seule fenêtre
    il faut mettre +name+ entre les guillemets de la ligne suivante
    aprÃ¨s url et avant height [mp 20030923]*/
    /* var newWin = window.open(url,'','height='+height+',width='+width+',location=no,menubar=no,personalbar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no'); */
    var newWin = window.open(url,'','height='+height+',width='+width+',location=no,menubar=no,personalbar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');
    newWin.focus();
  }


var isDHTML = 0;
var isLayers = 0;
var isAll = 0;
var isID = 0;

if (document.getElementById) {isID = 1; isDHTML = 1;}
else {
  browserVersion = parseInt(navigator.appVersion);
    if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {isLayers = 1; isDHTML = 1;}
    else {
      if (document.all) {isAll = 1; isDHTML = 1;}
    }
}

function findObj(objectID,withStyle) {
  if (withStyle == 1) {
      if (isID) { return (document.getElementById(objectID).style); }
    else { 
      if (isAll) { return (document.all[objectID].style); }
      else {
        if (isLayers) { return (document.layers[objectID]); }
      }
    }
  } else {
      if (isID) { return (document.getElementById(objectID)); }
    else { 
      if (isAll) { return (document.all[objectID]); }
      else {
        if (isLayers) { return (document.layers[objectID]); }
      }
    }
  }
}


/*
get properties of an object
for debug
*/
function props(o) {
 var result = ""
 var a=new Array();
 var i=0
 for (var prop in o) {
		a[i]= prop  + "\t"; // + " = " + o[prop]
		i++;
 }
 a.sort();
 return a;
}
