/* ================================================================ 
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/gallery/hover_gallery.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
=================================================================== */


document.getElementById('loading').style.display = "none";
/* Level 0 */
	var getEls = document.getElementById('sub0').getElementsByTagName("LI");	
	for (var i=0; i<getEls.length; i++) {
		getEls[i].onclick=function() {
		this.className = this.className == 'clicked' ? '' : 'clicked';

		checkClick ('sub0',this)

		allOff ('sub2')

		switchOn (this)

		switchOff ('sub1')
		}
	}
/* Level 1 */
	var getEls = document.getElementById('sub1').getElementsByTagName("LI");
	for (var i=0; i<getEls.length; i++) {
		getEls[i].onclick=function() {
		this.className = this.className == 'clicked' ? '' : 'clicked';

		checkClick ('sub1',this)

		switchOn (this)

		switchOff ('sub2')
		}
	}



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 = "";
				}
		}
