 // 3 LEVEL MENU CODE FOR THE TOP MENU SECTION.

	function addLoadEvent(func) {
			var oldonload = window.onload;
			if (typeof window.onload != 'function') {
				window.onload = func;
			} else {
				window.onload = function() {
					oldonload();
					func();
				}
			}
		}

		function prepareTopMenu() {
			// first lets make sure the browser understands the DOM methods we will be using
			if (!document.getElementsByTagName) return false;
			if (!document.getElementById) return false;

			// lets make sure the element exists
			if (!document.getElementById("topmenu")) return false;
			var topmenu = document.getElementById("topmenu");

			// for each of the li on the root level check if the element has any children
			// if so append a function that makes the element appear when hovered over
			var root_li = topmenu.getElementsByTagName("li");
			for (var i = 0; i < root_li.length; i++) {
				var li = root_li[i];
				// search for children
				var child_ul = li.getElementsByTagName("ul");
				if (child_ul.length >= 1) {
					// we have children - append hover function to the parent
					li.onmouseover = function () {
						if (!this.getElementsByTagName("ul")) return false;
						var ul = this.getElementsByTagName("ul");
						ul[0].style.display = "block";
						return true;
					}
					li.onmouseout = function () {
						if (!this.getElementsByTagName("ul")) return false;
						var ul = this.getElementsByTagName("ul");
						ul[0].style.display = "none";
						return true;
					}
				}
			}

			return true;
		}

		addLoadEvent(prepareTopMenu);

// 3 LEVEL MENU CODE FOR THE SIDE MENU SECTION.
	function addLoadEvent(func) {
			var oldonload = window.onload;
			if (typeof window.onload != 'function') {
				window.onload = func;
			} else {
				window.onload = function() {
					oldonload();
					func();
				}
			}
		}

		function prepareSideMenu() {
			// first lets make sure the browser understands the DOM methods we will be using
			if (!document.getElementsByTagName) return false;
			if (!document.getElementById) return false;

			// lets make sure the element exists
			if (!document.getElementById("sidemenu")) return false;
			var sidemenu = document.getElementById("sidemenu");

			// for each of the li on the root level check if the element has any children
			// if so append a function that makes the element appear when hovered over
			var root_li = sidemenu.getElementsByTagName("li");
			for (var i = 0; i < root_li.length; i++) {
				var li = root_li[i];
				// search for children
				var child_ul = li.getElementsByTagName("ul");
				if (child_ul.length >= 1) {
					// we have children - append hover function to the parent
					li.onmouseover = function () {
						if (!this.getElementsByTagName("ul")) return false;
						var ul = this.getElementsByTagName("ul");
						ul[0].style.display = "block";
						return true;
					}
					li.onmouseout = function () {
						if (!this.getElementsByTagName("ul")) return false;
						var ul = this.getElementsByTagName("ul");
						ul[0].style.display = "none";
						return true;
					}
				}
			}

			return true;
		}

		addLoadEvent(prepareSideMenu);



// 3 LEVEL MENU CODE FOR THE GROUP MENU SECTION.
	function addLoadEvent(func) {
			var oldonload = window.onload;
			if (typeof window.onload != 'function') {
				window.onload = func;
			} else {
				window.onload = function() {
					oldonload();
					func();
				}
			}
		}

		function prepareGroupMenu() {
			// first lets make sure the browser understands the DOM methods we will be using
			if (!document.getElementsByTagName) return false;
			if (!document.getElementById) return false;

			// lets make sure the element exists
			if (!document.getElementById("groupmenu")) return false;
			var groupmenu = document.getElementById("groupmenu");

			// for each of the li on the root level check if the element has any children
			// if so append a function that makes the element appear when hovered over
			var root_li = groupmenu.getElementsByTagName("li");
			for (var i = 0; i < root_li.length; i++) {
				var li = root_li[i];
				// search for children
				var child_ul = li.getElementsByTagName("ul");
				if (child_ul.length >= 1) {
					// we have children - append hover function to the parent
					li.onmouseover = function () {
						if (!this.getElementsByTagName("ul")) return false;
						var ul = this.getElementsByTagName("ul");
						ul[0].style.display = "block";
						return true;
					}
					li.onmouseout = function () {
						if (!this.getElementsByTagName("ul")) return false;
						var ul = this.getElementsByTagName("ul");
						ul[0].style.display = "none";
						return true;
					}
				}
			}

			return true;
		}

		addLoadEvent(prepareGroupMenu);