var tmp=new Image();
tmp.src='/templates/loading.gif';

var fooIsOpen=false;
function foo(src,w,h) {
	var foo=document.getElementById("foo");
	var fooimg=document.getElementById('fooimg');
	var zat=document.getElementById('zat');

	if(foo.style.display=="none") { 
		document.getElementById('tmpimg').src=src;

		zat.style.display='block';
		zat.style.width=document.body.scrollWidth+'px';
		zat.style.height=document.body.scrollHeight+'px';

		foo.style.display="block";

		if(w) foo.style.width=w;
		if(h) foo.style.height=h;
		foo.style.left=document.body.scrollLeft+Math.round((document.body.clientWidth-foo.offsetWidth)/2)+'px';
		foo.style.top=document.body.scrollTop+Math.round((document.body.clientHeight-foo.offsetHeight)/2)+'px';

		fooIsOpen=true;
	} else {
		zat.style.display='none';
		fooimg.src='/templates/loading.gif';

		foo.style.display="none";
		fooIsOpen=false;
	}
}


window.onkeyup = function(e) {
	if(fooIsOpen) {
		key = e.keyCode || e.which;
		if(key == 27)
    			foo();
	}
}

