// ==============================================================
// UNOBTRUSIVE TOGGLE SECTIONS SCRIPT: TOGGLE v1.0
// (c)2004 Sergi Meseguer http://zigotica.com/ under CC license:
// http://creativecommons.org/licenses/by-sa/2.0/
// ==============================================================
// Just set htmlclass to element to be hidden/shown and 
// it'll make a link from the previous element
// ==============================================================

TOGGLE = {
	// edit text to append before linkable element
	showtxt : "+ ",
	hidetxt : "- ",
	// edit html class name
	htmlclass : "toggle",
	
	// you should not need to edit past this point
	// ======================================================
	start : function(){ 
		var togglers = TOGGLE.getElementsByClass(TOGGLE.htmlclass);
		for (var i = 0; i < togglers.length; i++) {
			var box = togglers[i].previousSibling;
			//fix for Moz and line break/tab, etc:
			if(typeof box.innerHTML != "string") box = box.previousSibling; 
			var cont = togglers[i];
			//avoids currentStyle/computedStyle:
			cont.style.display = "block"; 
			TOGGLE.prepare(box,cont);
		}
	},
	
	prepare : function(box,cont){ 
		var origtxt = box.innerHTML;
		cont.style.display = "none";
		box.innerHTML = TOGGLE.showtxt+origtxt;
		box.onclick = function(){
			TOGGLE.run(box,cont,origtxt);
		}
		// fix for IE5.x cursor property:
		if(navigator.appVersion.indexOf("MSIE 5") > -1 && !window.opera) box.style.cursor = "hand";
		else box.style.cursor = "pointer";
	},
	
	run : function(box,cont,origtxt) { 
		if(cont.style.display == "block") {
			cont.style.display = "none";
			box.innerHTML = TOGGLE.showtxt+origtxt;
		}
		else {
			cont.style.display = "block";
			box.innerHTML = TOGGLE.hidetxt+origtxt;
		}
	}, 
	
	// Method adapted from Dan Pupius (pupius.co.uk):
	getElementsByClass : function(className,node) {
		if(!node) node=document;
		var refTags = document.all ? document.all : node.getElementsByTagName("*");
		var retVal = new Array();
		for(var z=0;z<refTags.length;z++) {
			if(refTags[z].className == className) 
			retVal.push(refTags[z]);
		}
		return retVal; 
	}
}

// adds 1 or more elements to an array (IE only)
if(!Array.prototype.push)
{
	Array.prototype.push =  function()
	{
		var i;
		for(i=0; j=arguments[i]; i++) this[this.length] = j;
		return this.length;
	}
}
if (document.getElementsByTagName) window.onload = TOGGLE.start;
