/*
Menus are created with an array for each.
The first 3 elements are the name+level, the name and the width for the menu
The next 6 are:
The URL
The Link Text
The Prefix that preceeds all menus in the same family
The Level which is how far down the tree a menu is starting with 0 for the parent
Blankwindow which should be an 'x' if you want the link to open in a new window

They are in the following order:
url,text,prefix,childMenu,level,blankWindow
*/

//temporary storage space for each menu item
var menuListHolder = new Array();
var linkClicked = false;

function findURL(cell){
	if(!linkClicked){
		URL = cell.childNodes[0].href
		URLTarget = cell.childNodes[0].target
		if(URLTarget==""){
			location.href = URL;
		}else{
			window.open(URL);
		}
	}
	linkClicked = false;
}

//Writes the menus to the page
for(i=0;i<menuList.length;i++){
	menusArray.push(menuList[i].shift());
	divWriter = "<div id=\"" + menuList[i].shift() + "\" class=\"addItemItems\" style=\"width:"+ menuList[i].shift() +"px;\">";
	tempLength = menuList[i].length/6;
	for(n=0;n<tempLength;n++){
		menuListHolder = menuList[i].splice(0,6);
			divWriter = divWriter + "<div id=\"itemMenuItem\" onMouseOver=\"showMenu(this,'";
			if(menuListHolder[3] != ""){
				divWriter = divWriter + "show";
			}else{
				divWriter = divWriter + "hold";
			}
			divWriter = divWriter + "','";
			if(menuListHolder[3] != ""){
				divWriter = divWriter + menuListHolder[3]
			}
				divWriter = divWriter + "','" + menuListHolder[4];
				divWriter = divWriter + "','" + menuListHolder[2] + "'"; 
			
			divWriter = divWriter + ")\" onMouseOut=\"showMenu(this,'hide')\"><div id=\"itemSpace\">";
			divWriter = divWriter + "<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td align=left nowrap onClick=\"findURL(this)\">";		
			divWriter = divWriter + "<a onClick=\"linkClicked=true;\" href=\""+menuListHolder[0]+"\"";
			if(menuListHolder[5] != ""){
				divWriter = divWriter + " target=\"_blank\"";
			}
			divWriter = divWriter + ">"+menuListHolder[1]+"</a></td><td align=right>";
			if(menuListHolder[3] != ""){
				divWriter = divWriter + "<img src=\"/global/css/images/menu_arrow.gif\" width=\"7\" height=\"15\" border=\"0\">";
			}
			divWriter = divWriter + "</td></tr></table></div></div>";
	}
	divWriter = divWriter + "</div>";
	document.write(divWriter);
}
