//global vars for menu creation....
	var itemLevel = 0; var itemCount = 0;
//global vars for menu navigation....
	var whoAmI = 0; whoAmIMotherLast = -1;
//collection menuitems....
	var menuItems = [];
//menu style,animation and dimension settings....
	var xLeft = 4; var yTop=78; var xWidthTop=111; var xWidthChild=161; var yHeight=25; var horizMenu=true; var horizStripe=true;
	var snapOnDelay=100; var snapOffDelay=75; var displayAsRead = false; var addIndentCarat=false;

function readStructure (data_items) {//main kickoff routine...

	//mozilla hacks for cross browser validity see http://webdesign.about.com/cs/css/a/aaboxmodelhack.htm
	yHeightSpec = yHeight;
	xWidthChildSpec = xWidthChild;
	xWidthTopSpec = xWidthTop;
	xTraIEWid =6;
	var nav4 = window.Event ? true : false;
	if (nav4) { yHeight = yHeight-10; xWidthTop = xWidthTop-10; xWidthChild = xWidthChild -10; xTraIEWid=0; xLeft = xLeft-4;}//subtract padding for mozilla (4 + 4 + 2 for IE error)
	// 	run main menu items thru our parser to get menu tree structure
	for (n_order = 0; n_order < data_items.length; n_order++) {
		readMenuData(data_items[n_order]);
		itemLevel=0;
	}

	var mi0=0; var mi1=0; var mi2=0;
	//after reading them, write them back as a menu tree to the web browser window
    for(var mi in menuItems)  {   // Loop through the children and build the menus....
			prePend = "";
		for (i=0;i<menuItems[mi].mLevel;i++) prePend += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
			//if(displayAsRead) document.write(prePend + menuItems[mi].serNo + '-' + menuItems[mi].mLevel + '-' + menuItems[mi].mText + '-' + menuItems[mi].mURL + '-' + menuItems[mi].mParent + '<br>');
			if(displayAsRead) {
				if(menuItems[mi].mLevel==0) document.write('<br>');
				if (menuItems[mi].mURL!=null) {
					document.write('<span class="body12pt">' + prePend + '<a href="' + menuItems[mi].mURL + '">' + menuItems[mi].mText + '</a></span><br>');
				} else {
					document.write('<span class="body12pt">' + prePend + menuItems[mi].mText + '</span><br>');
				}
			}
		if (horizMenu) {	
			if (menuItems[mi].mLevel==0){
				itemHTML = '<div id="di' + menuItems[mi].serNo + '" class="mOff" onmousedown="goHere(' + menuItems[mi].serNo + ');" onmouseout="mouseOutMI(' + menuItems[mi].serNo +
				');" onmouseover="mouseOverMI(' + menuItems[mi].serNo + ');"  style="cursor: pointer; cursor:hand; position: absolute; top: ' + yTop + 'px; left:' 
				+ (xLeft+(mi0 * (xWidthTop-1))) + 'px;  width: ' + xWidthTop + 'px; height: ' + yHeight + 'px; visibility: visible; z-index: 0;">' + menuItems[mi].mText + '</div>';
				document.write(itemHTML);
				mi0++;
				mi1=0;
			} else if(menuItems[mi].mLevel==1) {
				if (menuItems[mi].hasChildren && addIndentCarat) { addIndent='>'; } else { addIndent='';  }
				itemHTML = '<div id="di' + menuItems[mi].serNo + '" class="mOff" onmousedown="goHere(' + menuItems[mi].serNo + ');" onmouseout="mouseOutMI(' + menuItems[mi].serNo +
				');" onmouseover="mouseOverMI(' + menuItems[mi].serNo + ');"  style="cursor: pointer; cursor:hand; position: absolute; top: ' + (yTop + (yHeightSpec - 1) + (mi1*(yHeightSpec - 1))) + 'px; left: ' 
				+ (xLeft+((mi0-1) * (xWidthTop-1))) + 'px;  width: ' + xWidthChild + 'px; height: ' + yHeight + 'px; visibility: hidden; z-index: 0;">' + addIndent + menuItems[mi].mText + '</div>';
				document.write(itemHTML);
				mi1++;
				mi2=mi1-1;
			} else if(menuItems[mi].mLevel==2) {
				itemHTML = '<div id="di' + menuItems[mi].serNo + '" class="mOff" onmousedown="goHere(' + menuItems[mi].serNo + ');" onmouseout="mouseOutMI(' + menuItems[mi].serNo +
				');" onmouseover="mouseOverMI(' + menuItems[mi].serNo + ');"  style="cursor: pointer; cursor:hand; position: absolute; top: ' + + (yTop + (yHeightSpec - 1) + (mi2*(yHeightSpec - 1))) + 'px; left: ' 
				+ (xLeft + ((mi0-1) * (xWidthTop-1)) + xWidthChildSpec - 1) + 'px;  width: ' + xWidthChild + 'px; height: ' + yHeight + 'px; visibility: hidden; z-index: 0;">' + menuItems[mi].mText + '</div>';
				document.write(itemHTML);
				mi2++;
			}
		} else {
			if (menuItems[mi].mLevel==0){
				itemHTML = '<div id="di' + menuItems[mi].serNo + '" class="mOff" onmousedown="goHere(' + menuItems[mi].serNo + ');" onmouseout="mouseOutMI(' + menuItems[mi].serNo +
				');" onmouseover="mouseOverMI(' + menuItems[mi].serNo + ');"  style="cursor: pointer; cursor:hand; position: absolute; top: ' + (yTop+(mi0 * (yHeightSpec-1))) + 'px; left:' 
				+ xLeft + 'px;  width: ' + xWidthTop + 'px; height: ' + yHeight + 'px; visibility: visible; z-index: 0;">' + menuItems[mi].mText + '</div>';
				document.write(itemHTML);
				mi0++;
				mi1=0;
			} else if(menuItems[mi].mLevel==1) {
				if (menuItems[mi].hasChildren) { addIndent='> '; } else { addIndent='';  }
				itemHTML = '<div id="di' + menuItems[mi].serNo + '" class="mOff" onmousedown="goHere(' + menuItems[mi].serNo + ');" onmouseout="mouseOutMI(' + menuItems[mi].serNo +
				');" onmouseover="mouseOverMI(' + menuItems[mi].serNo + ');"  style="cursor: pointer; cursor:hand; position: absolute; top: ' + (yTop + (mi1 + mi0 -1)*(yHeightSpec - 1)) + 'px; left: ' 
				+ (xLeft + xWidthTopSpec - 1) + 'px;  width: ' + xWidthChild + 'px; height: ' + yHeight + 'px; visibility: hidden; z-index: 0;">' + addIndent + menuItems[mi].mText + '</div>';
				document.write(itemHTML);
				mi1++;
				mi2=mi1-1;
			} else if(menuItems[mi].mLevel==2) {
				itemHTML = '<div id="di' + menuItems[mi].serNo + '" class="mOff" onmousedown="goHere(' + menuItems[mi].serNo + ');" onmouseout="mouseOutMI(' + menuItems[mi].serNo +
				');" onmouseover="mouseOverMI(' + menuItems[mi].serNo + ');"  style="cursor: pointer; cursor:hand; position: absolute; top: ' + (yTop + mi2*(yHeightSpec - 1)) + 'px; left: ' 
				+ (xLeft + xWidthTopSpec + xWidthChildSpec - 2) + 'px;  width: ' + xWidthChild + 'px; height: ' + yHeight + 'px; visibility: hidden; z-index: 0;">' + menuItems[mi].mText + '</div>';
				document.write(itemHTML);
				mi2++;
			}
		}
	}
				if (horizMenu && horizStripe) document.write('<div class="mOff" style="position: absolute; top: ' + yTop + 'px; left:' + (xLeft+(mi0 * (xWidthTop-1))) + 'px;  width:' + (xTraIEWid + document.body.clientWidth-(xLeft+(mi0 * (xWidthTop-1)))-10) + 'px; height: ' + yHeight + 'px; visibility: visible; z-index: 0;"></div>');
}

