// ==============================================================
// 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 : "desplegable",
	// 1: close all when opening any; 0: just toggle this.
	closeAll : 1,
	
	// you should not need to edit past this point
	// ======================================================
	start : function(){ 
		var togglers = EXTRAS.getElementsByClass(TOGGLE.htmlclass, null, 0);
		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(TOGGLE.closeAll == 1) {
			var togglers = EXTRAS.getElementsByClass(TOGGLE.htmlclass, null, 0);
			for (var i = 0; i < togglers.length; i++) if(togglers[i] != cont) togglers[i].style.display = "none";
		}
		if(cont.style.display == "block") {
			cont.style.display = "none";
			box.innerHTML = TOGGLE.showtxt+origtxt;
		}
		else {
			cont.style.display = "block";
			box.innerHTML = TOGGLE.hidetxt+origtxt;
		}
	}
}

// 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;