function $(x) { return document.getElementById(x); }
function hide()
{
  var simg = $('showimg');
  simg.src = '{i:http.img}/empty.gif';
  simg.style.border = 'none';
  $('backshow').style.display = 'none';
}

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
      //Netscape compliant
      scrOfY = window.pageYOffset;
      scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
      //DOM compliant
      scrOfY = document.body.scrollTop;
      scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
      //IE6 standards compliant mode
      scrOfY = document.documentElement.scrollTop;
      scrOfX = document.documentElement.scrollLeft;
  }
  return { x:scrOfX, y:scrOfY };
}

function getSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
      //Non-IE
      myWidth = window.innerWidth;
      myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
      //IE 6+ in 'standards compliant mode'
      myWidth = document.documentElement.clientWidth;
      myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
      //IE 4 compatible
      myWidth = document.body.clientWidth;
      myHeight = document.body.clientHeight;
  }
  return { w:myWidth, h:myHeight };
}

function fnimg(x)
{
  var simg = $('showimg');
  simg.src = '{i:http.img}/empty.gif';
  
  
  var i = $(x);
  if ( !i ) return;
  
  var x = i.getAttribute("file");
  
  var backshow = $('backshow');
  backshow.className = '';
  backshow.style.display = 'block';
  backshow.style.height = Math.max( ( $('bottom').offsetTop + $('bottom').clientHeight ), document.body.clientHeight )+'px';

  var show = $('show');
  
  var scr = getScrollXY();
  var size = getSize();
                  
  show.style.top = (scr.y)+'px';
  simg.style.height = 
  show.style.height = (size.h-80)+'px';
  
  simg.src = x;
  simg.style.border = '10px solid #fff';
  
//  $('print').setAttribute('href', i.getAttribute('print_url') );
  $('save').setAttribute('href', i.getAttribute('save_url') );
  $('gallery_hint').innerHTML = i.getAttribute('title');
  
  return false;
}


