// Browser Window Size and Position
function pageWidth() {
	return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ?       document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
}
function pageHeight() {
	return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;
}
function leftPos() {
	return typeof window.pageXOffset != 'undefined' ? window.pageXOffset :document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;
}
function topPos() {
	return typeof window.pageYOffset != 'undefined' ?  window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;
}
function rightPos() {
	return posLeft()+pageWidth();
}
function bottomPos() {
	return posTop()+pageHeight();
}

function move_box()
{
  if( boxdiv.style.display != 'none' )
  {
	
	  var posLeft = ( ( ( pageWidth() - 4 ) - width ) / 2 );
	  var posTop  = ( topPos() + ( pageHeight() - height ) / 2 );
	
	  boxdiv.style.left = posLeft + 'px';
	  boxdiv.style.top  = posTop  + 'px';
  }
}


self.setInterval('move_box()', 30)



function hide_box() {
	boxdiv.style.display = 'none';
	return false;
}




var width = '820';
var height = '460';

var boxdiv = document.createElement('div');
var contents = document.createElement('iframe');
  
function show_box( gal, img ) {
	
  var href = 'viewGallery.php?gal=' + gal + '&img=' + img;

  boxdiv.setAttribute('id', href);
  boxdiv.style.display = 'block';
  boxdiv.style.position = 'absolute';
  boxdiv.style.width = width + 'px';
  boxdiv.style.height = height + 'px';
  boxdiv.style.border = '1px solid';
  boxdiv.style.backgroundColor = '#ffffe6';

  contents.scrolling = 'no';
  contents.frameBorder = '0';
  contents.style.width = width + 'px';
  contents.style.height = height + 'px';
  contents.src = href;

  boxdiv.appendChild(contents);
  document.body.appendChild(boxdiv);
  move_box();

  return false;
}