// JavaScript Document

/* ================================================================
This copyright notice must be untouched at all times.

The original version of this script and the associated (x)html
is available at http://www.stunicholls.com/menu/hover_through.html
Copyright (c) 2005-2008 Stu Nicholls. All rights reserved.
This script and the associated (x)html may be modified in any
way to fit your requirements.

Please see 'Terms of use' on stunicholls.com
=================================================================== */

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 = "";
 }
 }

