//	11/11/2010
//

TVideo.instancias = 1;

TVideo.prototype.alto    = 290;
TVideo.prototype.ancho   = 480;
TVideo.prototype.cargado = false;
TVideo.prototype.empezar = false;
TVideo.prototype.iconos  = true;
TVideo.prototype.imagen  = '';
TVideo.prototype.nombre  = '';
TVideo.prototype.player  = '/lib/videos/jwplayer.swf';
TVideo.prototype.skin    = '';
TVideo.prototype.video   = '';

TVideo.prototype._instancia = 0;


TVideo.prototype.cargar = function (vContenedor)
{
	var Div = null;

	if (typeof (vContenedor) == 'string') Div = document.getElementById (vContenedor);
	else if (typeof (vContenedor) == 'object') Div = vContenedor;
	else alert ('No se ha encontrado el contenedor.');

	if (! this.nombre) this.nombre = 'Video_' + this._instancia;
	if (Div)
	{	if (window.ActiveXObject) // IE
		{	Div.innerHTML = '<object id="' + this.nombre + '" name="' + this.nombre + '"' +
			                ' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
		  	              ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9.0.115"' +
		    	            ' width="' + this.ancho + '"' +
		      	          ' height="' + this.alto + '">' +
		        	        '<param name="movie" value="' + this.player + '">' +
		          	      '<param name="allowfullscreen" value="true">' +
		            	    '<param name="allowscriptaccess" value="always">' +
		              	  '<param name="wmode" value="transparent">' +
		                	'<param name="flashvars" value="' + this._FlashVars () + '">' +
		                	'</object>';
		} else
		{	var Emb = document.createElement ('embed', 'wmode');

			Emb.setAttribute ('id', this.nombre);
			Emb.setAttribute ('name', this.nombre);
			Emb.setAttribute ('type', 'application/x-shockwave-flash');
			Emb.setAttribute ('pluginspage', 'http://www.macromedia.com/go/getflashplayer');
			Emb.setAttribute ('width', this.ancho);
			Emb.setAttribute ('height', this.alto);
			Emb.setAttribute ('src', this.player);
			Emb.setAttribute ('allowfullscreen', 'true');
			Emb.setAttribute ('allowscriptaccess', 'always');
			Emb.setAttribute ('wmode', 'transparent');
			Emb.setAttribute ('flashvars', this._FlashVars ());
			Div.appendChild (Emb);
		}
		this.cargado = true;
	}
}


TVideo.prototype._FlashVars = function ()
{
	var Aux = '';
	
	Aux += 'autostart=' + (this.empezar ? 'true' : 'false');
	Aux += '&fullscreen=true';
	Aux += '&stretching=uniform';
	Aux += '&icons=' + (this.iconos ? 'true' : 'false');
	
	if (this.video)  Aux += '&file=' + this.video;
	if (this.imagen) Aux += '&image=' + this.imagen;
	if (this.skin)   Aux += '&skin=' + this.skin;
	return Aux;
}


TVideo.prototype.load = function (movie)
{
	var player = document.getElementById (this.nombre);
	
	if (player)
	{	player.sendEvent ('LOAD', movie);
		player.sendEvent("PLAY","true");
	}
}


TVideo.prototype.stop = function ()
{
	document.getElementById (this.nombre).sendEvent("STOP");
}


function TVideo ()
{
	this._instancia = TVideo.instancias++;
}

/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////




