function Menu(){
	this.Box=null;
	this.FrameBox=null;
	this.Head='';
	this.Foot='';
	this.ItemHead='';
	this.ItemFoot='';
	this.ItemClass='';
	this.Items=new Array();
	this.State=0;
	this.OK=false;
	this.Timer=null;
	this.MenuContent='';
	
	this.Load=LoadMenu;
	this.Clear=ClearMenu;
	this.Close=CloseMenu;
	this.Hide=HideMenu;
	this.Show=ShowMenu;	
}

function LoadMenu(){
	var itemLen=this.Items.length;
	var str='';	
	if(itemLen>0){
		str+=this.Head;
		for(var i=0;i<itemLen;i++){
			str+=this.ItemHead;
			str+="<a href=\""+this.Items[i][1]+"\" target=\""+this.Items[i][2]+"\"";
			if(this.ItemClass!='')str+=" class=\""+this.ItemClass+"\"";
			str+=" >"+this.Items[i][0]+"</a>";
			str+=this.ItemFoot;
		}
		str+=this.Foot;
		this.OK=true;
	}else{
		this.OK=false;
	}	
	this.MenuContent=str;
	this.Box.innerHTML=this.MenuContent;
	return this.OK;
}

function CloseMenu(){
	this.Box=null;
	this.FrameBox=null;
	this.Head='';
	this.Foot='';
	this.ItemHead='';
	this.ItemFoot='';
	this.ItemClass='';
	this.Clear();
}
function ClearMenu(){
	this.OK=false;
	this.MenuContent='';
	this.Items=null;
}

function ShowMenu(items,top,left){
	this.Items=items;	
	this.Load();
	if(this.OK){
		if(!top)top=event.y;
		if(!left)left=event.x;
		this.state=1;
		this.Box.style.top=top;
		this.Box.style.left=left;
		this.Box.style.display='';
		var frm=document.getElementById(this.FrameBox);
		if(frm){
			frm.style.top=top;
			frm.style.left=left;
			frm.style.display='';
			frm.style.width=this.Box.clientWidth;
			frm.style.height=this.Box.clientHeight;
		}
	}
}

function HideMenu(){
	this.Clear();
	this.state=1;
	this.Box.style.display='none';	
	var frm=document.getElementById(this.FrameBox);
	if(frm){
		frm.style.display='none';
	}
}


var menu_Timer=null;
function Show_Menu(menuObj,items,x,y){
  if(!eval(menuObj)) return false;
  if(!eval(items)) return false;
  var left=document.body.scrollLeft+event.clientX-event.offsetX;
  var top=document.body.scrollTop+event.clientY-event.offsetY;
  if(x)left+=x;
  if(y)top+=y;
  window.clearTimeout(menu_Timer);
  var obj=eval(menuObj);  
  obj.Show(eval(items),top,left);
}

function Hide_Menu(menuObj){
  if(!eval(menuObj)) return false;
  if(eval(menuObj+".state==1")) menu_Timer=window.setTimeout("Hide_Menu1('"+menuObj+"')",500);
}

function Hide_Menu1(menuObj){
	eval(menuObj+".Hide()");
}

function Lock_Menu(){
  window.clearTimeout(menu_Timer);
} 




