var agt = navigator.userAgent.toLowerCase();
var is_gecko = (agt.indexOf('gecko') != -1);
var x,y
var box;

function handlerMM(e){
	x = (is_gecko) ? e.pageX : event.clientX;
	y = (is_gecko) ? e.pageY : event.clientY;
	
	if (x < 0) { x = 0; }
	if (y < 0) { y = 0; }  
	
	return false;
}
if (document.layers){
	document.captureEvents(Event.MOUSEMOVE);
}

document.onmousemove = handlerMM;

function pause(numberMillis) {
	var now = new Date();
	var exitTime = now.getTime() + numberMillis;
	while (true) {
		now = new Date();
		if (now.getTime() > exitTime)
			return;
	}
}

function openbox(content) {
	pause(500);

	if (content == '') return false;
	box = document.getElementById('popupbox');
	box.innerHTML = content;
	box.style.left = x+20 + "px";
	box.style.top = y + "px";
	box.style.display = 'inline';
	box.style.visibility = 'visible';
	return false;
}

function closebox(){
	box = document.getElementById('popupbox');
	box.style.visibility = "hidden";
	return false;
}

function zoomout() {
	try {
		var container = document.getElementById('zoomer');
		container.style.display = 'none';
	} catch (e) {
		alert(e.message);
	}
}

function zoom(img) {
	try {
		var container = document.getElementById('zoomer');
		if (container.style.display == 'none') {
			myImage = new Image() 
			myImage.src = img; 
			
			container.innerHTML = '<img src="' + myImage.src + '" border="0" id="large_image" class="zoomer_out" onclick="zoomout();" /><br /><div align="center"><a href="javascript:zoomout();">Close</a>';
			
			var image_width = myImage.width;
			var image_heigth = myImage.height;			
			var screen_width = screen.availWidth;
			var screen_height = screen.availHeight;
			var new_x = (screen_width - image_width) / 2 + "px";
			var new_y = (screen_height - image_heigth) / 2 + "px";
			
			container.style.left = new_x;
			container.style.top = new_y;
			container.style.display = 'inline';
		} else {
			container.style.display = 'none';
		}
	} catch (e) {
		alert(e.message);
	}
}