function rollOn(elemento){elemento.className = "on";}
function rollOut(elemento){elemento.className = "out";}

var Sitio = {
	cambiaFlash: function() {
		$$('.contenedorFlash').each(
			function(div) {
				var object = div.getFirst();
				var ruta = object.getAttribute('data');
				var ancho = object.getAttribute('width');
				var alto  = object.getAttribute('height');
				var so = new SWFObject(ruta, "flash", ancho, alto, "7");
				so.addParam("wmode", "transparent");
				so.write(div.id);
			}
		);
	}
};

//window.addEvent('domready', Sitio.cambiaFlash);

window.addEvent('domready', function() {
 $$('.textoGenerico').each(function(txt) {
   var h2 = txt.getElement('h2');
   txt.getElements('.pestanias .pestania').each(function(a, i) {
    if(i != 0) {
     a.style.display = 'none';
    }
    var h3 = a.getElement('h3');
    var enlace = document.createElement('enlace');
    enlace.className = (i == 0) ? 'enlacePestania activo' : 'enlacePestania';
    enlace.div = a;
    enlace.padre = txt;
    enlace.onclick = function() {
      this.padre.getElements('.pestanias .pestania').each(function(a) {
       a.style.display = 'none';
      });
      this.div.style.display = 'block';

      this.padre.getElements('.enlacePestania').each(function(a) { a.className = 'enlacePestania' });
      this.className = 'enlacePestania activo';
    };
    var span = document.createElement('span');
    span.appendChild(document.createTextNode(h3.firstChild.firstChild.data));
    enlace.appendChild(span);
    txt.insertBefore(enlace, txt.getElement('div'));

    h3.parentNode.removeChild(h3);
   });
 });
});