function __popMenu()
{
	this.queue	= new Array();
	EventDispatcher.initialize(this);
	this.popClick=function(e){
		e 	=	e || window.event;
		var target	= e.target || e.srcElement;
		var q=PopMenu.queue,l=q.length;
		
		for(var i=0;i<l;i++){
			
			var t=target,isHide = true;
			try{
				while(t.tagName.toLowerCase()!='body'){
					if(t==q[i].o) isHide =false;
					t=t.parentNode;
				}
			}catch(e){isHide=true;}
			if(target != q[i].t && isHide && q[i].o.style.display=='')
				PopMenu.setHide(q[i].o);
		}
	}
	
	this.setHide=function(o){
		var p	=	Global.getId('pop_'+o.id);
		if(p) p.style.display='none';
		o.style.display='none';
		this.dispatchEvent({type:"onHide",target:o});
		document.onclick=this.oldDocClick;
	}
	
	this.add=function(t,o){
		this.oldDocClick=document.onclick;
		document.onclick=this.popClick;
		var pStyle	=	'background:#666;position:absolute;width:'+o.offsetWidth+'px;height:'+o.offsetHeight+'px;';				
		var p		=	Global.getId('pop_'+o.id) || o.parentNode.insertBefore(document.createElement('div'),o);
		var q		=	{t:t,o:o};
		var isAdd	=	true;
		p.id='pop_'+o.id;
		pStyle+=Global.ie?'filter:alpha(opacity=40);':'opacity:0.4;';
		p.style.cssText	=	pStyle;
		p.style.top		=	(o.offsetTop+2)+'px';
		p.style.left	=	(o.offsetLeft+2)+'px';
		q.p=p;
		for(var i=0;i<this.queue.length;i++){
			if(q.t==this.queue[i].t) isAdd=false;
		}
		if(isAdd) this.queue.push(q);
		o.style.display='';
		PopMenu.dispatchEvent({type:"onShow",target:o});
	}
	
}
var PopMenu = new __popMenu();
