/**
* @author		Jan van der Veen
* @date			2006-05-12
* @description	This script provides Flash Player embedding capabilities for HTML pages. This
*				script was based on the SWFObject scripts conceived by Geoff Stearns. For more
*				information see http://blog.deconcept.com/swfobject/.
*/

// Create the namespaces used by the classes
if (typeof venspro == "undefined"){
	venspro = new Object;	
}
if (typeof venspro.flash == "undefined"){
	venspro.flash = new Object();
}
if (typeof venspro.flash.embed == "undefined"){
	venspro.flash.embed = new Object();
}

// Create the SwfObject constructor
venspro.flash.embed.SwfObject = function(url,id,width,height){
	// Create the array which will hold all attributes and variables
	this.attributes = new Array();
	this.variables = new Array();
	this.parameters = new Array();
	// Set the attributes passed to the constructor
	this.setAttribute("url",url);
	this.setAttribute("id",id);
	this.setAttribute("width",width);
	this.setAttribute("height",height);
	// Check which browser the user is using
	this.isIE = (navigator.appVersion.indexOf("MSIE") != -1);
	this.isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1);
	this.isOpera = (navigator.userAgent.indexOf("Opera") != -1);
}

// Create the methods for the SwfObject
venspro.flash.embed.SwfObject.prototype = {
	
	// Getter/setter for SwfObject attributes
	getAttribute: function(name){
		return this.attributes[name];
	},
	setAttribute: function(name,value){
		this.attributes[name] = value;
	},
	
	// Getter/setter for SwfObject attributes
	getParameter: function(name){
		return this.parameters[name];
	},
	setParameter: function(name,value){
		this.parameters[name] = value;
	},
	
	// Getter/setter for SwfObject variables
	getVariable: function(name){
		return this.variables[name];
	},
	setVariable: function(name,value){
		this.variables[name] = value;
	},
	
	// Gets the variables as a name/value pair string
	getVariablesString: function()
	{
		var pairs = new Array();
		for (i in this.variables)
		{
			pairs.push(i+"="+this.variables[i]);
		}
		return pairs.join("&");
	},
	
	// Gets the HTML markup for embedding the SwfObject onto the page
	getHtmlMarkup: function()
	{
		var markup = "";
		// Check if the user is has a netscape-like browser
		if (this.isIE && this.isWin && !this.isOpera)
		{
			// The user has an Internet Explorer-like browser
			markup += '<object id="'+ this.getAttribute('id'); 
			markup += '" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000';
			markup += '" width="'+ this.getAttribute('width');
			markup += '" height="'+ this.getAttribute('height');
			markup += '">';
			// Add the parameters (if neccessary)
			for (var i in this.parameters)
			{
				markup += '<param name="'+ i +'" value="'+ this.parameters[i] +'" />';
			}
			// Add the variables
			markup += '<param name="movie" value="'+ this.getAttribute('url') +'" />';
			markup += '<param name="flashvars" value="'+ this.getVariablesString() +'" />';
			markup += '</object>'
		}
		else
		{
			// The user has a Netscape-like browser
			markup += '<embed type="application/x-shockwave-flash';
			markup += '" src="'+ this.getAttribute('url');
			markup += '" width="'+ this.getAttribute('width');
			markup += '" height="'+ this.getAttribute('height');
			markup += '" id="'+ this.getAttribute('id');
			markup += '" name="'+ this.getAttribute('id');
			markup += '"';
			// Add the parameters (if neccessary)
			for (var i in this.parameters)
			{
				markup += ' '+i+'="'+this.parameters[i]+'"';
			}
			// Add the variables (if neccessary)
			markup += ' flashvars="'+ this.getVariablesString() +'"';
			// Close the tag
			markup += '/>'
		}
		// Return the compiled markup
		return markup;
	},
	
	writeToElement: function(elementId)
	{
		elementId.innerHTML = this.getHtmlMarkup();
	}
}