function expandoMenu() {

	// Variables defining the menu's classes and IDs
	var parentClass = 'parent';				// class for LI containing a nested UL
	var expandedParentClass = 'expanded';	// class for nested UL when visible
	var menuClass = 'expando';		// class for main UL when Javascript available
	var hClass = 'hChild';					// class for hidden nested UL
	var vClass = 'vChild';					// class for visible nested UL
	var currentClass = 'selected';			// class for active sub element and prevents collapsing
	var d = document.getElementById('nav');	// ID of the navigation UL 

	if(!document.getElementById && !document.createTextNode) {
		return;
	}

// if the navigation element is available, apply the class denoting DHTML capabilities
	if(d) {
		d.className+=d.className==''?menuClass:' '+menuClass;
		var lis,i,firstUL,j,apply;

		// loop through all LIs and check which ones contain an UL
		lis=d.getElementsByTagName('li');
		for(i=0;i<lis.length;i++) {
			firstUL=lis[i].getElementsByTagName('ul')[0]
			// if there is a nested UL, deactivate the first nested link 
			// and apply the class to show there is a nested list
			if(firstUL) {
				lis[i].childNodes[0].onclick=function() {
					return false;
				}
				lis[i].className+=lis[i].className==''?parentClass:' '+parentClass;
				// check if there is a "current" element 
				apply=true;
				if(new RegExp('\\b'+currentClass+'\\b').test(lis[i].className)) {
					apply=false;
				}
				if(apply) {
					for(j=0;j<firstUL.getElementsByTagName('li').length;j++) {
						if(new RegExp('\\b'+currentClass+'\\b').test(firstUL.getElementsByTagName('li')[j].className)) {
							apply=false;break
						}
					}
				}
				// if there is no current element, apply the class to hide the nested list
				if(apply) {
					firstUL.className+=firstUL.className==''?hClass:' '+hClass;
					lis[i].onclick=function() {
						toggleMenu(this);
					}
				}
				else {
					// if there is a current element, define the list as being kept open and apply the 
					// classes to show the nested list and define the parent LI as an active one
					lis[i].keepopen=1;
					firstUL.className+=firstUL.className==''?vClass:' '+vClass;
					lis[i].className=lis[i].className.replace(parentClass,expandedParentClass);
				}
			}
		}
	}

	// function to show and hide the nested lists and add the classes to the parent LIs
	function toggleMenu(o) {
		var childUL,isobj,swap;

		// loop through all LIs of the navigation		
		lis=d.getElementsByTagName('li');
		for(i=0;i<lis.length;i++) {
			isobj=lis[i]==o;
			// function to exchange class names in an object
			swap=function(tmpobj,tmporg,tmprep) {
				tmpobj.className=tmpobj.className.replace(tmporg,tmprep)		
			}
			// if the current LI does not have an indicator to be kept visible
			if(!lis[i].keepopen) {
				childUL=lis[i].getElementsByTagName('ul')[0];
				// check if there is a nested UL and if the current LI is not the one clicked on
				// and exchange the classes accordingly (ie. hide all other nested lists and 
				// make the LIs parent rather than active.
				if(childUL)	{
					if(new RegExp('\\b'+expandedParentClass+'\\b').test(lis[i].className)) {
						swap(childUL,isobj?vClass:hClass,isobj?hClass:vClass);		
						swap(lis[i],isobj?expandedParentClass:parentClass,isobj?parentClass:expandedParentClass);		
					}
					else {
						swap(childUL,isobj?hClass:vClass,isobj?vClass:hClass);		
						swap(lis[i],isobj?parentClass:expandedParentClass,isobj?expandedParentClass:parentClass);		
					}
				} 
			}
		}
	}
}
