var nextOpaque;
var nextUrlSwf;
var nextPathRoot;
var nextW;
var nextH;

function createFlash(urlSwf, pathRoot, w, h)
{
	nextOpaque = false;
	nextUrlSwf = urlSwf;
	nextPathRoot = pathRoot;
	nextW = w;
	nextH = h;
}
function createOpaqueFlash(urlSwf, pathRoot, w, h)
{
	nextOpaque = true;
	nextUrlSwf = urlSwf;
	nextPathRoot = pathRoot;
	nextW = w;
	nextH = h;
}

function buildFlash()
{
	if (nextOpaque) _createOpaqueFlash(nextUrlSwf, nextPathRoot, nextW, nextH);
	else _createFlash(nextUrlSwf, nextPathRoot, nextW, nextH);
}

function _createFlash(urlSwf, pathRoot, w, h)
{
	if (!document.body.className || document.body.className.indexOf("flashEnabled") < 0)
		return;

	var flashvars = {
		swfPath: pathRoot,
		src: document.location.href,
		fonts: "_swf/fontLibrary.swf",
		css: "_css/style_flash_sp.css",
		swf: urlSwf
	};
	var params = {
		menu: "false",
		scale: "noScale",
		allowscriptaccess: "always"
	};

	swfobject.embedSWF(pathRoot + "_swf/main.swf", "contentFlash", w, h, "9.0.0", pathRoot + "_swf/expressInstall.swf", flashvars, params);
}


function _createOpaqueFlash(urlSwf, pathRoot, w, h)
{
	if (!document.body.className || document.body.className.indexOf("flashEnabled") < 0)
		return;

	var flashvars = {
		swfPath: pathRoot,
		src: document.location.href,
		fonts: "_swf/fontLibrary.swf",
		css: "_css/style_flash_sp.css",
		swf: urlSwf
	};
	var params = {
		menu: "false",
		scale: "noScale",
		allowscriptaccess: "always",
		wmode: "opaque"
	};

	swfobject.embedSWF(pathRoot + "_swf/main.swf", "contentFlash", w, h, "9.0.0", pathRoot + "_swf/expressInstall.swf", flashvars, params);
}


/* The code below just deal with accessibilty functionality - to enable/disable flash on page */
function createCookie(name,value,days)
{
    var expires = "";
	if (days)
    {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		expires = "; expires="+date.toGMTString();
	}
	else expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
    {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
}

function DoAccessibility()
{
    var isCookiePresent = readCookie('accessibility');
    if( isCookiePresent == null ) //no cookie found
    {
        createCookie('accessibility','true',30);       
        location.reload(true);
    }
    else
    {
        eraseCookie('accessibility');
        location.reload(true);
    }
}