/* 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 = [
	["Solutions","/solutions/"],
		["|B2B Outsourcing","/solutions/outsourcing/"],
		["|Application Software","/solutions/software/"],
		["|Software as a Service (SaaS)","/solutions/saas.jsp"],
		["|BCM Platform","/solutions/bcm/"],
		["|Managed File Transfer","/solutions/managedfiletransfer/"],
		["|Electronic Data Exchange (EDI)","/capabilities/electronic-data-exchange-edi.jsp"],
		["|B2B Products","/solutions/b2b-products.jsp"],
	["Industries","/industries/"],
		["|Retail","/industries/retail.jsp"],
		["|Technology","/industries/technology-solutions.jsp"],
		["|Financial Services","/industries/financialservices.jsp"],
		["|Transportation","/industries/transportationsolutions.jsp"],
		["|Consumer Packaged Goods","/industries/consumerpackagedgoods.jsp"],
		["|Automotive","/industries/automotive.jsp"],
	["Research & Insight","/downloads/research_insight.jsp"],
		["|Ask the Experts","/experts/"],
		["|Resource Library","/downloads/resources.jsp"],
		["|Success Stories","/news/success.jsp"],
		["|Blog","http://blogs.inovis.com"],
	["Global Partners","/partners/"],
		["|Technology Partners","/partners/technology.jsp"],
		["|Strategic Alliances","/partners/strategic.jsp"],
		["|VAR Partners","/partners/var.jsp"],
		["|Referral Partners","/partners/referral.jsp"],
		["|Consulting Partners","/partners/consulting.jsp"],
		["|Association Partners","/partners/association.jsp"],
	["About Inovis","/about/"],
		["|Company History","/about/company.jsp"],
		["|Management","/about/management.jsp"],
		["|Meet the Team","/about/team.jsp"],
		["|News and Events","/news/"],
			["||Analyst Coverage","/news/analyst.jsp"],		
			["||Press Releases","/news/press/"],
			["||Events","/news/events.jsp"],
			["||Media Kit","/news/presskit.jsp"],
		["|Careers","/about/careers/"],
		["|Locations","/about/locations.jsp"]
]

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);
}

