
TPano.Instancias = 1;

TPano.prototype.Alto       = 800;
TPano.prototype.Ancho      = 535;
TPano.prototype.Cargado    = false;
TPano.prototype.Nombre     = '';
TPano.prototype.Pano       = '/lib/panoramicas/krpano.swf';
TPano.prototype.Panoramica = '';

TPano.prototype._Instancia   = 0;
TPano.prototype._oPano       = null;


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


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


TPano.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 = 'Pano_' + this._Instancia;
	if (window.ActiveXObject) // IE
	{	Div.innerHTML = '<object id="' + 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.Pano + '">' +
		                '<param name="allowfullscreen" value="true">' +
		                '<param name="allowscriptaccess" value="always">' +
		                '<param name="wmode" value="transparent">' +
		                '<param name="flashvars" value="' + this._FlashVars () + '">' +
		                '</object>';
		this._oPano = document.getElementById (this.Nombre);		                
	} else
	{	var Emb = document.createElement ('embed', 'wmode');
		
		Emb.setAttribute ('name', this.Nombre);
		Emb.setAttribute ('id', 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.Pano);
		Emb.setAttribute ('allowfullscreen', 'true');
		Emb.setAttribute ('allowscriptaccess', 'always');
		Emb.setAttribute ('wmode', 'transparent');
		Emb.setAttribute ('flashvars', this._FlashVars ());
		Div.appendChild (Emb);
		this._oPano = Emb;
	}
	this.Cargado = true;
}


TPano.prototype._FlashVars = function ()
{
	var Aux = '';
	
	if (! this.Panoramica) alert ('Tiene que indicar una panorámica.');
	Aux += 'pano=' + this.Panoramica;
//	Aux += '&fullscreen=true';
	return Aux;
}


TPano.prototype.loadXML = function (sXML)
{
	this._oPano.call("loadpano(" + sXML + ",null,keepbase,blend(1));)");
}
