function create_lightbox( id, width, height, html, mod )
{
  if (!mod) { mod = ''; }
  if (mod == 2 && document.getElementById(id+"_2")) 
  { destroy_lightbox(id+"_2"); 
  }

  if (!mod || mod == '')
  { var newdiv = document.createElement('div');
    newdiv.setAttribute('id', id);
    var classname = 'lightbox';
    classname += mod;
    newdiv.className = classname;
    newdiv.style.height = document.body.clientHeight+"px";
  }
  
  var newdiv2 = document.createElement('div');
  newdiv2.setAttribute('id', id+"_2");
  var classname = 'lbcontent';
  classname += mod;
  newdiv2.className = classname;
  
  if (width) { newdiv2.style.width = width+"px"; }
  if (height) { newdiv2.style.height = height+"px"; }
  
  /* calcul de la position top */
  if (mod==2) { var y = 60; }
  else        { var y = 140; }
  if (navigator.appVersion.indexOf('Chrome')>0 || navigator.appVersion.indexOf('Safari')>0)
  { y += document.body.scrollTop;
  }
  else
  { y += document.documentElement.scrollTop;
  }
  
  newdiv2.style.top = y+"px";
  
  /* calcul de la position left */
  var x = 0;
  var wwidth = document.body.clientWidth;
  if (width < wwidth)
  { x = ((wwidth/2) - (width/2));
  }
  if (mod==2) { x += 200; }
  newdiv2.style.left = x+"px";
  
  if (html) {
    newdiv2.innerHTML = html;
  } else {
    newdiv2.innerHTML = "";
  }
  
  if (!mod || mod == 1)
  { document.body.appendChild(newdiv);
  }
  document.body.appendChild(newdiv2);  
}

function destroy_lightbox( id )
{
  var obj = document.getElementById( id );
  var tab_body = document.getElementsByTagName( 'body' );
  var body = tab_body[0];
  var obj2 = document.getElementById( id+"_2" );
  
  if (obj2) { body.removeChild(obj2); }           
  if (obj) { body.removeChild(obj); }
}

function show_lightbox( id )
{
  var obj = document.getElementById( id );
  obj.style.display = "block";
}

function mask_lightbox( id )
{
  var obj = document.getElementById( id );
  obj.style.display = "none";
}
