function show() {
	var sizes = getPageSize();
	$('light_img').src = 'xadmin/icons/progress_bar.gif';
	$('overlay').style.display='';
	$('overlay').style.height=sizes[1]+'px';
	$('lightbox').style.top = getScrollHeight() + 100 + 'px';
	$('lightbox').style.display='';
}

function show2() {
	var sizes = getPageSize();
	$('light_img2').src = 'xadmin/icons/progress_bar.gif';
	$('overlay2').style.display='';
	$('overlay2').style.height=sizes[1]+'px';
	$('lightbox2').style.top = getScrollHeight() + 100 + 'px';
	$('lightbox2').style.display='';
}

function hide() {
	$('overlay').style.display='None';
	$('lightbox').style.display='None';
}

function hide2() {
	$('overlay2').style.display='None';
	$('lightbox2').style.display='None';
}

function show_image(link){
		if($('overlay').style.display!='') show();
		$('light_img').src=link;
		$('slide_position').innerHTML = (pos(im) + 1) + " / " + im.length;
}

function show_image2(link){
		if($('overlay2').style.display!='') show2();
		$('light_img2').src=link;
}

function pos(im){
	for(var i=0; i < im.length; i++) {
		if ($('light_img').src.match('='+im[i])) return i;
	}
}

function iprev(im){
	var position = pos(im)
	if(position) {
		position--;
		$('light_img').src = 'xadmin/php/image.php?size=large&id='+im[position];
		$('slide_position').innerHTML = (position + 1) + " / " + im.length
	}
}

function inext(im){
	var position = pos(im)
	if(im.length-1>position) {
		position++;
		$('light_img').src = 'xadmin/php/image.php?size=large&id='+im[position];
		$('slide_position').innerHTML = (position + 1) + " / " + im.length
	}
}

function getScrollHeight(){
   var h = window.pageYOffset ||
           document.body.scrollTop ||
           document.documentElement.scrollTop;
   return h ? h : 0;
}

function getPageSize(){
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}

	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight) pageHeight = windowHeight; else pageHeight = yScroll;

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth) pageWidth = windowWidth; else pageWidth = xScroll;

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	return arrayPageSize;
}
