$.popup={
	queue:[],
	mix:document.onmousedown=function(e){
		var e=e||window.event,t=e.target||e.srcElement;
		$.popup.hide($.popup.show(t));
	},
	show:function(n,a){
		a=a || [],t=this;
		while(n.parentNode){
			this.queue.each(function(o){if(n==o.poper || n==o.sender){a.push(o);$.show(o.poper);t.position(o);if(o.onshow)o.onshow({type:'onshow',target:o});if(n==o.poper)t.show(o.sender,a)}});
			n=n.parentNode;
		}
		return a;
	},
	hide:function(a){
		a=a || [];
		this.queue.each(function(t){
			var h =true;
			a.each(function(o){if(t==o)h=false});
			if(h){$.hide(t.poper);if(t.onhide)t.onhide({type:'onhide',target:t})}
		});
	},
	position:function(t){
		var p =$.getXY(t.sender);
		if(t.area=='-' || t.area=='VERTICAL' || t.area==0){
			p.x+=t.sender.offsetWidth;
		}else{
			p.y+=t.sender.offsetHeight;
			with(t.poper.style){top=p.y+'px';left=p.x+'px'}
		}
	},
	add:function(t){
		var a = true;
		this.queue.each(function(o){if(o.poper == t.poper)a=false});
		t.poper.style.position='absolute';
	
		$.hide(t.poper,false);
		if(a)this.queue.push(t);
		return t;
	}
};