//
//	22/03/10	Se aņade el elemento id al objeto embeded
//	22/03/10	Se aņade el metodo stop
//

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  = '/js/swf/jwplayer.swf';
TVideo.prototype.Skin    = '';
TVideo.prototype.Video   = '';

TVideo.prototype._Instancia = 0;


TVideo.prototype._addParam = function (sParam, sValue)
{
	var Aux = document.createElement ('param');

	Aux.setAttribute ('name', sParam);
	Aux.setAttribute ('value', sValue);
	return Aux;
}


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 (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 + 20) + '">' +
		                '<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 Obj = document.createElement ('object');
		var Emb = document.createElement ('embed', 'wmode');

		Obj.setAttribute ('classid',  'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000');
		Obj.setAttribute ('codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9.0.115');
		Obj.setAttribute ('width', this.Ancho);
		Obj.setAttribute ('height', this.Alto);

		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 + 20);
		Emb.setAttribute ('src', this.Player);
		Emb.setAttribute ('allowfullscreen', 'true');
		Emb.setAttribute ('allowscriptaccess', 'always');
		Emb.setAttribute ('wmode', 'transparent');
		Emb.setAttribute ('flashvars', this._FlashVars ());
		Obj.appendChild (Emb);
		Div.appendChild (Obj);
	}
	this.Cargado = true;
}


TVideo.prototype._FlashVars = function ()
{
	var Aux = '';
	
	Aux += 'autostart=' + (this.Empezar ? 'true' : 'false');
	Aux += '&bufferlength=10';
	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.Stop = function ()
{
	var oVideo = document.getElementById (this.Nombre);
	
	if (oVideo && oVideo.sendEvent) oVideo.sendEvent("STOP");
}


function TVideo ()
{
	this._Instancia = TVideo.Instancias++;
}

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



