
// Poner error a true si no se quiere que haya emision
var error = false;

var estadobuffer=0;


window.onload = function() {
	if (error) {
		show_error();	
	}
	else if (!document.all) {
		no_iexplorer()	
	}
	else {
		centrar();
		inicio();
		eventos();
	}
}

//window.onresize = recarga;


function show_error() {
	document.getElementById('precarga').style.display = "none";
	document.getElementById("error").style.display = "block";	
}

function no_iexplorer() {
	document.getElementById('precarga').style.display = "none";
	document.getElementById("netscape").style.display = "block";	
}

function centrar() {
	cont = document.getElementById("contenedor");
	cop = document.getElementById("copy");
	totalbody = document.body.clientHeight;
	totaltele = cont.offsetHeight + cop.offsetHeight;
	margen = parseInt((totalbody-totaltele)/2);
	cont.style.marginTop = margen + "px";
}
	
function inicio() {
	
	capaPrecarga = document.getElementById('precarga');
	capaTv = document.getElementById('tv');
	capaConn = document.getElementById('conexion');
	capaOff = document.getElementById('off');
	tele = document.getElementById('tvObj');
	q = document.location.search;
	

	if (q!="")  {
		capaPrecarga.style.display = "block";
		capaConn.style.display = "none";
		archivo_asx = q.substring(1,q.length);
		tele.FileName = archivo_asx + ".asx";
		controlbuffer();
		}
	else {
		capaPrecarga.style.display = "none";
		capaConn.style.display = "block";
		tele.Stop();
		}
}


function eventos() {
	
	b1 = document.getElementById("bot1").firstChild;
	b2 = document.getElementById("bot2").firstChild;
	b3 = document.getElementById("bot3").firstChild;
	b4 = document.getElementById("bot4").firstChild;
	b5 = document.getElementById("contacA");
	
	
	b1.onclick = function() {
		parar();		
	}
	
	b2.onclick = function() {
		encender();	
	}
	
	b3.onclick = function() {
		conexion();	
	}
	
	b4.onclick = function() {
		full_screen();	
	}
	
	b5.onclick = function() {
		document.location.href = "mailto:ondajerez&#64ondajerez.com";	
		return false;
	}
	
}



function controlbuffer() {
	
	estadobuffer = tele.bufferingProgress;
	tele.ShowStatusBar = "True";

	if(estadobuffer==100){
		estadobuffer = 0;
		fuera_buffer();
		return ;
	}
	
	setTimeout("controlbuffer()",500);
}

function fuera_buffer() {
	
	capaPrecarga.style.display = "none";
	capaTv.style.display = "block";
	setTimeout('tele.ShowStatusBar="False"',10000);
	tele.DisplaySize = 0;
	tele.AutoSize = true;

}


function parar() {

		tele.Stop();
		capaOff.style.display = "block";

}

function encender() {
	
	if (tele.FileName) {	
		capaOff.style.display = "none";
		capaPrecarga.style.display = "block";
		tele.ShowStatusBar = "True";
		controlbuffer();
		tele.Play();		
	}
	
}

function conexion() {
	
	tele.Stop();
	capaConn.style.display = "block";
	
}



function full_screen() {
	
	tele.DisplaySize = 3;
	
}

function recarga() {
	if (document.getElementById('tvObj'))
		document.location.reload();
}