function images_next(id, nb_images, auto) {
  var images_current_index = eval('images_current_index_' + id);
  var images_interval = eval('images_interval_' + id);
  if ( !auto )
    clearInterval(images_interval);
  var current_image = document.getElementById('images_thumb_' + id + images_current_index);
  if ( images_current_index == nb_images )
    images_current_index = 1;
  else
    images_current_index++;  
  var next_image = document.getElementById('images_thumb_' + id + images_current_index);
  current_image.style.display = 'none';
  next_image.style.display = '';
  eval('images_current_index_' + id + '=' + images_current_index);
}

function images_previous(id, nb_images, auto) {
  var images_current_index = eval('images_current_index_' + id);
  var current_image = document.getElementById('images_thumb_' + id + images_current_index);
  var images_interval = eval('images_interval_' + id);
  if ( !auto )
    clearInterval(images_interval);
  if ( images_current_index == 1 )
    images_current_index = nb_images;
  else
    images_current_index--;
  var next_image = document.getElementById('images_thumb_' + id + images_current_index);
  current_image.style.display = 'none';
  next_image.style.display = '';
  eval('images_current_index_' + id + '=' + images_current_index);
}

function images_show(id, title) {
  var image = document.getElementById(id);    
  var img = image.getElementsByTagName('img');
  if ( img && (img.length > 0) )
    img = img[0];
  var html = image.innerHTML;
  var width = img.width + 80;
  var height = img.height + 15;
  height += 40;
  height += 50;    
  images_showPopup(html, width, height, title);
}

function images_showPopup(html, width, height, title) {
  var params = "";
  params += "innerwidth  = " + width  + ", ";
  params += "innerheight = " + height + ", ";
  params += "width       = " + width  + ", ";
  params += "height      = " + height + ", ";
  params += "dependent   = yes, ";
  params += "location    = no , ";
  params += "menubar     = no , ";
  params += "status      = no , ";
  params += "toolbar     = no , ";
  params += "scrollbars  = yes, ";
  params += "resizable   = yes, ";    
  params += "top         = " + 10 + ", ";
  params += "left        = " + ((screen.width  - width)  / 2);
  var win = window.open("about:blank", "win", params);
  win.document.write('<html>');
  win.document.write('<head>');
  win.document.write('<link rel="stylesheet" type="text/css" href="' + images_css_url  + '">');
  if ( title ) {
    win.document.write('<title>');
    win.document.write(title);
    win.document.write('</title>');
  }
  win.document.write('</head>');
  win.document.write('<body style="margin:0px;">');
  win.document.write(html);
  win.document.write('</body>');
  win.document.write('</html>');
}
