function SwfEmbed()
{
	this.id = "player";
	this.imageid = "placeholder";
	this.flvpath = "/flv/";
	this.swfpath = "/swf/";
	this.mediaplayer = "mediaplayer.swf";
	this.expressinstall = "expressInstall.swf";
	this.allowscriptaccess = "always";
	this.allowfullscreen = "true";
	this.file = '';
	this.width = '';
	this.width = "300";
	this.height = "110";
	this.autostart = "false";
	this.repeat = "false";
	this.flashversion = "9.0.0";
	this.searchbar = "false";
	this.shownavigation = "true";
	this.usefullscreen = "true";
	this.wmode = "transparent";
	this.abouttext = "";
	this.aboutlink = "";
	this.frontcolor = "#ffffff";
	this.lightcolor = "#ffffff";
	this.backcolor = "#333333";
	this.plugins = {};
	this.controlbar = "bottom";
}

SwfEmbed.prototype.addListener = function()
{
	var scope = this;
	var imageid = this.imageid;
	
	jQuery(document).ready(function()
	{
		if( $(imageid) )
		{
			$('#'+imageid).click( function(e)
			{
				scope.embedVideo();
			});
		}
	});
}

SwfEmbed.prototype.setParam = function( key, value )
{
	eval( "this."+ key +"= value;");
}

SwfEmbed.prototype.setParams = function( params )
{
	if( this.isArray )
	{
		for( var key in params )
		{
			eval( "this."+ key +"= params[key]");
		}
	}
	else
	{
		alert('Must be an array.');	
	}
}

SwfEmbed.prototype.isArray = function(obj)
{   
   if (obj.constructor.toString().indexOf("Array") == -1)
	 {
      return false;
	 }
   else
	 {
      return true;
	 }
}

SwfEmbed.prototype.embedSwf = function(){
	var flashvars = {
		width: this.width,
		height: this.height
	};
	
	var params = {wmode: this.wmode};

	var attributes = {};

	swfobject.embedSWF( 
		this.swfpath+this.file, this.id, 
		this.width, this.height, this.flashversion, 
		this.swfpath+this.expressinstall, 
		flashvars, params, attributes 
	);
}

SwfEmbed.prototype.embedVideo = function(){
	var flashvars = {
		file: this.flvpath+this.file,
		image: this.image,
		width: this.width,
		height: this.height,
		searchbar: this.searchbar,
		shownavigation: this.shownavigation,
		usefullscreen: this.usefullscreen,
		abouttext: this.abouttext,
		aboutlink: this.aboutlink,
		frontcolor: this.frontcolor,
		lightcolor: this.lightcolor,
		backcolor: this.backcolor,
		autostart: this.autostart,
		controlbar: this.controlbar,
		repeat: this.repeat
	};
		
	if( this.isArray( this.plugins ) )
	{		
		for ( var key in this.plugins )
		{
			flashvars[key] = this.plugins[key];
		} 
	}
	
	var params = { 
		allowscriptaccess: this.allowscriptaccess, 
		allowfullscreen: this.allowfullscreen, 
		wmode: this.wmode
	};

	var attributes = {};

	swfobject.embedSWF( 
		this.swfpath+this.mediaplayer, this.id, 
		this.width, this.height, this.flashversion, 
		this.swfpath+this.expressinstall, 
		flashvars, params, attributes 
	);
}
