/*
	Compatibile XHTML Flash displayer
	Author 	: Razvan Stanga
	Date 	: 2006-03-07 17:39
*/

function Flash () {
    this._id = '';
	this._swf = '';
	this._width = 0;
	this._height = 0;
	this._version = 9;
	this._params = new Array();
	this._isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
	this._isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
	this._isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
	this._isFirefox = (navigator.userAgent.indexOf("Firefox") != -1) ? true : false;
	
}

Flash.prototype.setSWF = function (_swf, _width, _height, _version) {
	this._swf 		= _swf;
	_id 			= this._swf.split ("/");
	this._id        = _id[ _id.length-1 ];
	this._id        = this._id.replace(".swf", "");
	this._width 	= _width;
	this._height 	= _height;
	if ( isNaN (_version) == false ) {
		this._version 	= _version;
	}
}

Flash.prototype.setParam = function (paramName, paramValue) {
	this._params[this._params.length] = paramName+'|||'+paramValue;
}

Flash.prototype.display = function (divid) {
	var _txt 	= '';
	var params 	= '';
	
  	if (this._isIE && this._isWin && !this._isOpera) {
		_txt += '<object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+this._version+',0,0,0" width="'+this._width+'" height="'+this._height+'" align="middle" id="'+this._id+'" name="'+this._id+'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" >\n';
		_txt += '<param name="movie" width="'+this._width+'" height="'+this._height+'" value="'+this._swf+'" />\n'
		_txt += '<param name="quality" value="high" />\n';
		_txt += '<param name="devicefont" value="false" />\n';
		for ( i=0;i<this._params.length;i++ ) {
			_param = this._params[i].split ('|||');
			_txt += '\t<param name="'+_param[0]+'" value="'+_param[1]+'" />\n';
			params += _param[0]+'="'+_param[1]+'" ';
		}
		_txt += '</object>\n';
	} else {
		for ( i=0;i<this._params.length;i++ ) {
			_param = this._params[i].split ('|||');
			params += _param[0]+'="'+_param[1]+'" ';
		}
		_txt += '<embed width="'+this._width+'" height="'+this._height+'" src="'+this._swf+'" '+params+' quality="high" devicefont="false" id="'+this._id+'" name="'+this._id+'" type="application/x-shockwave-flash"></embed>\n';
	}
	if ( divid == undefined ) {
	    document.write (_txt);
	} else {
		$_div = document.getElementById (divid);
		$_div.innerHTML = _txt;
	}
	
}
