﻿/* String variables to write the menus */
var menuBarStart = "<div id='menuBar'><ul id='navMain' class='menu'> ";
var menuBarEnd = "</li></ul></div>";
var stMenuBar = "";

/* EDIT MENU HERE */
/* Use pipe to indicate hierarchy */
var menuItems = [
	["EDI 电子商务产品","/solutions/edi.jsp"],
	["||EDI 数据交换软件","/solutions/edi-software.jsp"],
	["||增值网络","/solutions/value-added-network.jsp"],
	["||管理式服务","/solutions/managed-services.jsp"],
	["操控智能","/solutions/actionable-intelligence.jsp"],
	["数据质量","/solutions/data-quality.jsp"],
	["安全文件传输","/solutions/secure-file-transfer.jsp"],
	["关于 Inovis","/about/"],
		["| 联系我们","/contact/"],
		["| 客户入口","/support/"],
		["|全球位置","http://www.inovis.com/about/locations.jsp"],
		["|客户门户","http://customer.inovis.com/"]
]

initNavSubs = function() {
	var navList = document.getElementById("navMain").getElementsByTagName("LI");
	for (var i=0; i<navList.length; i++) {/* assign white arrow class to indicate sub menu except for top items */			
		navList[i].onmouseover=function(){this.className+=" itemHover";}
		navList[i].onmouseout=function(){this.className=this.className.replace(new RegExp(" itemHover\\b"), "");}
	}	
}
if (window.attachEvent) window.attachEvent("onload", initNavSubs);
window.onload = function(){
	var navList = document.getElementById("navMain").getElementsByTagName("LI");
	for (var i=0; i<navList.length; i++) {/* assign white arrow class to indicate sub menu except for top items */
		if(navList[i].childNodes[0].nextSibling != null && navList[i].childNodes[0].nextSibling.tagName == "UL" && navList[i].parentNode.id != "navMain" ){
			navList[i].className+="expand";
		}
	}
}
var previousItemLevel = null;
function writeMenus(){/* parse + process/convert menu array into HTML */
	for(i=0; i<menuItems.length; i++){
		var itemUrl = menuItems[i][1];
		var itemTitle = menuItems[i][0];	
		currentItem =  menuItems[i].toString();
		currentItemLevel = currentItem.substring(0,3);
		currentItemLevel = currentItemLevel.lastIndexOf("|")+1; 
		itemTitle = itemTitle.substring(currentItemLevel);
		if(currentItemLevel == 0 && currentItemLevel != previousItemLevel){ /* process top items */
			if(currentItemLevel == previousItemLevel){
				stMenuBar += "</li><li><a href='" + itemUrl + "'>" + itemTitle + "</a>";			
			}else if(currentItemLevel < previousItemLevel){				
				stMenuBar +=  "</li></ul></li><li><a href='" + itemUrl + "'>" + itemTitle + "</a>";				
			}else if(currentItemLevel != previousItemLevel){
				stMenuBar +=  "<li><a href='" + itemUrl + "'>" + itemTitle + "</a>";
			}		
		}else{ /* process sub hovered menus */
			if(currentItemLevel== previousItemLevel){				
				stMenuBar += "</li><li><a href='" + itemUrl + "'>" + itemTitle + "</a>";	
			}else if(currentItemLevel < previousItemLevel){
				stMenuBar +=  "</li></ul></li><li><a href='" + itemUrl + "'>" + itemTitle + "</a>";				
			}else if(currentItemLevel > previousItemLevel){
				stMenuBar +=  "<ul><li><a href='" + itemUrl + "'>" + itemTitle + "</a>";
			}				
		}
		previousItemLevel = currentItemLevel;
	}
	stMenuBar = menuBarStart + stMenuBar + menuBarEnd;
	document.write(stMenuBar);
}



