/*
	======================================
	listsclass.js adds a toggle function
	to list items in the col2 div, whose 
	class is lists
	======================================
	NOTE: 14 Dec 2006
	image of plus and minus sign where changed
	to left- and down-pointing triangles.
	
	Changed script so no IMG tag was added to
	UL's SPAN. Since the IMG tag is an inline
	item, it got an underline. The IMG was 
	replaced by adding a STYLE to the span
	=====================================
	
*/

function showthem() {
	/* original code
	var dad = this.parentNode;
	var kids = dad.getElementsByTagName("ul");
	kids[0].style.display = (kids[0].style.display=="none") ? "block" : "none";
	this.style.background = (kids[0].style.display=="none") ? "url(css/plus.gif) no-repeat right center" : "url(css/minus.gif) no-repeat right center";
	*/
	var $this = $(this),
		$thisUl = $this.parent("li").children("ul");
	if ($thisUl.is(":hidden")) {
		$thisUl.slideDown("normal");
		$this.css("backgroundImage", "url(css/minus.gif)")
	} else {
		$thisUl.slideUp();
		$this.css("backgroundImage", "url(css/plus.gif)")
	
	}
	return false;
	
}

function initListclass() {
	// test for browser compatibility
	if (!document.getElementsByTagName) return false;
	if (!document.getElementById) return false;
	if (!document.createElement) return false;
	if (!document.createTextNode) return false;
	if (!document.getElementById("secondaryContent")) return false;
	
	var containerDiv = document.getElementById("secondaryContent");
	var aLists = containerDiv.getElementsByTagName("ul");
	
	var aUlList = new Array();
	
	for(var x=0; x < aLists.length; x++) {
		/* Loop thru array of ULs in 
		 * secondaryContent div and pick out
		 * the ones with the class of lists */
		if(aLists[x].className!="lists") continue;
		aUlList[aUlList.length] = aLists[x];
	} // end for loop
	
	var l,n,t,span,txt,ul,pic;
	for ( var thisUl = 0; thisUl < aUlList.length; thisUl++) {
		/* loop thru list of ULs with class of lists */
		l = aUlList[thisUl];
		for (var i=0; i<l.childNodes.length; i++) {
			n=l.childNodes[i];
			if (n.nodeName!="LI") continue;
			if (n.getElementsByTagName("ul").length<1) continue;
			t = n.childNodes[0];	
			span = document.createElement("span");
			txt = document.createTextNode(t.nodeValue);
			span.appendChild(txt);
			
			/* Removed IMG tag 14 Dec 2006. It created an underline
			pic = document.createElement("IMG");
			pic.src="css/plus.gif";
			pic.style.verticalAlign="text-bottom";
			pic.style.marginLeft="8px";
			span.appendChild(pic);
			*/
			
			n.insertBefore(span,n.childNodes[1]);
			n.removeChild(t);
			
			
			span.style.textDecoration="underline";
			span.style.cursor="pointer";
			// new 14 Dec 2006 ended underline problem
			span.style.paddingRight="15px";
			span.style.background="url(css/plus.gif) no-repeat right center";
			
			span.onclick=showthem;
			
			ul = n.getElementsByTagName("ul")[0];
			ul.style.display="none";
			
			$(span).hover(
				function() {$(this).css("color","#0054a6")},
				function() {$(this).css("color","black")}
			);

		} // end for loop
	} // end for loop
}


addLoadEvent(initListclass);



