function getLastChildElementh(parentdiv){ //returns the last child element of parentdiv
	cc=parentdiv.childNodes.length-1 //counter set to the index of the last child node in parentdiv 
	while (cc>=0){ //while child nodes still remain
		if (parentdiv.childNodes[cc].nodeType==1){ //if current child node is an element
			return parentdiv.childNodes[cc] //return the current child node
		}
		else{
			cc-- //count down
		}
		
	}
}

function getFirstChildElementh(parentdiv){ //returns the last child element of parentdiv
	cc=0 //counter set to the index of the first child node in parentdiv 
	while (cc<parentdiv.childNodes.length){ //while child nodes still remain
		if (parentdiv.childNodes[cc].nodeType==1){ //if current child node is an element
			return parentdiv.childNodes[cc] //return the current child node
		}
		else{
			cc++ //count up
		}
		
	}
}

function showItemsh(menuitem){ //shows the sub menu (if it exists)
	if (getLastChildElementh(menuitem).tagName=="DIV"){ // if last child element is a div, ie menuitem has a sub menu
		getLastChildElementh(menuitem).style.visibility = "visible" //show the sub menu
	}
	else{
	getFirstChildElementh(menuitem).style.color="#bd2000" //change the color of the menuitem's first child (A tag) text so that some rollover effect happens
	}
}
function hideItemsh(menuitem,ent){ //hides the sub menu
	if (ent.toElement || ent.relatedTarget){ //if toelement or relatedtarget is supported
		if (ent.toElement){ //if IE or Opera
			if (ent.toElement.parentNode.className!="item" && ent.toElement.parentNode.className!="item" && ent.toElement.parentNode.className!="side" && ent.toElement!=menuitem && ent.toElement.className!="side"){ //if mouse is over a menu item
				if (getLastChildElementh(menuitem).tagName=="DIV"){ //if menuitem has a sub menu
					getLastChildElementh(menuitem).style.visibility = "hidden" //hide children
				}
				else{
					getFirstChildElementh(menuitem).style.color="#ffffff" //change the color of the link back (rollout) 
				}
			}
		}
		else if (ent.relatedTarget){ //NN and FF
			if (ent.relatedTarget.parentNode.className!="item" && ent.relatedTarget.parentNode.className!="item" && ent.relatedTarget.parentNode.className!="side" && ent.relatedTarget!=menuitem && ent.relatedTarget.className!="side"){ //if mouse is over a menu item
				if (getLastChildElementh(menuitem).tagName=="DIV"){ //if menuitem has a sub menu
					getLastChildElementh(menuitem).style.visibility = "hidden" //hide children
				}
				else{
					getFirstChildElementh(menuitem).style.color="#ffffff" //change the color of the link back (rollout)
				}
			}
		}
	}
	else {
		hideItemsOldh(menuitem) //run original version of this function which causes flickering in FF and NN
	}
}

function hideItemsOldh(menuitem){ //essentially the same as hideItems only this may cause flickering in FF and NN
if (getLastChildElementh(menuitem).tagName=="DIV"){ // if last child element is a div, ie menuitem  has a sub menu
getLastChildElementh(menuitem).style.visibility = "hidden" //hide sub menu
}
else {
	getFirstChildElementh(menuitem).style.color="#ffffff" //change the color of the link back (rollout)
}
}

function itemHighlightOnh(item){ //changes color of side menu item background and text when mouse goes over
if (getFirstChildElementh(item).tagName=="A"){ //if item has a link child
getFirstChildElementh(item).style.color="#0000ff" //change color of link text as this overrides normal text
}
item.style.backgroundColor="#F0E696" //change background color of item
}
function itemHighlightOffh(item){ //changes color of side menu item background and text when mouse goes over
if (getFirstChildElementh(item).tagName=="A"){ //if item has a link child
getFirstChildElementh(item).style.color="#ff0000" //change color of link text as this overrides normal text
}
item.style.backgroundColor="#FFFFFF" //change background color of item
}
