var mainMenu = new Array;

// Change Code here

mainMenu[0] = new Array;
mainMenu[0][0] = "Products";
	mainMenu[0][1] = "ePrint Professional, /about-ePrint.htm";
	mainMenu[0][2] = "ePrint Terminal Server, /ePrintTerminalServer.html";
	mainMenu[0][3] = "ePrint API, /eprint-OEM-Developer.html";

mainMenu[1] = new Array;
mainMenu[1][0] = "Free Trial, /free-evaluation.htm";
mainMenu[2] = new Array;
mainMenu[2][0] = "Purchase, /purchasing-options.html";
mainMenu[3] = new Array;
mainMenu[3][0] = "Video Demos, /demos/default.html";
mainMenu[4] = new Array;
mainMenu[4][0] = "Software Developers, /eprint-OEM-Developer.html";
mainMenu[5] = new Array;
mainMenu[5][0] = "Support Resources";
mainMenu[5][1] = "Support Home, /e-Support.html";
mainMenu[5][2] = "FAQ, /faq.html";
mainMenu[5][3] = "Forums, http://support.leadtools.com/SupportPortal/cs/forums/26/ShowForum.aspx";
mainMenu[5][4] = "Help Files";
	
	
//  Do not touch

function splitText(textToDivide){
	var text = new Array();
	if (textToDivide.match(",")){					//Checks to see if the entry has a "," to split the listing into urls and tag text
		splitPoint = textToDivide.indexOf(",", 0);	//sets the point in the textString where the comma is located.
		text[0] = textToDivide.substring(0, splitPoint);
		text[1] = textToDivide.substring(splitPoint + 1, textToDivide.length);
	}else{
		text[0] = mainMenu[i][s];
		text[1] = "#";
	}
	return text;
}

var activeHeading;
var activeSelection;

function createMenu(active){
	menuSpace = document.getElementById("menuArea");		//creates the menu element in the variable "menuSpace"
	while(menuSpace.firstChild){menuSpace.removeChild(menuSpace.firstChild);};
	for(i=0; i<mainMenu.length; i++){						//Loop through the main Headings
		for(s=0; s < mainMenu[i].length; s++){				//Loop through the sub Headings
			text = new Array();								//text[0] is the catagory name, text[1] is the link
			text = splitText(mainMenu[i][s]); displayText = text[0]; urlText = text[1];
			if(i == active || s == 0){
				menuCell = document.createElement("a");
				menuSpace.appendChild(menuCell);
				menuCellName = document.createTextNode(displayText);
				menuCell.appendChild(menuCellName);
				if (i == activeHeading && s == activeSelection && s == 0 && i == active){
					menuCell.className = "selectedActiveHeading";
				}if (i == activeHeading && s == activeSelection && s == 0){
					menuCell.className = "selectedHeading";
				}else if (i == activeHeading && s == activeSelection){
					menuCell.className = "selectedItem";
				}else if (s == 0 && i == active){
					menuCell.className = "activeHeading";
					menuCell.href = urlText;
				}else if(s == 0){
					menuCell.className = "heading";
					menuCell.href = urlText;
				}else{
					menuCell.className = "subItem";
					menuCell.href = urlText;
				}
				menuCell.id = "i" + i + "s" + s;

			}
		}
	}
	//This section of the code adds the functionality to the menu items
	menuItems = menuSpace.getElementsByTagName("a");
	for (i=0; i < menuItems.length; i++){
		if(menuItems[i].className == "activeHeading"){
			menuItems[i].onclick = function(){itemClicked(this);}
		}else if(menuItems[i].className == "selectedActiveHeading"){
			menuItems[i].onclick = function(){itemClicked(this);}
			menuItems[i].onmouseover = function(){this.className = "headingHover";}
			menuItems[i].onmouseout = function(){this.className = "selectedActiveHeading"}
		}else if(menuItems[i].className == "selectedHeading"){
			menuItems[i].onclick = function(){itemClicked(this);}
		}else if(menuItems[i].className == "heading"){
			menuItems[i].onmouseover = function(){this.className = "headingHover";}
			menuItems[i].onmouseout = function(){this.className = "heading"}
			menuItems[i].onclick = function(){itemClicked(this);}				
		}else if(menuItems[i].className == "subItem"){
			menuItems[i].onmouseover = function(){this.className = "subItemHover";}
			menuItems[i].onmouseout = function(){this.className = "subItem"}
			menuItems[i].onclick = function(){itemClicked(this);}				
		}
	}
					//menuCell.className = "heading";
					//divTag += 'onmouseover="this.className=\'headingHover\'" ';
					//divTag += 'onmouseout="this.className=\'heading\'" ';
					
				//divTag += 'onclick="rebuildTable(' + i + ')" ';
				//divTag += 'href="' + urlText + '"';
				//divTag += '>';
				//divTag += displayText;
				//divTag += '</a>\r';
}
function itemClicked(menuItem){
		var splitText = menuItem.id;
		var splitPoint = splitText.indexOf("s", 0);
		var i = splitText.substring(1, splitPoint);
		var s = splitText.substring(splitPoint + 1, splitText.length);
		if(s == 0){
			createMenu(i);
		}
}
function rebuildTable(i){
	createMenu(i);
}

function setMenu(i, s){
	activeHeading = i;
	activeSelection = s;
	createMenu(i);
}