openlink={}

function elist(link) {
	listElement = link.parentNode

	if(listElement.className != "scrollmenu") 
		return false;

	sublist = listElement.nextSibling

	while(sublist!=null && (sublist.nodeName == "#text" || sublist.tagName != "OL")) {
		sublist = sublist.nextSibling
	}
	return sublist

}
function setVisibility(sublist, status) {

	for(i = 0; i < sublist.childNodes.length; i++) {
		if(sublist.childNodes[i].nodeName == "#text")
			continue;
		sublist.childNodes[i].style.display=status
		
	}

}
function changeColor(from, to, obj) {
	r=(parseInt(from.substring(1,3),16)-10).toString(16)
	g=(parseInt(from.substring(3,5),16)-10).toString(16)
	b=(parseInt(from.substring(5,7),16)-10).toString(16)
	
	from = '#' + (r.length == 1 ? "0" + r : r) +  (g.length == 1 ? "0" + g : g)  +  (b.length == 1 ? "0" + b : b) ;
	obj.childNodes[0].style.color = from

	if(to != from)
		setTimeout(changeColor, 5,from, to, obj);
}

function activateItem(link) {

	sublist = elist(link)

	if(!openlink[link.id]) {
		scale(0,sublist.childNodes.length, sublist.childNodes)
		openlink[link.id]=true
		
		//close every other link
		for(olink in openlink) {
			if(olink != link.id) {
				if(openlink[olink]) {
					activateItem(document.getElementById(olink))
				}
			} 
		}
	} else {
		setVisibility(sublist, "none")
		openlink[link.id]=false
	}
	

}

function scale(from, to, list) {

	if(from >= to) return

	if(list[from].nodeName == "#text") {
		return scale(from+1, to, list)
	}

	if(list[from].className!="division")
		changeColor("#e8e8e8", "#666666", list[from])

	list[from].style.display = "list-item"
		
	window.setTimeout(scale, 50,from+1, to, list)
}

var bgsleight	= function() {
	
	function addLoadEvent(func) {
		var oldonload = window.onload;
		if (typeof window.onload != 'function') {
			window.onload = func;
		} else {
			window.onload = function() {
				if (oldonload) {
					oldonload();
				}
				func();
			}
		}
	}
	
	function fnLoadPngs() {
		var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
		var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5);
		for (var i = document.all.length - 1, obj = null; (obj = document.all[i]); i--) {
			if (itsAllGood && obj.currentStyle.backgroundImage.match(/\.png/i) != null && obj.tagName != "BODY") {
				fnFixPng(obj);
				obj.attachEvent("onpropertychange", fnPropertyChanged);
			}
		}
	}

	function fnPropertyChanged() {
		if (window.event.propertyName == "style.backgroundImage") {
			var el = window.event.srcElement;
			if (!el.currentStyle.backgroundImage.match(/x\.gif/i)) {
				var bg	= el.currentStyle.backgroundImage;
				var src = bg.substring(5,bg.length-2);
				el.filters.item(0).src = src;
				el.style.backgroundImage = "url(x.gif)";
			}
		}
	}

	function fnFixPng(obj) {
		var bg	= obj.currentStyle.backgroundImage;
		var src = bg.substring(5,bg.length-2);
		obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')";
		obj.style.backgroundImage = "url(x.gif)";
	}
	
	
	
	
	return {
		
		init: function() {
			
			if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
				addLoadEvent(fnLoadPngs);
			}
			
		}
	}
	
}();

bgsleight.init();

