/******************************
* @Copyright:Onamix.com
* @note: Not for commercial use unless rights given
* @description: SwfObject Extension
* @file: scripts/fms_wfobject.js
* @version: 1.2
* @Created: 8/2/2007
* @Updated: 3/14/2010
******************************/

// if not predefined. then we add
if (!upgradeMsg) 
{
	var upgradeMsg = '<a href="http://get.adobe.com/flashplayer" target="getflashplayer">You need to install/upgrade your Flash Player</a>. ';
};

// string, string, obj, obj
function getSWFUpgradeMsg()
{
//alert(getLocation());
	var tmp = upgradeMsg + '<br />If you think you have the correct flash version please <a href="'+getLocation()+'">force load Flash here</a>';
	return tmp;
};

function getLocation() 
{
    return document.location + '?detectflash=false&' + document.location.search;
};

function fmInsertSwf(f, c, o) 
{
	var result;
	var id = 'swfobj_'+Math.random()*1000000;
	if (o.id) id = o.id;
	if (typeof(o)!='undefined')
	{
		if (typeof(o)!="object") 
		{
		    alert('Invalid object specified!');
		    return;
		}
	}
	if (typeof(c)!="object") 
	{
		alert('Canvas must be an object!');
		return;
	}
	if (typeof(o)=='undefined') o = {};
	if (typeof(o.version)=='undefined') o.version = 9.0;
	if (typeof(o.bgcolor)=='undefined') 
	{
		o.bgcolor = '';
	} else {
	    o.bgcolor = '#'+o.bgcolor;
	}
	
	if (typeof(o.flashvars)!='undefined')
	{
		if (o.flashvars.length>0) var _vars = o.flashvars;
	} else {
	    var _vars = [];
	}
	
	if (typeof(o.params)!='undefined')
	{
		if (o.params.length>0) var _params = o.params;
	} else {
	    var _params = [];
	}
	var so = new SWFObject(f, id, c.width, c.height, o.version, o.bgcolor, true);
	for (var i = 0; i <_vars.length; i++) 
	{
		so.addVariable(_vars[i].name, _vars[i].value);
	}
	so.addParam("allowFullScreen", "true");
	for (var i = 0; i <_params.length; i++) 
	{
		so.addParam(_params[i].name, _params[i].value);
	}
	if (typeof(o.allowScript)!='undefined') 
	{
		if (o.allowScript==false) 
		{
			so.addParam("allowScriptAccess", "never");
		}
	}
	result = so.write(id);
	if (!result && !o.useCustomUpgradeMsg) 
	{
		$(o).html('<div id="'+ id +'_layer" class="onaAlert">'+ getSWFUpgradeMsg() +'</div>');
	}
	return result;
};


// Customizable
function fmSwfObject(f, c, o)
{
	return fmInsertSwf(f, c, o);
};


