var popups = [];
var lastpopup;
addEvent(window,'load',function() { 
	addEvent(document.body,'click',function() { 
		while(popups.length) { 
			var popup = popups.pop();
			popup.style.display = 'none';
		}

		if(lastpopup) { 
			popups.push(lastpopup);
			lastpopup = undefined;
		}
	});
});

function miniPopupHandler(node,evt) { 
	var div = document.getElementById(node.id + "_minipopup");
	var offset = scrollOffset();

	div.style.position='absolute';

	// IE doesn't have pageX or pageY, so we take the relative location and add in the page offset
	// Safari decided to make evt.clientX be the absolute position of the event, 
	// so we can't just do clientX + offset consistently
	div.style.left = ( evt.pageX  ? evt.pageX : evt.clientX + offset.x) - 10 + "px";
	div.style.top = (evt.pageY ? evt.pageY : evt.clientY + offset.y)  - 20 + "px";
	div.style.display = 'block';
	div.style.backgroundColor = 'white';
	div.style.border = '3px gray outset';

	// becasue IE handles the events in a different order than mozilla:
	if(document.all) { 
		lastpopup = div;
	} else { 
		popups.push(div);	
	}
	return false;
}

