
if (document.images) {
  var orgWindowOnload = null;
  var winName = 'imagewin';

  if (window.onload) orgWindowOnload = window.onload;
  window.onload = windowOnloadImages;
}

function windowOnloadImages()
{
  if (orgWindowOnload) orgWindowOnload();
  for (var i=0; i < document.links.length; i++) {
    var HREF = document.links[i].href.toLowerCase().split('.');
    if (HREF[HREF.length-1] == 'jpeg' ||
        HREF[HREF.length-1] == 'jpe' ||
        HREF[HREF.length-1] == 'jpg' ||
        HREF[HREF.length-1] == 'gif' ||
        HREF[HREF.length-1] == 'png')
      document.links[i].onclick = onklickImage;
  }
}

function singleUnHex(hexchar)
{
  hexchar -= 48;
  if (16 < hexchar) hexchar -= 7;
  if (41 < hexchar) hexchar -= 32;
  return hexchar;
}

function unquote(name)
{
  var parts = name.split('%');
  var retval = parts[0];
  for (var i = 1; i < parts.length; i++) {
    var h = singleUnHex(parts[i].charCodeAt(0));
    var l = singleUnHex(parts[i].charCodeAt(1));
    retval += String.fromCharCode(16*h+l);
    retval += parts[i].substring(2, parts[i].length);
  }
  return retval;
}

function onklickImage()
{
  var ModX = 0, ModY = 0;
  var scrollbarsFlag = 0;
  var Dat = this.href.split('/');
  Dat = Dat[Dat.length-1];
  var ImageName = Dat.split('_');
  Dat = Dat.split('.');
  Dat = Dat[Dat.length-1];
  var ImageSize = ImageName[ImageName.length-2].split('x');
  var MaxX = screen.width-24, MaxY = screen.height-56;
  var xImg = parseInt(ImageSize[0]);
  var yImg = parseInt(ImageSize[1]);
  var xSize, ySize;
  var faktor = "100%";

  if (4*xImg < MaxX && 4*yImg < MaxY) {
    xImg *= 4;
    yImg *= 4;
    faktor = "400%";
  } else if (3*xImg < MaxX && 3*yImg < MaxY) {
    xImg *= 3;
    yImg *= 3;
    faktor = "300%";
  } else if (2*xImg < MaxX && 2*yImg < MaxY) {
    xImg *= 2;
    yImg *= 2;
    faktor = "200%";
  } else if (3*xImg < 2*MaxX && 3*yImg < 2*MaxY) {
    xImg = 3*xImg/2;
    yImg = 3*yImg/2;
    faktor = "150%";
  }
  xSize = xImg;
  ySize = yImg;
  if (MaxX < xSize || MaxY < ySize) {
    if (MaxX < xSize) xSize = MaxX;
    if (MaxY < ySize) ySize = MaxY;
    scrollbarsFlag = 1;
    ModX += 16;
    ModY += 16;
  }
  xSize += ModX;
  ySize += ModY;
  var Param = 'width='+xSize+',height='+ySize+',directories=0,location=0'+
    ',menubar=0,status=0,resizable=0,scrollbars='+scrollbarsFlag+
    ',left='+(screen.width/2-xSize/2-4)+',top='+(screen.height/2-ySize/2-28);
  if (window[winName] && !window[winName].closed) window[winName].close();

  var Title = '&nbsp; | &nbsp; &nbsp; ';
  for (var i = 1; i < ImageName.length-2; i++) Title += unquote(ImageName[i])+' ';
  Title += '&nbsp; &nbsp; | &nbsp; &nbsp; '+
    ImageName[0].substring(7,9)+'.'+ImageName[0].substring(4,6)+'.20'+
    ImageName[0].substring(1,3)+' &nbsp; &nbsp; | &nbsp; &nbsp; FSK-RbK'+
    ' &nbsp; &nbsp; | - | - | - | - | - | - | - | - | ';
  window[winName] = window.open('', winName, Param);
  window[winName].document.open();
  window[winName].document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01'+
    ' Transitional//EN"><html>\n<head>\n<meta http-equiv="Content-Type content"'+
    '="text/html; charset=iso-8859-1">\n<title>'+Title+'</title>\n</head>\n'+
    '<body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0><div>\n'+
    '<a href="javascript:self.close()"><img border=0 src="'+this.href+
    '" width='+xImg+' height='+yImg+' title="');
  for (var i=1; i < ImageName.length-2; i++) {
    window[winName].document.write(ImageName[i]);
    if (i < ImageName.length-3) window[winName].document.write(' ');
  }
  window[winName].document.write('" alt="');
  for (var i=1; i < ImageName.length-2; i++) {
    window[winName].document.write(ImageName[i]);
    if (i < ImageName.length-3) window[winName].document.write(' ');
  }
  window[winName].document.write('"></a>\n</div></body>\n</html>\n');
  window[winName].document.close();

  return false;
}
