// JavaScript Document
function g(id) {
    if (document.getElementById) var returnVar = document.getElementById(id);
    else if (document.all) var returnVar = document.all[id];
    else if (document.layers) var returnVar = document.layers[id];
    return returnVar; 
}

function mostrar(x) {o=g(x); o.style.visibility="visible";}
function ocultar(x) {o=g(x); o.style.visibility="hidden";}
function opacidad(object, opacity) {
    object.style.opacity = (opacity / 100);
    object.style.MozOpacity = (opacity / 100);
    object.style.KhtmlOpacity = (opacity / 100);
    object.style.filter = "alpha(opacity=" + opacity + ")";
}

function contacto() {
	if (g("form").style.visibility=='hidden') {
		g("form").style.visibility='visible';
		g("filtro").style.visibility='visible';
	} else {
		g("form").style.visibility='hidden';
		g("filtro").style.visibility='hidden';
	}
}

function compruebaForm() {
	if (g("nombre").value=='') {
		alert ("Por favor, indica tu nombre.");
		g("nombre").focus();
		return false;
	} else if ((g("telefono").value=='') && (g("email").value=='')) {
		alert ("Por favor, indica alguna forma de contacto.");
		g("telefono").focus();
		return false;
	} else if (g("mensaje").value=='') {
		alert ("Por favor, escribe tu mensaje.");
		g("mensaje").focus();
		return false;
	} else return true;
}

// Abrir y cerrar la zona central de teatrófilos
factor=0; paso=-5; int=0; h=140; m=225;

function desplegar() {
	g("t1").style.visibility="hidden";
	if (typeof document.body.style.maxHeight != "undefined") { // Navegadores serios
		clearInterval(int); paso = -paso;
		int=setInterval("timer()",10);
	} else { // IE 6 o peor
		b=g("bienvenida");
		t=g("teatrofilos");
		x=g("teatrofilos2");
		if (paso<0) { // Abrir
			b.style.visibility="hidden"; t.style.visibility="visible";
			t.style.height="450px"; x.style.height="400px"; t.style.marginTop="70px";
		} else { // Cerrar
			b.style.visibility="visible"; t.style.visibility="hidden";
		}
		paso=-paso;
	}
}

function timer() {
	b=g("bienvenida");
	t=g("teatrofilos");
	x=g("teatrofilos2");
	// Paso 1: Transparencia
	if ( ((paso>0) && (factor<=100)) || ((paso<0) && (factor>=0) && (factor<=100)) ) {
		if (paso>0) {t.style.visibility="visible";}
		else {t.style.height="140px"; x.style.height="90px"; t.style.marginTop="225px"; b.style.visibility="visible";}
		opacidad(b,(100-factor)); opacidad(t,(factor));
		factor=factor+paso;
	// Paso 2: Tamaño
	} else if ( ((paso>0) && (factor<=200)) || ((paso<0) && (factor>100))) {
		if (paso>0) {h=((h*5)+450)/6; m=((m*5)+70)/6;}
		else 		{h=((h*5)+140)/6; m=((m*5)+225)/6;}
		t.style.height=h+"px"; t.style.marginTop=m+"px";
		x.style.height=(h-50)+"px";
		factor=factor+paso;
	// Finalizado
	} else {
		if (paso>0) {
			b.style.visibility="hidden";
			t.style.height="450px"; x.style.height="400px"; t.style.marginTop="70px";			
		}
		else t.style.visibility="hidden";
		clearInterval(int);
	}
}
