/* **************************************************************
*                         --XJS--	                            *
* Desenvolvedora: Rhianna Cantarelli							*
* Versão: 1.5													*
* Data: 17.05.2007												*
* Email: r.rhianna@yahoo.com.br									*
************************************************************** */







/* **************************************************************
Cria um objeto responsavel por armazenar as propriedades de um 
filme flash para posterior amostra

Métodos: 
	.setObject(thisID, thisClass, thisTitle, w, h) : Inicia objeto com Informações Básicas
	.setQuality(q) : Seta qualidade se ela for diferente do default 'high'
	.setTransparency() : Seta fundo transparente
	.addFlashVars(name, value) : Adiciona uma ou mais flashvars
	
	.showFlash(where) : Adiciona o objeto criado ao local indicado por ID, se...
		where = 'here' adiciona ao mesmo local onde está o código JS
		where = 'alert' mostra a string criada em forma de alert
	
	.fontReplace(getTagByClass, searchTag) : faz a substituição de todo conteudo de
		uma dada tag com determinada classe pelo filme em questão.
		O filme receberá automaticamente uma flashvar chamada 'tagInside' 
		com o valor do conteudo de innerHTML da tag
************************************************************** */
function objFlash(srcSWF){
	this.scr = srcSWF;
	this.id = '';
	this.classe = '';
	this.title = '';
	this.width = '';
	this.height = '';
	this.quality = '<param name="quality" value="high" />';
	this.transparency = '';
	this.param = '<param name="allowScriptAccess" value="sameDomain" />';
	this.alternate = '<div class="xjs_AltFlash">' + xjs_AltFlash + '</div>';
	this.flashvars = '';
	strSwf = '';


	this.setObject = function(thisID, thisClass, thisTitle, w, h) {
		this.id = thisID;
		this.classe = thisClass;
		this.title = thisTitle;
		this.width = w;
		this.height = h;
	};
	this.setQuality = function(q) { this.quality = '<param name="quality" value="'+ q +'" />'; };
	this.setTransparency = function() { this.transparency += '<param name="wmode" value="transparent">'; };


	this.addFlashVars = function(name, value) { 
		// Verifica se já há alguma variavel setada e adiciona o '&' para a próxima
		if(this.flashvars != '' && this.flashvars.indexOf('=') != -1) { this.flashvars += '&'; }
		this.flashvars += name +'='+ value;
	};
	this.addParam = function(name, value) { this.param += '<param name="' + name + '" value="' + value + '" />'; };


	this.clearFlashVars = function() { this.flashvars = ''; };
	this.clearParam = function() { this.param = '<param name="allowScriptAccess" value="sameDomain" />'; };
	this.clearTransparency = function() { this.transparency = ''; };


	this.createString = function () {
		// Inicia Tag Object
		strSwf = '<object ';
		
		if(xjs_browser.type == 'IE') {
			strSwf += 'classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
			strSwf += 'codebase="http://www.adobe.com/br/shockwave/download/alternates/" ';
			this.addParam('movie', this.scr);
		}
		else {
			strSwf += 'type="application/x-shockwave-flash" ';
			strSwf += 'data="'+ this.scr +'" ';
		}

		// Adiciona Propriedades Básicas
		if (this.id != '') { strSwf += 'id="' + this.id + '" '; }
		if (this.classe != '') { strSwf += 'class="' + this.classe + '" '; }
		if (this.title != '') { strSwf += 'title="' + this.title + '" '; }

		strSwf += 'width="' + this.width + '" ';
		strSwf += 'height="' + this.height + '" ';
		strSwf += '>';

		if(this.flashvars != '') { this.addParam('flashvars', this.flashvars); }
		strParam = this.quality + this.transparency + this.param;
		
		strSwf += strParam + this.alternate + '</object>';
	};

	
	this.showFlash = function(where) {
		this.createString();
		
		if(where == 'here') { document.write(strSwf); }
		else if(where == 'alert') {alert(strSwf); }
		else { id(where).innerHTML = strSwf; }
	};
	
	
	this.fontReplace = function(getTagByClass, searchTag) {
		getTag = new Array;	
		getTag = getElementsByClassName(getTagByClass, searchTag);

		for (f=0; f<getTag.length; f++)
		{
			if (xjsBool_SuportFlash == true) {
				content = getTag[f].innerHTML; 
				this.title = content;
				
				this.clearFlashVars();
				this.clearParam();
				
				this.addFlashVars('tagInside', content);

				this.createString();
				getTag[f].innerHTML = strSwf;
			}
			// Para não 'piscar' defina que a classe para troca tem visibility=hidden
			getTag[f].style.visibility = 'visible';
        } 
    };
}