String.prototype.trim = function() {
	return this.replace(/^\s*|\s(?=\s)|\s*$/g, "");
}

var getFlashMsg = new Array();
var getFlashBtnURL = new Array();

var getFlashBtnCode = '<a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" target="_blank" name="&lid=Anypage_GetOrUpgradeFlashButton"><img src="%GET_FLASH_BTN_URL%" alt="Get Adobe Flash" border="0" /></a>';
getFlashMsg['Default'] = '<p><br /><b>Adobe Flash Player %VERSION%</b> or newer is required to view some elements of this page.<br /><br />'+getFlashBtnCode+'</p>';

getFlashBtnURL['#000000'] = "";
getFlashBtnURL['#FFFFFF'] = "/images/theme/get_flash.gif";
getFlashBtnURL['#666666'] = "";

function getGetFlashMsg(pageBgcolor, messageId, version) {
	var customMsg = getFlashMsg[messageId];
	customMsg = customMsg.replace("%VERSION%", version);
	customMsg = customMsg.replace("%GET_FLASH_BTN_URL%", getFlashBtnURL[pageBgcolor.toUpperCase()]);
	return customMsg;
}


function quickSwfObject(url, id, width, height, version, flashBgcolor, pageBgcolor, messageId, flashParameters, variables) {
	if (!getFlashMsg[messageId]) {
		messageId = "Default";
	}
	if(!pageBgcolor) {
		pageBgcolor = flashBgcolor;
	}
	document.write('<div id="'+id+'" style="width: '+width+'px; height: '+height+'px;" class="flashObject">'+getGetFlashMsg(pageBgcolor, messageId, version)+'</div>');
	so = new SWFObject(url, id+'Object', width, height, version, flashBgcolor);
	if (variables) {
		var variablesArray = variables.split(";");
		if (variablesArray.length > 0) {
			var i = 0;
			while (i < variablesArray.length) {
				var thisVariableArray = variablesArray[i].split("=");
				if (thisVariableArray.length == 2) {
					var variable = thisVariableArray[0].trim();
					var value = thisVariableArray[1].trim();					
					so.addVariable(variable, value);
				}
				i++;
			}
		}
	}
	if (flashParameters) {
		var parametersArray = flashParameters.split(";");
		if (parametersArray.length > 0) {
			var i = 0;
			while (i < parametersArray.length) {
				var thisParameterArray = parametersArray[i].split("=");
				if (thisParameterArray.length == 2) {
					var parameter = thisParameterArray[0].trim();
					var value = thisParameterArray[1].trim();					
					so.addParam(parameter, value);
				}
				i++;
			}
		}
	}
	so.write(id);
}