// ==============================================================
// 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/
// ==============================================================
// Requires EXTRAS namespace (extras.js in this folder)
// 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 : "Muestra ",
	hidetxt : "Esconde ",
	// edit html class name
	htmlclass : "toggle",
	
	// you should not need to edit past this point
	// ======================================================
	start : function(){ 
		var togglers = EXTRAS.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;
		}
	}
}

if (document.getElementsByTagName) EXTRAS.addEvent(window, 'load', TOGGLE.start, false);