/* $Id: flashControl.js,v 1.1 2006/12/13 12:05:12 rbernaczek Exp $ */
/**
 * version: 1.2
 */

flash_versions = 20;

var flash = new Object();
flash.installed=false;
flash.version='0.0';

if (navigator.plugins && navigator.plugins.length) {
	for (x=0; x < navigator.plugins.length; x++) {
		if (navigator.plugins[x].name.indexOf('Shockwave Flash') != -1) {
			flash.version = navigator.plugins[x].description.split('Shockwave Flash ')[1];
			flash.installed = true;
			break;
		}
	}
}
else if (window.ActiveXObject) {
	for (x = 2; x <= flash_versions; x++) {
		try {
			oFlash = eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash." + x + "');");
			if(oFlash) {
				flash.installed = true;
				flash.version = x + '.0';
			}
		}
		catch(e) {}
	}
}

function flashControl(src,width,height){
	this.src				= src;
	this.width				= width;
	this.height				= height;
	this.id					= null;
	this.wmode				= 'transparent';
	this.bgcolor			= 'ffffff';
	this.flashVars			= null;
	this.fla_installed		= flash.installed;
	this.fla_version		= flash.version;
	this.alt_image			= null;
	this.alt_url			= null;
	this.alt_test			= null;
	this.flash				= null;
	this.containerId		= null;
	this.containerObj		= null;
}

flashControl.prototype.init = function(){
	if (this.fla_installed)
		this.writeFlash();
	else
		this.writeImg();
};

flashControl.prototype.writeFlash = function(){
	this.flash = new FlashTag(this.src, this.width, this.height);
	this.flash.flashVars = this.flashVars;
	this.flash.bgcolor = this.bgcolor;
	
	if (this.containerId){
		this.containerObj = document.getElementById(this.containerId);
		if (this.containerObj) {
			this.containerObj.innerHTML = this.flash.toString();
		} else {
			alert("FlashControl\nElement " + this.containerId + "no exist!");
		}
	} else 
		document.write(this.flash.toString());
};

flashControl.prototype.writeImg = function(){
	if (this.alt_image)
		document.write(this.createImage())
};

flashControl.prototype.createImage = function(){
	var doc = "<img src='" + this.alt_image + "' alt='" + this.alt_test + "'/>";
	if (this.alt_url){
		doc = "<a href='" + this.alt_url + "'>" + doc + "</a>";
	}
		
	return doc;
};



