/* PROYECTOR */

var img_root = "img/menu/";

Fulanos.prototype.Hijo = function(){
	this.pantalla = null;
}
function Menu(){
	this.menu = null;
}
function YouTube(){
	this.obj = null;
	this.parent = arguments[0];
}
function Fulanos(){
	this.obj = arguments[0];
	this.hijo = new this.Hijo();
	this.menu = new Menu();
	this.youtube = new YouTube(this);
}


var obj = new Fulanos("obj");

/* PROPIEDADES*/
Fulanos.prototype.freq = 100;
Fulanos.prototype.sw = false;
Fulanos.prototype.over = false;
Fulanos.prototype.encendido = true;
Fulanos.prototype.timer = null;
Fulanos.prototype.clic = false;
Fulanos.prototype.cargando;
Fulanos.prototype.gobalTimer = null;
Fulanos.prototype.freqG = 3000;

YouTube.prototype.pelis = [];
/* Promos */
YouTube.prototype.pelis[1] = "http://www.youtube.com/v/v2SD9i22RZk&hl=en";
YouTube.prototype.pelis[2] = "http://www.youtube.com/v/-6mnnHXuReo&hl=en";
YouTube.prototype.pelis[3] = "http://www.youtube.com/v/vsaXBRfSPwQ&hl=en&fs=1";
YouTube.prototype.pelis[4] = "http://www.youtube.com/v/jlEmCRIzZpA&hl=en&fs=1";
YouTube.prototype.pelis[5] = "http://www.youtube.com/v/f2ID-3_DAD8&hl=en&fs=1";
YouTube.prototype.pelis[6] = "http://www.youtube.com/v/5J44nv1LHf0&hl=es&fs=1";
YouTube.prototype.pelis[7] = "http://www.youtube.com/v/UuRAUwgCIBE&hl=es&fs=1";
YouTube.prototype.pelis[8] = "http://www.youtube.com/v/utcDgH8tyuo&hl=es&fs=1";
YouTube.prototype.pelis[9] = "http://www.youtube.com/v/B01Qy_BhZjc&hl=es&fs=1&";
YouTube.prototype.pelis[10] = "http://www.youtube.com/v/8y3dhZetdpA&hl=es_ES&fs=1&"

YouTube.prototype.contenedor = "pantalla";

/* METODOS */

YouTube.prototype.setPeli = function(){
		this.parent.cargando.style.display = "block";
	var so = new SWFObject(this.pelis[arguments[0]], "part de cero", "254", "206", "9", "#FF6600");
		so.addParam("movie", this.pelis[arguments[0]]);
		so.addParam("wmode", "transparent");
		so.write(this.contenedor);
		this.parent.visualizar(true);
}
Fulanos.prototype.luzSW = function(){
	this.sw	= true;
	if( this.encendido ){
		this.encendido = false;
		this.fuente.style.visibility = "visible";
	} else {
		this.encendido = true;
		this.fuente.style.visibility = "hidden";
	}
	this.timer = setTimeout( this.obj + ".luzSW()" , this.freq);
	return;	
}
Fulanos.prototype.luz = function(){
	if( !arguments[0] ){
		this.over = false;
		this.sw = false;
		clearTimeout(this.timer);
		this.timer = null;
		if( !this.clic )this.fuente.style.visibility = "hidden";
		else this.fuente.style.visibility = "visible";
		
	} else if( !this.over ) {
		this.sw	= true;
		this.over = true;
		if( this.timer != null )this.timer = null;
		if( this.encendido ){
			this.encendido = false;
			this.fuente.style.visibility = "visible";
		} else {
			this.encendido = true;
			this.fuente.style.visibility = "hidden";
		}
		this.timer = setTimeout( this.obj + ".luzSW()", this.freq);
	}	
	return;
}
Fulanos.prototype.visualizar = function(){
	this.clic = true;
	if(arguments[0]){
		this.hijo.pantalla.style.visibility = "visible";
		this.over = false;
		this.sw = false;
		clearTimeout(this.timer);
		this.timer = null;
		this.fuente.style.visibility = "visible";
	} else this.hijo.pantalla.style.visibility = "hidden";
	
}
Menu.prototype.over = function(){
	arguments[0].src = img_root + arguments[0].id + "-over.png";	
}
Menu.prototype.out = function(){
	arguments[0].src = img_root + arguments[0].id + ".png";	
}


onload = function(){
	obj.fuente = document.getElementById( "luz" );
	obj.hijo.pantalla = document.getElementById( "pantalla" );
	obj.cargando = document.getElementById( "cargandoPeq" );
	obj.youtube.obj = document.getElementById( "pantalla" ).firstChild;
	document.getElementById( "cargando" ).style.display = "none";
	obj.luz(true);
	gobalTimer = setTimeout( "document.getElementById('proyectorImg').onclick()" , obj.freqG);
	
}	