var openoverlay;

function showOverlay(target){
	var arrayPageSize = getPageSize();
	g('overlay1').style.display = 'block';
	g('overlay2').style.display = 'block';
	g('overlay1').style.height = arrayPageSize[1] + 'px';
	g('overlay2').style.height = arrayPageSize[1] + 'px';
	g(target).style.display = 'block';
	openoverlay = target;
}
function hideOverlay(){
	g(openoverlay).style.display = 'none';
	g('overlay1').style.height = '1px';
	g('overlay1').style.display = 'none';
	g('overlay2').style.display = 'none';
	var divx = document.getElementById('imginfo01');
	divx.innerHTML="";
	var divy = document.getElementById('scripts');
	divy.innerHTML="";
}

function g(id){
	return document.getElementById(id);
}




//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
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;
}


// ---------------------------------------------------

document.onkeypress = function(e) {
	var code;
	if (!e) var e = window.event;
	if (e.keyCode) code = e.keyCode;
	else if (e.which) code = e.which;
	if (code == 27){
		hideOverlay();
	}
}

function resizePopupComments(ref,target){
	g(target).style.height = g(ref).offsetHeight + 'px';
}

function popHl(ref){
	ref.className = 'focus';
}
function popDhl(ref){
	ref.className = '';
}