/*

	Sitemap Styler v0.1
	written by Alen Grakalic, provided by Css Globe (cssglobe.com)
	visit http://cssglobe.com/lab/sitemap_styler/

*/

this.sitemapstyler = function(){
	var sitemap = document.getElementById("level_0");
        var len = sitemap.childNodes.length;
        var w=0;
        var browserName = navigator.appName;
        if(browserName == 'Netscape'){
            //alert (len);
            for(w=0; w< (len); w++){
                if(w != 0 &&  w != 2){
                    //alert(w);
                    var kid = sitemap.childNodes[w];
                    var root = kid.parentNode;
                    var parent = document.createElement('div');
                    parent.className = 'eachSMwrapper';
                    root.insertBefore(parent, kid);
                    parent.appendChild(kid);
                }
        }
        }
        else {
            for(w=0; w< (len); w++){
                    //alert(w);
                    var kid = sitemap.childNodes[w];
                    var root = kid.parentNode;
                    var parent = document.createElement('div');
                    parent.className = 'eachSMwrapper';
                    root.insertBefore(parent, kid);
                    parent.appendChild(kid);

            }
        }



	if(sitemap){

		this.listItem = function(li){

			if(li.getElementsByTagName("ul").length > 0){
				var ul = li.getElementsByTagName("ul")[0];
				ul.style.display = "none";
				var span = document.createElement("span");
				span.className = "collapsed";
				//span.onclick = function(){
					ul.style.display = (ul.style.display == "none") ? "block" : "none";
					this.className = (ul.style.display == "none") ? "collapsed" : "expanded";
				//};
				li.appendChild(span);
			};
		};

		var items = sitemap.getElementsByTagName("li");
		for(var i=0;i<items.length;i++){
			listItem(items[i]);
		};

	};
};

window.onload = sitemapstyler;

