//
//  05/05/10	Se mueve a la carpeta lib
//	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  = '/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.Stop = function ()
{
	document.getElementById (this.Nombre).sendEvent("STOP");
}


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

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



