/**
 * Description:
 * 		Wyswietla plik flasha.		
 *
 * Used: IE, FF, Opera
 *
 * Example:
 *		DisplayFlash.init({src: 'pliki/myFlash.swf', width: 400, height: 80});
 *		lub
 *		var df = new DisplayFlash({src: 'pliki/myFlash.swf', width: 400, height: 80});
 *		df.insertCode();
 *		
 * Version: 1.00 2005/07/18
 */
 

DisplayFlash = function(params){
	this.classid = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000';
	
	this.params = {
		id: '',
		src: '',
		width: 100,
		height: 100,
		quality: 'high',
		wmode: 'transparent',
		bgcolor: '#ffffff',
		allowScriptAccess: 'sameDomain'
	};
	
	for(var i in params){
		this.params[i] = params[i];
	}
};

DisplayFlash.pathToViewerFLV = 'flash/viewer.swf?path=../';

//--- public static
DisplayFlash.init = function(params){
	var df = new DisplayFlash(params);
	df.insertCode();
	return df; // df.getId();
};

//--- public
DisplayFlash.prototype.insertCode = function(){
	var src = this.params['src'];
	//alert(Service.getSuffix(src));
	
	if(Service.getSuffix(src) == 'flv'){
		src = DisplayFlash.pathToViewerFLV + src;
		//alert(src);
	}

	var code = '<object id="' + this.params['id'] + '" classid="' + this.classid + '" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="' + this.params['width'] + '" height="' + this.params['height'] + '">' +
	'<param name="movie" value="' + src + '" />' +
	'<param name="quality" value="' + this.params['quality'] + '" />' +
	'<param name="wmode" value="' + this.params['wmode'] + '" />' +
	'<param name="bgcolor" value="' + this.params['bgcolor'] + '" />' +
	'<param name="allowScriptAccess" value="' + this.params['allowScriptAccess'] + '" />' +
	'<embed name="' + this.params['id'] + '" src="' + src + '" quality="' + this.params['quality'] + '" wmode="' + this.params['wmode'] + '" bgcolor="' + this.params['bgcolor'] + '" width="' + this.params['width'] + '" height="' + this.params['height'] + '" allowScriptAccess="' + this.params['allowScriptAccess'] + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>' +
	'</object>';
	
	document.write(code);
};

//--- public
DisplayFlash.prototype.setParam = function(key, value){
	this.params[key] = value;
};

//--- public
DisplayFlash.prototype.getParam = function(key){
	return this.params[key];
};

//--- public
DisplayFlash.prototype.getId = function(){
	return this.getParam('id');
};