

onload = function() {
/* Level 0 */
	var getEls = document.getElementById('sub0').getElementsByTagName("LI");	
	for (var i=0; i<getEls.length; i++) {
		getEls[i].onmouseover=function() {
		this.className = this.className == 'clicked' ? '' : 'clicked';

		checkClick ('sub0',this)

		allOff ('sub2')
		allOff ('sub3')
		allOff ('sub4')
		allOff ('sub5')

		switchOn (this)

		switchOff ('sub1')
		}
	}
/* Level 1 */
	var getEls = document.getElementById('sub1').getElementsByTagName("LI");
	for (var i=0; i<getEls.length; i++) {
		getEls[i].onmouseover=function() {
		this.className = this.className == 'clicked' ? '' : 'clicked';

		checkClick ('sub1',this)

		allOff ('sub3')
		allOff ('sub4')
		allOff ('sub5')

		switchOn (this)

		switchOff ('sub2')
		}
	}
/* Level 2 */
	var getEls = document.getElementById('sub2').getElementsByTagName("LI");
	for (var i=0; i<getEls.length; i++) {
		getEls[i].onmouseover=function() {
		this.className = this.className == 'clicked' ? '' : 'clicked';

		checkClick ('sub2',this)

		allOff ('sub4')
		allOff ('sub5')

		switchOn (this)
		
		switchOff ('sub3')
		}
	}
/* Level 3 */
	var getEls = document.getElementById('sub3').getElementsByTagName("LI");
	for (var i=0; i<getEls.length; i++) {
		getEls[i].onmouseover=function() {
		this.className = this.className == 'clicked' ? '' : 'clicked';

		checkClick ('sub3',this)

		allOff ('sub5')

		switchOn (this)
		
		switchOff ('sub4')
		}
	}
/* Level 4 */
	var getEls = document.getElementById('sub4').getElementsByTagName("LI");
	for (var i=0; i<getEls.length; i++) {
		getEls[i].onmouseover=function() {
		this.className = this.className == 'clicked' ? '' : 'clicked';

		checkClick ('sub4',this)

		switchOn (this)
		
		switchOff ('sub5')
		}
	}
}


function switchOn (subs) {
		ulId = subs.id.replace("top", "sub");
		document.getElementById(ulId).className = document.getElementById(ulId).className == 'yes' ? 'none' : 'yes';
		}

function checkClick (subs,thisOne) {
				var getAgn = document.getElementById(subs).getElementsByTagName("LI");
				for (var z=0; z<getAgn.length; z++) {
				if (thisOne.id != getAgn[z].id){
				getAgn[z].className = '';
			}
		}
	}

function allOff (subs) {
			var getListSub = document.getElementById(subs).getElementsByTagName("UL");
			for (var s=0; s<getListSub.length; s++) {
					getListSub[s].className = "none";
				}
			}

function switchOff (subs) {
			var getListElts = document.getElementById(subs).getElementsByTagName("UL");
			for (var i=0; i<getListElts.length; i++) {
			if (ulId != getListElts[i].id && getListElts[i].className == "yes"){
					getListElts[i].className = "none";
				}
			}
			var getListSub = document.getElementById(subs).getElementsByTagName("LI");
			for (var s=0; s<getListSub.length; s++) {
					getListSub[s].className = "";
				}
		}

