	/*
		Custom functions.
	*/

	function switchDiv(capa){
		// switcheamos el estado display del DIV
        if(capa){
            if(capa.style.display=="block" || capa.style.display==""){
                capa.style.display = "none";
            }else{
                capa.style.display = "block";
		    }
        }
	}
	
	function switchFAQ(capa){
		// switcheamos el estado display del DIV
		if (window.attachEvent) {
			capa = capa.previousSibling;
		}
		
		//cambiar todos los DT a display none
		var elems =	document.getElementById("faq").getElementsByTagName("DD");
		for(i=0;i<elems.length;i++){
			elems[i].style.display = "none";
		}
		
		if(capa.style.display=="none" || capa.style.display==""){
			capa.style.display = "block";
		}else{
			capa.style.display = "none";
		}
	}
	
	function switchNEWS(capa){
		// switcheamos el estado display del DIV
		if (window.attachEvent) {
			capa = capa.previousSibling;
		}
		
		//cambiar todos los DT a display none
		var elems =	document.getElementById("news").getElementsByTagName("DD");
		for(i=0;i<elems.length;i++){
			elems[i].style.display = "none";
		}
		
		if(capa.style.display=="none" || capa.style.display==""){
			capa.style.display = "block";
		}else{
			capa.style.display = "none";
		}
	}
	
	function embedFlash(o){
		document.write(o);
	}
	
	
	function addEmail() {
		var ni = document.getElementById('emails');
		var numi = document.getElementById('theValue');
		if(numi.value < 10) {
			var num = (document.getElementById("theValue").value -1)+ 2;
			numi.value = num;
			var divIdName = "my"+num+"Div";
			var newdiv = document.createElement('div');
			newdiv.setAttribute("id",divIdName);
			newdiv.innerHTML = "<div class=\"margintop clearfix\"><input type=\"text\" class=\"floatright\" name=\"email"+num+"\" /><button type=\"button\" class=\"submit min_width floatleft\" onclick=\"removeEmail(\'"+divIdName+"\')\">Delete</button></div>";
			ni.appendChild(newdiv);
		}
	}

	function removeEmail(divNum) {
		var numi = document.getElementById('theValue');
		var num = (document.getElementById("theValue").value -1);
		numi.value = num;

		var d = document.getElementById('emails');
		var olddiv = document.getElementById(divNum);
		d.removeChild(olddiv);
	}
	
	function cerrarDemos() {
		for(i=1;i<4;i++){
			document.getElementById("demo"+i).style.display = "none";
		}
	}
    
    function cerrarDemosHome() {
		for(i=1;i<5;i++){
			document.getElementById("demo"+i).style.display = "none";
		}
	}

    function addInputSpam(cad){
        sal='<inp'+'ut t'+'yp'+
            'e="hi'+'dd'+'en"'+
            ' na'+'me'+'='+'"s'+
            'pam'+'" v'+'alu'+
            'e='+'"'+cad+'"'+
            ' />';
        document.write(sal);
    }

    
    /* EFECTILLO MOVEOUT (dos capas, una "empuja" a la otra) para Whisher*/

    function moveout(idvieja,idnueva){
        objviejo=document.getElementById(idvieja);
        objnuevo=document.getElementById(idnueva);
        objviejo.style.left="0px";
        ancho=document.getElementById('wrappaginas').offsetWidth;
        alto=document.getElementById('wrappaginas').offsetHeight;
        objnuevo.style.left=ancho+"px";
        objnuevo.style.display="block";
        objnuevo.style.marginLeft="50px";
        if(idnueva>idvieja) objnuevo.style.top="-"+alto+"px";
        else objviejo.style.top="-"+alto+"px";
    
        setTimeout('moveoutTimer("'+idvieja+'","'+idnueva+'",0,1,'+ancho+')',50);
    }

    function moveoutTimer(idvieja,idnueva,posx,vel,ancho){
        objviejo=document.getElementById(idvieja);
        objnuevo=document.getElementById(idnueva);
        posx=posx-vel;
        if(posx+ancho<0)    //por si se pasa, bloqueamos a cero
            posx=-ancho;    

        if((posx+ancho)>(ancho/2))  vel=vel*2;
        else                        vel=vel/2;

        objviejo.style.left=posx+"px";
        objnuevo.style.left=(posx+ancho)+"px";
        if(posx+ancho > 0)
            setTimeout('moveoutTimer("'+idvieja+'","'+idnueva+'",'+posx+','+vel+','+ancho+')',50);
        else{
            objviejo.style.display="none";
            objnuevo.style.top="0px";
            objnuevo.style.marginLeft="0px";
            iLen = idnueva.length;
            nDiv = idnueva.substring(iLen, iLen - 1);
            ocultarCapasHome(nDiv);
        }
    }

    
    /*------------------------------------
        ::   eventos BOTONERA home   ::
        --------------------------------------*/
    var capaActual=1;
    
    function initHome()
    {
        ocultarCapasHome(1);
        var x = document.getElementById('homeBotonera').getElementsByTagName('a');
        for (var i=0;i<x.length-1;i++)
        {
            addEvent(x[i],"click",activarBoton);
        }
    }

    function activarBoton(e)
    {
        desactivarBotones();
        cerrarDemos();
        
        iLen = this.childNodes[0].id.length;
        nDiv = this.childNodes[0].id.substring(iLen, iLen - 1);
        if(capaActual!=nDiv)    //to avoid same in and out
            moveout('pagina'+capaActual,'pagina'+nDiv);
        this.className += ' activo';
    }

    function desactivarBotones()
    {
        var x = document.getElementById('homeBotonera').getElementsByTagName('a');
        for (var i=0;i<x.length;i++)
        {
            x[i].className = x[i].className.replace(/activo/g,'');
        }
    }
    
    function ocultarCapasHome(nDiv) // nDiv es la capa que NO se oculta
    {        
        capaActual=nDiv;
        for (var i=1;i<=5;i++){
            var x = document.getElementById('pagina'+i);
            (nDiv==i) ? x.style.display='block' : x.style.display='none';
            //(nDiv==i) ? fadeIn.toggle() : fadeOut.toggle();
        }
        
    }
    
/*-------------------------------
::  MENU DESPLEGABLE  ::
--------------------------------*/

function initBotones()
{
	var x = document.getElementsByClassName('submit');
	for (var i=0;i<x.length;i++)
	{
		addEvent(x[i],"mouseover",colorOn);
		addEvent(x[i],"mouseout",colorOff);
	}
}

function colorOn(e)
{
	this.className += ' hover';
}

function colorOff(e)
{
	this.className = this.className.replace(/hover/g,'');
}