	// JavaScript Document

	    function $_getID(id)
	    {
		    return document.getElementById(id);
	    }
		//读取xml文件类;
		var LoadXMLFile = function(){
			var dom;
			if(navigator.userAgent.indexOf("MSIE") > 0){
				dom = new ActiveXObject("Microsoft.XMLDOM");
				dom.async = false;
				dom.load("Handlelist.xml");
			}
			else if(isFirefox = navigator.userAgent.indexOf("Firefox") > 0){
				dom = document.implementation.createDocument("","",null);
				dom.async = false;
				dom.load("Handlelist.xml");
			}
			return dom;
		}
		
		//用于FF获取当前节点的文本内容函数;//兼容ff;
		function getText(oNode) {
			var sText = "";
			for (var i = 0; i < oNode.childNodes.length; i++) {
			   if (oNode.childNodes[i].hasChildNodes()) {
				   sText += getText(oNode.childNodes[i]);
			   } else {
				   sText += oNode.childNodes[i].nodeValue;
			   }
			}
			return sText;
		}
		function FrameRedirect(frameId, url)
		{
		    if (($_getID(frameId) != null) && (url != "#") && (url.length > 0))
		    {
		        window.frames[frameId].location.href = url;
		    }
		}
		//构建表格及填充表格类;
		var createtable = function(HandleNode){
			//HandleNode 为xml文档对象.
			var otable = document.createElement("table");
			var otablebody = document.createElement("tbody");
			otable.setAttribute("id","tree_menu");
			otable.setAttribute("cellSpacing","0");
			otable.setAttribute("cellPadding","0");
			otable.setAttribute("width","100%");
			otable.setAttribute("border","0");
			for (var b=0;b<HandleNode.length;b++){
				for (var a=0;a<HandleNode[b].childNodes.length;a++){
					var otableRow = document.createElement("tr");
					var otableCell = document.createElement("td");
					otableCell.setAttribute("class","treeview_unfocus");
					if(document.all){otableCell.setAttribute("className","treeview_unfocus");}
					if (a==0){
						if(document.all){otableCell.setAttribute("className","treeview_unfocus2");}else{otableCell.setAttribute("class","treeview_unfocus2");}
					}
					//alert(HandleNode[b].childNodes[a].childNodes.length);
					if(HandleNode[b].childNodes[a].childNodes.length != 0 || (navigator.userAgent.indexOf("MSIE") > 0))//兼容ff;
					{
						if (HandleNode[b].childNodes[a].getAttribute("url").toString() != ""){
							otableCell.innerHTML = "<img src=\"" + HandleNode[b].childNodes[a].getAttribute("icon").toString() + "\">" + "&nbsp;" + "<a onclick=\"FrameRedirect(\'Main\', \'" +  HandleNode[b].childNodes[a].getAttribute("url").toString() + "\');\" href=\"#\">" + HandleNode[b].childNodes[a].getAttribute("textnode").toString() + "<\/a>";
						}else{
							otableCell.innerHTML = "<img src=\"" + HandleNode[b].childNodes[a].getAttribute("icon").toString() + "\">" + "&nbsp;" + HandleNode[b].childNodes[a].getAttribute("textnode").toString();
						}
						otableCell.setAttribute("id","tree_menu" + (HandleNode[b].childNodes.length+1));
						otableRow.appendChild(otableCell);
						otablebody.appendChild(otableRow);

						if(HandleNode[b].childNodes[a].childNodes.length != 0){
								var otableRow2 = document.createElement("tr");
								var otableCell2 = document.createElement("td");
								var createDiv = document.createElement("div");
								var createUl = document.createElement("ul");
								for(var c=0;c<HandleNode[b].childNodes[a].childNodes.length;c++){
								if(getText(HandleNode[b].childNodes[a].childNodes[c]) != ""){ //兼容ff;
									var createLi = document.createElement("li");
									if(document.all){createDiv.setAttribute("className","BasicinfoShow");}else{createDiv.setAttribute("class","BasicinfoShow");}
									if(HandleNode[b].childNodes[a].childNodes[c].childNodes.length !=0){
										createLi.innerHTML = "<a onclick=\"FrameRedirect(\'Main\', \'" + HandleNode[b].childNodes[a].childNodes[c].getAttribute("url").toString() + "\');\" href=\"#\"><img src=\"" + HandleNode[b].childNodes[a].childNodes[c].getAttribute("icon").toString() + "\">" + getText(HandleNode[b].childNodes[a].childNodes[c]) + "<\/a>"
										createDiv.setAttribute("id","menulist" + (c+1));
									}
									createLi.onclick = function(){thisMenuStyleChange('tree_menu',this);};
									createUl.appendChild(createLi);
									createDiv.appendChild(createUl);
									otableCell2.appendChild(createDiv);
									otableRow2.appendChild(otableCell2);
									otablebody.appendChild(otableRow2);
								}
							}
						}
					}
				}
			}
			otable.appendChild(otablebody);
			return otable;
		}
		
		//构建子菜单项及填充类;
		function SelectMenu(menuItem, subMenuId)
        {
			if($_getID("leftList").style.display == 'none') $_getID("leftList").style.display = '';
			//判断是否已经实例化了LoadXMLFile类;
			if(typeof(XMLDom) == 'undefined'){
			try{
				var XMLDom = new LoadXMLFile();
			}catch (e){
				alert(e.message);}
			}
			//alert(subMenuId);
			var HandleNode = XMLDom.getElementsByTagName(subMenuId);
			try{
				var createMenuListTable = new createtable(HandleNode); //实例化creattable类;
				document.getElementById("LeftMenuList").innerHTML = "";
				document.getElementById("LeftMenuList").appendChild(createMenuListTable); //添加动态生成的table节点到leftMenulist下面;
			}catch (e){
				alert(e.message);
            }
            switch (parseInt(subMenuId.substr(7))) {
			    case 1:
			        FrameRedirect('Main', 'shop/SiteContent.aspx');
			        break;
			    case 2:
			        FrameRedirect('Main', 'productcatalog/ProductOnSales.aspx');
			        break;
			    case 3:
			        FrameRedirect('Main', 'Membership/ManageMembers.aspx');
			        break;
			    case 4:
			        FrameRedirect('Main', 'sales/ManageOrder.aspx');
			        break;
			    case 5:
			        FrameRedirect('Main', 'promote/EngagedPromoteSales.aspx');
			        break;
			    case 6:
			        FrameRedirect('Main', 'shop/AfficheList.aspx');
			        break;
			    case 7:
			        FrameRedirect('Main', 'Membership/ManageLeaveComments.aspx');
			        break;
			    case 8:
			        FrameRedirect('Main', 'shop/EmailToUser.aspx');
			        break;
			    case 9:
			        FrameRedirect('Main', 'sales/SaleTotalStatistics.aspx');
			        break;
			}
			//alert(subMenuId);
            if ($_getID("txtSelectedMenuId").value == menuItem.id)
                return;
            menuItem.className = "Current";
//            for(i = 0;i<$_getID("SubMenu").childNodes.length;i++)
//            {
//                $_getID("SubMenu").childNodes[i].className = "submenuLayerHide";
//            }
//            $_getID(subMenuId).className = "submenuLayerShow";
            
            if ($_getID("txtSelectedMenuId").value.length > 0)
                $_getID($_getID("txtSelectedMenuId").value).className = "";
            $_getID("txtSelectedMenuId").value = menuItem.id;
        }
        
        function MouseOver(menuItem)
        {
            if ($_getID("txtSelectedMenuId").value == menuItem.id)
                return;
            menuItem.className = "hover";
           // menuItem.childNodes[0].className = "hoverspan";
        }
        
        function MouseOut(menuItem)
        {
            if ($_getID("txtSelectedMenuId").value == menuItem.id)
                return;
            menuItem.className = "";
            //menuItem.childNodes[0].className = "";
        }
        
        function SubmenuMouseOver(menuItem, subMenuId)
        {
            menuItem.className = "hover";
            if (subMenuId == '')
                return;
            var subMenu = $_getID(subMenuId);
            if (subMenu == null)
                return;
            var offsetTop = menuItem.offsetTop; 
            var offsetLeft = menuItem.offsetLeft; 
            var offsetWidth = menuItem.offsetWidth; 
            var offsetHeight = menuItem.offsetHeight; 
            while( menuItem = menuItem.offsetParent ) 
            { 
                offsetTop += menuItem.offsetTop; 
                offsetLeft += menuItem.offsetLeft; 
            }
            
            subMenu.style.left = offsetLeft + "px";
            subMenu.style.top = (offsetTop + offsetHeight - 3) + "px";
            subMenu.className = "porcelain2show"; 
        }
        
        function SubmenuMouseOut(menuItem)
        {
            menuItem.className = "";
        }

		function leftList(thisID,thisImgID)
		{
			thisID = $_getID(thisID);
			// thisImgID = $_getID(thisImgID);
			if (thisID.style.display == 'none')
			{
				thisID.style.display = '';
				//thisImgID.src = "../images/splitbar_collapse_h.gif";
				//$_getID("top_001").style.display = '';
				//$_getID("top_002").style.display = '';
			}
			else
			{
				thisID.style.display = 'none';
				//$_getID("top_001").style.display = 'none';
				//$_getID("top_002").style.display = 'none';
				//thisImgID.src = "../images/splitbar_expand_h.gif";
			}
		}
		
		function callLeftTree(obj,submenuSum)
		{
			var submenuSumLayer = $_getID(submenuSum);
			if (submenuSumLayer.className == 'BasicinfoHide')
			{
				submenuSumList =$_getID('tree').getElementsByTagName('div').length + 1;
				submenuSumLayer.className = 'BasicinfoShow';
				for (i=1;i<submenuSumList ;i++ )
				{	
					var submenuSumthis = 'MenuList_' + i;
					if (submenuSum != submenuSumthis)
					{
						var submenuSumthis = $_getID(submenuSumthis);
						submenuSumthis.className = 'BasicinfoHide';
					}
				}
			}
			//Sub menu background change;
			var subMainMenuList = $_getID('tree_menu').getElementsByTagName('td').length + 1;
			var subMenuTD = $_getID(obj);
			subMenuTD.className = 'treeview_focus';
			for (i=1;i<subMainMenuList ;i++ )
			{	
				var submenuTDthis = 'tree_menu' + i;
				if (subMenuTD.id != submenuTDthis)
				{
					var submenuTDthis = $_getID(submenuTDthis);
					submenuTDthis.className = 'treeview_unfocus';
				}
			}
		}

		function thisMenuStyleChange(menuID,thisID)
		{
			var menuID = $_getID(menuID);
			//alert(menuID);
			
			var menuList = menuID.getElementsByTagName('li').length;
			var testList = menuID.getElementsByTagName('li');
			for (i=0;i<menuList ;i++ )
			{	
				testList[i].className = '';
			}
			thisID.className = 'selectThisItemsStyle';
		}
		
		//换肤.
        function SetCookie(name,value)//两个参数，一个是cookie的名子，一个是值
        {
            var Days = 30; //此 cookie 将被保存 30 天
            var exp  = new Date();    //new Date("December 31, 9998");
            exp.setTime(exp.getTime() + Days*24*60*60*1000);
            document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
        }
        function getCookie(name)//取cookies函数        
        {
            var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
             if(arr != null) return unescape(arr[2]); 
             return null;
        }

        //处理onload事件;
//        window.onload = function MyMoodClassOnload()
//        {
//                alert(getCookie("HishopAdminCookie"));
//                if (getCookie("HishopAdminCookie") == "")
//                {
//                    SetCookie("HishopAdminCookie","Blue");
//                    $_getID("cssLink").href = "css/IFrame.css";
//                    return;
//                }
//                $_getID("cssLink").href = "css/IFrame_" + getCookie("HishopAdminCookie") + ".css";
//        }
        function MyMoodClass(thisMood)
        {
                if (thisMood.toString() == "Blue")
                {
                    $_getID("cssLink").href = "css/IFrame.css";
                    //SetCookie("HishopAdminCookie",thisMood);
                    return;
                }
                //SetCookie("HishopAdminCookie",thisMood);
                //alert(getCookie("HishopAdminCookie"));
                $_getID("cssLink").href = "css/IFrame_" + thisMood.toString() + ".css";
        }
        //处理加载导航菜单内容
//        window.onload = function() {
//            var nav_menu = $_getID("SubMenu");
//            nav_menu.innerHTML = "<div style=\"padding-left:10px;\"><a href=\"test\">aaaaa<\/a></div>";
//        }