var popups = [];
function popup( link,popup_id ) {
	var popup = null;
	var timer = null;
	var timeout = 500;
	link.mouseover(function() {
		if ( timer !== null ) {
			clearTimeout(timer);
			timer = null;
		}
		for( i in popups ) {
			popups[i].css('display','none');
		}
		if ( popup == null ) {
			popup = $('#' + popup_id);
			if ( popup.length == 0 ) {
				return;
			}
			popup.css('display','block');
			var width = popup.find('.content').outerWidth();
			popup.find('.shadow_bottom .spacer').css('width',( width - 31 ) + 'px');
			var height = popup.find('.content').outerHeight();
			popup.find('.shadow_right .spacer').css('height',( height - 5 ) + 'px');
			popup.mouseover(function() {
				if ( timer == null ) {
					return;
				}
				clearTimeout(timer);
				timer = null;
			}).mouseout(function() {
				timer = setTimeout(function() {
					popup.css('display','none');
					timer = null;
				},timeout);
			});
			var offset = link.offset();
			var left = offset.left - 8;
			var top = ( offset.top - popup.outerHeight() - 3 );
			popup.css({
				top: top + 'px',
				left: left + 'px'
			});
			popups[popups.length] = popup;
		}
		popup.css('display','block');
	}).mouseout(function() {
		if ( popup == null ) {
			return;
		}
		timer = setTimeout(function() {
			popup.css('display','none');
			timer = null;
		},timeout);
	});
}
