
	var subDivId;//主窗体中用来装入子菜单的容器DIV的ID名
	var iframeId;//主窗体中用来包含菜单页面的iframe名
	
	//正数为加大，负数为减少
	var adjustLeft= 8;//由于计算出来的子menu窗体left值有点偏差，所以设置该left的偏移量
	var adjustTop = 105;
	
	function addSubMenu(divid){
		//用来显示子菜单内容的容器DIV 
		this.subDivId = divid;
		var str="<div id = '"+divid+"' name ='"+divid+"' style=\"z-index:99;position:absolute;top:0px;left:400px;visibility:hidden\" ></div>";
		document.write(str);
	}

	function displayMenu(){
		
		document.getElementById(subDivId).style.visibility="visible";
		
	}

	/**
	* 根据iframe名和此iframe中的组件名来改变"根menu项"的图片
	*/ 
	function changeRootImage(iframeName,id,imagePath){
		var imgObj;
		//alert('changeRootImage');
		if(isIE()){
			imgObj=document.frames[iframeName].document.getElementById(id);//IE
		}

		if(isNS()){
			var iframe = document.getElementById(iframeName);
			imgObj=iframe.contentDocument.getElementById(id);
		}

		imgObj.src=imagePath;
	}

	function changeIcon(id,state){
		//alert('changeIcon');
		var iconObj = document.getElementById(id);
		
		if(state=="show"){
			iconObj.style.visibility='visible';
		}
		if(state=="hidden"){
			iconObj.style.visibility='hidden';
		}

	}
	
	function changeBgColor(id,color){
		//alert('changeBgColor');
		var obj;
		obj = document.getElementById(id);
		obj.style.backgroundColor=color;
	}


	function hiddenMenu(type){
		//alert('hiddenMenu');
		if(type=="parent"){
			parent.document.getElementById(subDivId).style.visibility="hidden";
		}else{
			document.getElementById(subDivId).style.visibility="hidden";
		}
		
	}




	function initMenu(divid,iframeId){
		this.subDivId = divid;
		this.iframeId = iframeId;
	}
		

	function showMenu(left,top,content){
		
		//alert(left+'--'+top);
		var popMenu = parent.document.getElementById(subDivId);
		//alert(popMenu);
		popMenu.innerHTML=content;
		//alert(popMenu.style.left);
		//alert(popMenu.style.top);

		popMenu.style.left=left +"px";
		popMenu.style.top=top+"px";
		popMenu.style.visibility="visible";
		//alert(popMenu.style.left);
		//alert(popMenu.style.top);

		//alert('finish move');
	}

	
	
	
	function cmGetX (obj)
	{
	 if (!obj)
	  return 0;
	 var x = 0;
	
	 do
	 {
	  x += obj.offsetLeft;
	  obj = obj.offsetParent;
	 }
	 while (obj);
	 return x;
	}
	
	
	
	function cmGetY (obj)
	{
	 if (!obj)
	  return 0;
	 var y = 0;
	 do
	 {
	  y += obj.offsetTop;
	  obj = obj.offsetParent;
	 }
	 while (obj);
	 return y;
	}	
	
	 //（iframe中菜单页面调用）根据ID找到相应的菜单项（DIV）对象，由此计算出子菜单的显示位置
	 function popMenu(id,imgId){
		 //alert('popMenu-start');
		var left,top;
		var thisObj =document.getElementById(imgId);
		var pObj = thisObj.offsetParent;
		
		
		if(isIE()){
			var thisObjT = pObj.offsetTop;
			var pObjH = pObj.height;
			top=new Number(thisObjT)+new Number(pObjH);

		//alert('cmGetY(thisObj)-->'+cmGetY(thisObj)+'\n'
			 // +'cmGetY(pObj)-->'+cmGetY(pObj)+'\n'
			  //+'cmGetY(ppObj)-->'+cmGetY(ppObj)+'\n'
			 // +'thisObj.height-->'+thisObj.height+'\n'
			 // +'thisObj.clientTop-->'+thisObj.clientTop+'\n'
		    //  +'thisObj.offsetTop-->'+thisObj.offsetTop+'\n'
			//  +'pObj.height-->'+pObj.height+'\n'
			//  +'pObj.clientTop-->'+pObj.clientTop+'\n'
		    //  +'pObj.offsetTop-->'+pObj.offsetTop+'\n');
			 // +'ppObj.height-->'+ppObj.height+'\n'
			 // +'ppObj.clientTop-->'+ppObj.clientTop+'\n'
		      //+'ppObj.offsetTop-->'+ppObj.offsetTop);


		}
		
		
		if(isNS()){
			//alert('cmGetY(thisObj)-->'+cmGetY(thisObj));
			var thisTop=cmGetY(thisObj);
			top = thisTop + pObj.offsetHeight;
			//alert('top-->'+top);
		}
		
		left =thisObj.offsetWidth+adjustLeft;
		top=top+adjustTop;
		
		var content = getChildContent(id,iframeId);//获得子菜单的完整内容
		
		//alert('top-->'+top);
		//alert('left-->'+left);
		showMenu(left,top,content);
		
	 }
	 
	 function changeImage(id,imagePath){
	 	var imgObj=document.getElementById(id);
	 	imgObj.src=imagePath;
	 }
	 
	
	
	//判断浏览器类型
	function isIE(){
		return (navigator.appName== "Microsoft Internet Explorer");
	}
	function isNS(){
		return (navigator.appName== "Netscape"); 
	}
	
