/********************************************************************
- con este script todos los elementos estan inicialmente cerrados
- al pinchar sobre uno, este se abre y los demas se cierran
- cambios con respecto al original:
  * class "acordeon" por "toogle"
		* en principio aparecen todos cerrados
*********************************************************************/

//Obtenido de http://www.disenorama.com/articulos/dhtml-no-intrusivo
//Convierte en clickable el elemento anterior al que sea class="toggle"
//que lo muestra u oculta

// ==============================================================
// 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
// ==============================================================
function iniciar_acordeon(){
var toggleini = 'no';
ACORDEON = {
	// edit text to append before linkable element
	/*
	showtxt : "Muestra ",
	hidetxt : "Esconde ",
	*/
	showtxt : "",
	hidetxt : "",
	// edit html class name
	htmlclass : "acordeon",
	
	// you should not need to edit past this point
	// ======================================================
	start : function(){ 
		var togglers = ACORDEON.getElementsByClass(ACORDEON.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"; 
			ACORDEON.prepare(box,cont,i);
		}
	},
	
	prepare : function(box,cont,i){ 
		var origtxt = box.innerHTML;
		/*
		
		este script sería para que el primero este desplegado por defecto
		
		if(i==0 && toggleini=='no'){
			toggleini = 'si';
		 cont.style.display = "block";
		}else{
		 cont.style.display = "none";
		}
		
		*/
		/* inicio todos cerrados -> */ cont.style.display = "none";
		
		//else cont.style.display = "block";
		box.innerHTML = ACORDEON.showtxt+origtxt;
		box.onclick = function(){
			ACORDEON.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 = ACORDEON.showtxt+origtxt;
		}
		else {
/* *********** SOLO ABIERTO EL ELEMENTO ACTUAL ***************/
			ACORDEON.start();
/* *********** FIN SOLO ABIERTO EL ELEMENTO ACTUAL ***************/
			cont.style.display = "block";
			box.innerHTML = ACORDEON.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;
	}
}

	ACORDEON.start();
}
