/* JS script to manage menu on a.d. Install site
// written by mar_cim (www.marcim.info)
*/

// Skrypt obsługujący menu w lewej kolumnie:
function ColumnMenu(varname, id) {
	this.clicked = new Array();
	this.lastClicked = 0;
	
	this.rootID = id;
	this.root = document.getElementById(id);
	
	this.blocked = false;
	
	var sectionID = 0;
	for(i=0;i<this.root.childNodes.length;i++) {
		el = this.root.childNodes[i];
		if(el.tagName == 'LI' || el.tagName == 'li') {
			for(k=0;k<el.childNodes.length;k++) {
				elem = el.childNodes[k];
				if(elem.tagName == 'H3' || elem.tagName == 'h3') {
					sectionID++;
					elem.id = id+"_sectionhead_"+(sectionID);
					eval("elem.onclick = function() {"+varname+".click("+sectionID+");}");
					//eval("elem.onmouseout = function() {"+varname+".click("+sectionID+");}");
					//eval("elem.onmouseover = function() {"+varname+".click("+sectionID+");}");
				}
				else if(elem.tagName == 'UL' || elem.tagName == 'ul') {
					elem.id = id+"_sectionlinks_"+sectionID;
					elem.style.display = "none";
					elem.style.paddingTop = "0";
					elem.style.paddingBottom = "0";
					//elem.innerHTML = "<li>&nbsp;</li>"+elem.innerHTML+"<li>&nbsp;</li>";
					this.clicked[sectionID] = 1;
				}
			}
		}
	}
	
	
	this.click = function(sectionID) {
		
		if(sectionID != this.lastClicked) {
			if(this.lastClicked > 0) {
				$("#"+this.rootID+"_sectionlinks_"+this.lastClicked).hide("slow"); 
				document.getElementById(this.rootID+"_sectionhead_"+this.lastClicked).className = undefined;
				this.clicked[this.lastClicked] = undefined;
			}
			document.getElementById(this.rootID+"_sectionhead_"+sectionID).className = "active";
			$("#"+this.rootID+"_sectionlinks_"+sectionID).show("slow"); 
			this.clicked[sectionID] = 1;
			this.lastClicked = sectionID;
		}
		
		else if(sectionID == this.lastClicked) {
			document.getElementById(this.rootID+"_sectionhead_"+sectionID).className = undefined;
			$("#"+this.rootID+"_sectionlinks_"+this.lastClicked).hide("slow"); 
			this.clicked[this.lastClicked] = undefined;
			this.lastClicked = 0;
		}
		/**/
	}
	
}

// oraz jego inicjalizacja:
menuleft = new ColumnMenu('menuleft', 'menu');