function readMenuData(dataItem) {
	if (typeof(dataItem) == 'object'){
		for (var i=0; i<dataItem.length; i++){ //note, don't leave out the var here!!! You'll curse and not recurse....
			if (dataItem[i]==null){  //handle null values at node ends....
					itemCount++;
					if (itemCount%2==0) menuItems[itemCount-1] = new menuItem(itemCount/2,dataItem[i-1],dataItem[i],itemLevel);
			} else {
				if (typeof(dataItem[i]) == 'object'){//not at the end of a node
					itemLevel++;
					readMenuData(dataItem[i]);		 // this it the recursion
				} else {							 //node end
						itemCount++;
						if (itemCount%2==0)menuItems[itemCount-1] = new menuItem(itemCount/2,dataItem[i-1],dataItem[i],itemLevel);
				}
			}
				if (i == dataItem.length - 1) itemLevel--;
		}
	} else {  //should never be here, error in input data structure...
		alert ('Error in input data structure, not an object found... "' + dataItem + '"');
	}
}

//menu item object
function menuItem(serNo,mText,mURL,mLevel) {
	this.serNo = serNo;
	this.mText = mText;
	this.mURL = mURL;
	this.mLevel = mLevel;
	this.mParent = whosYourMother(mLevel-1);
	this.hasChildren = false;  //keep track of children for expansion arrows
}

function whosYourMother(mLevel) {
	var mother = 0; var mamaMI = null;
    for(var mi in menuItems)  {   // Loop through all items to find mama
		if(menuItems[mi].mLevel==mLevel) {
			mother = menuItems[mi].serNo; 
			mamaMI = menuItems[mi];
		}
    }
	if (mother>0) mamaMI.hasChildren = true;
	return mother;
}

