function getLastChildElementv(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 getFirstChildElementv(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 showItemsv(menuitem){ //shows side menu
if (getLastChildElementv(menuitem).tagName=="DIV"){ // if last child element is a div, ie menuitem  has a side menu
getLastChildElementv(menuitem).style.visibility = "visible" //show the side menu
}
menuitem.style.backgroundColor="#ffffff" //background color of menuitem changed to this
menuitem.style.backgroundImage="url(/images/rolloverbg.gif)" //show fancy background image 
}
function hideItemsv(menuitem,ent){ //hides side menu
	if (ent.toElement || ent.relatedTarget){ //if browser supports toelement or relatedtarget
		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 (getLastChildElementv(menuitem).tagName=="DIV"){ //if menuitem has a side menu
					getLastChildElementv(menuitem).style.visibility = "hidden" //hide children
				}
				menuitem.style.backgroundColor="#F2C512" //change background-color
				menuitem.style.backgroundImage="none" //remove background-image
			}
		}
		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 (getLastChildElementv(menuitem).tagName=="DIV"){ //if menuitem has a side menu
					getLastChildElementv(menuitem).style.visibility = "hidden" //hide children
				}
				menuitem.style.backgroundColor="#F2C512" //change background-color
				menuitem.style.backgroundImage="none" //remove background-image
			}
		}
	}
	else {
		hideItemsOldv(menuitem) //run original version of this function which causes flickering in FF and NN
	}
}

function hideItemsOldv(menuitem){ //essentially the same as hideItems only this may cause flickering in FF and NN
if (getLastChildElementv(menuitem).tagName=="DIV"){ // if last child element is a div, ie menuitem  has a side menu
getLastChildElementv(menuitem).style.visibility = "hidden" // hide side menu
}
menuitem.style.backgroundColor="#F2C512" //change color of menuitem to same as background
menuitem.style.backgroundImage="none" //remove fancy background image
}

function itemHighlightOnv(item){ //changes color of side menu item background and text when mouse goes over
if (getFirstChildElementv(item).tagName=="A"){ //if item has a link
getFirstChildElementv(item).style.color="#0000ff" //change text link color to this color
}
item.style.backgroundColor="#F0E696" //change background color to this
}
function itemHighlightOffv(item){ //changes color of side menu item background and text when mouse goes over
if (getFirstChildElementv(item).tagName=="A"){ //if item has a link
getFirstChildElementv(item).style.color="#ff0000" //change link text color to this color
}
item.style.backgroundColor="#FFFFFF" //change background color to this
}
