
/*Función ocultar texto*/

function mostrarOcultar(){

	var elDesp = document.getElementById("plegables").getElementsByTagName("h3");

	for (i=0; i<elDesp.length; i++){

		var Link = document.createElement("a");

		Link.appendChild(document.createTextNode(elDesp[i].firstChild.nodeValue));

		Link.href = "#";

		
		elDesp[i].replaceChild(Link,elDesp[i].firstChild);

		elDesp[i].title = "Desplegar";

		
		// oculto el siguiente hermano

		var next = elDesp[i].nextSibling; 
		
		while(next.nodeType != 1){

			next = next.nextSibling;

		}

		elDesp[i].next = next; 


		elDesp[i].next.className = "oculto"; 

		

	

		elDesp[i].onclick = function(){

			if(this.className == ""){

				this.className = "plegar";

				this.next.className = "";

				this.title = "Ocultar"

			}

			else{

				this.className = "";

				this.next.className ="oculto";

				this.title = "Desplegar"

			}

		}

		

	}

}



window.onload = function (){

	mostrarOcultar();

}