var pop = null;

function showPop(id,coords){
  theImg = document.images["p_"+maps[0]];
  topx = getEltTop(theImg);
  var leftBorder = Math.round(parseInt(document.body.clientWidth)/2)-300;
  if (pop != null) pop.style.display = 'none';
  pop = document.getElementById(id);
  theX=0;
  theY=0;
  if (!window.event) {
    var newCoords = eval('new Array('+coords+')');
    for (i=0;i<newCoords.length;i+=2) {
      theX = theX += newCoords[i];
    }
    for (j=1;j<newCoords.length;j+=2) {
      theY = theY += newCoords[j];
    }
    pop.style.left = leftBorder + Math.round(theX/(newCoords.length/2));
    pop.style.top =  topx + Math.round(theY/(newCoords.length/2));
  }
  else {
    pop.style.top = window.event.clientY + document.body.scrollTop;
    pop.style.left = window.event.clientX;
  }
  pop.style.display = "block";
}

function hidePop(id) {
  document.all(id).style.display = "none";
}

function setPics() {
  for (var x=0;x<maps.length;x++) {
    bigImg = document.images["p_"+maps[x]];
    leftx = getEltLeft(bigImg);
    topx = getEltTop(bigImg);
    num = getElt("d"+maps[x]).title;
    for (y=1;y<=num;y++) {
      img = document.images[maps[x]+y];
      img.style.MozOpacity= .0;
      positie = img.id;
      imgX= positie.substring(1,positie.indexOf('z'));
      imgY= positie.substring(positie.indexOf('z')+1,positie.length);
      setEltLeft(img,parseInt(leftx) + parseInt(imgX));
      setEltTop(img,parseInt(topx) + parseInt(imgY));
      img.style.display = "block";
    }
  }
}

function changeImg(id) {
  obj = getElt(id);
  setOP(obj,0);
}

function resetImg(id) {
  obj = getElt(id);
  setOP(obj,0);
}