/* This script and many more are available free online at
The JavaScript Source :: http://javascript.internet.com
Created by: JTricks.com :: http://www.jtricks.com/ */

function hide(){
    this.style.display = 'none';
}    
function show_hide_box(enllac, an, nom, contingut, img) {
  //var href = an.href;
  //var boxdiv = document.getElementById(href);
  var boxdiv = document.getElementById(an);

  if (boxdiv == null){
    boxdiv = document.createElement('div');
    boxdiv.setAttribute('id', an);
    boxdiv.className = 'caixapopup';
    boxdiv.style.display = 'none';
    boxdiv.style.position = 'absolute';
    boxdiv.style.padding = '4px';
   
    boxdiv.name = nom;
    boxdiv.onblur = hide;

    document.body.appendChild(boxdiv);
  }
    if (boxdiv.style.display=='none' || boxdiv.name != nom) {
      move_box(enllac, boxdiv);
      boxdiv.style.display='block';
      boxdiv.name = nom;
      boxdiv.innerHTML = 
      "<div class=\"tancarpopup\"><a href=\"#\" onclick=\"this.parentNode.parentNode.style.display='none'; return false;\" style=\"border:none;\" ><img src=\"" + img + "\" style=\"border:none;\"  /></a></div>" +contingut;
      boxdiv.focus();
    } else
      boxdiv.style.display='none';
  return false;
}

function move_box(an, box) {
  var cleft = 0;
  var ctop = 0;
  var obj = an;
  while (obj.offsetParent) {
    cleft += obj.offsetLeft;
    ctop += obj.offsetTop;
    obj = obj.offsetParent;
  }
  box.style.left = cleft + 'px';
  ctop += an.offsetHeight + 8;
  if (document.body.currentStyle &&
    document.body.currentStyle['marginTop']) {
    ctop += parseInt(
      document.body.currentStyle['marginTop']);
  }
  box.style.top = ctop + 'px';
}