function mouseOverMI(miSerNo) {
	whoAmI = miSerNo;
	document.getElementById('di' + miSerNo).className = 'mOn';
	for(var mi in menuItems)  {//find whoAmI in collection and get level
		if (menuItems[mi].serNo == whoAmI) whoAmILevel = menuItems[mi].mLevel;
	}
		i = 0;
	for(var mi in menuItems)  { //unlight and hide all nodes of higher level then whoAmILevel (necessary for odd fast mousing)
		if(menuItems[mi].mLevel>whoAmILevel) {
			if (whoAmIMotherLast!=menuItems[mi].mParent){ //only nodes hide the children is not getting...
				document.getElementById('di' + menuItems[mi].serNo).style.visibility = 'hidden';
				document.getElementById('di' + menuItems[mi].serNo).className = 'mOff';
			}
		}
    }
		i = 0;
	for(var mi in menuItems)  { //explicitly light the children only
		if(menuItems[mi].mParent==miSerNo) {
			i++;
			if (snapOnDelay>0) { //building ladder effect
				lmiSerNo = menuItems[mi].serNo + 2000;
				lmiSerNo = window.setTimeout('lightMe(' + menuItems[mi].serNo + ');',i*snapOnDelay);
			} else { //snap on...
				document.getElementById('di' + menuItems[mi].serNo).style.visibility = 'visible';
				document.getElementById('di' + menuItems[mi].serNo).className = 'mOff';
			}
		}
    }
}

function unLightMe(miSerNo) {	
	document.getElementById('di' + miSerNo).style.visibility = 'hidden';
	document.getElementById('di' + miSerNo).className = 'mOff';
}

function lightMe(miSerNo) {	
		whoAmIMother=0;
	for(var mi in menuItems)  {//find whoAmI in collection and get level
		if (menuItems[mi].serNo == miSerNo) miSerNoMother = menuItems[mi].mParent;
		if (menuItems[mi].serNo == whoAmI) whoAmIMother = menuItems[mi].mParent;
	}
	if (whoAmI==miSerNoMother || whoAmIMother==miSerNoMother){ //only light if still over parent or sibling....
		document.getElementById('di' + miSerNo).style.visibility = 'visible';
		document.getElementById('di' + miSerNo).className = 'mOff';
	}
}

function mouseOutMI(miSerNo) {
	whoAmIMotherLast = miSerNo;
	whoAmI = -1;
	document.getElementById('di' + miSerNo).className = 'mOff';
	//hide the children, unless going to a child
	miSerNo = window.setTimeout('hideTheChildren(' + miSerNo + ');',200);
}

function hideTheChildren(miSerNo) {
	var level = 0; var whoAmIParent=-1;
	//is miSerNo (node you just left) a child of whoAmI (node you are on) 
	//for children miSerNo is the parent  //first determine whoAmIParent
	for(var mi in menuItems)  {
		if(menuItems[mi].serNo==whoAmI) whoAmIParent = menuItems[mi].mParent;
    }
					var i = 0;
	if (miSerNo!=whoAmIParent) {  //boom boom out go the lights??
		for(var mi in menuItems)  {   // Loop through all items to find children and hide them
			if(menuItems[mi].mParent==miSerNo) {
				if (snapOffDelay>0 && whoAmIMotherLast==menuItems[mi].mParent){
					i++;
					lmiSerNo = menuItems[mi].serNo + 1000;
					lmiSerNo = window.setTimeout('unLightMe(' + menuItems[mi].serNo + ');',i*snapOffDelay);
				} else {
					document.getElementById('di' + menuItems[mi].serNo).style.visibility = 'hidden';
					document.getElementById('di' + menuItems[mi].serNo).className = 'mOff';
				}
			}
		}
		if (whoAmI<0) leftTheMenus();
	}
}

function goHere(miSerNo){
	document.getElementById('di' + miSerNo).className = 'mPress';
	miSerNo = window.setTimeout('goNow(' + miSerNo + ');',200);
}

function goNow(miSerNo){
	for(var mi in menuItems)  {//find whoAmI in collection and get url
		if (menuItems[mi].serNo == miSerNo) tarURL = menuItems[mi].mURL;
	}
	if(tarURL==null) {
		document.getElementById('di' + miSerNo).className = 'mOn';
	} else {
		document.location = tarURL;
	}
}

function leftTheMenus() {
	for(var mi in menuItems)  {   // Loop through all items to find children and hide them
		if(menuItems[mi].mParent>0) {
			document.getElementById('di' + menuItems[mi].serNo).style.visibility = 'hidden';
			document.getElementById('di' + menuItems[mi].serNo).className = 'mOff';
		}
	}
}