gloader.load(["glow", "1", "glow.dom"],{onLoad: function(glow) {
if(typeof bbc === "undefined") window.bbc = {};
bbc.emp_fmtj = function(o){
this._propertiesObj=new bbc.emp_fmtj_properties();
this.playerInstances = new Array();
this._targetFlashVersion = o.version || this._propertiesObj.flashPlayerRequired;
this.isEmpWrittenOnLoad=this._propertiesObj.isEmpWrittenOnLoad;
this.swf=this.getEMPSwf(this._propertiesObj.swfObj);
}
bbc.emp_fmtj.prototype.getEMPSwf = function(swfObj){
var flashVersion = deconcept.SWFObjectUtil.getPlayerVersion();
var swf = swfObj.player8;
if (flashVersion.major < 8) {
swf = swfObj.player7;
} else if ((flashVersion.major == 9 && (flashVersion.minor > 0 || flashVersion.rev >= 115)) || (flashVersion.major > 9)) {
swf = swfObj.player9;
}
var swfURL = swfObj.server+swf;
return swfURL;
}
bbc.emp_fmtj.prototype.getEmpEmbeddedParams = function(domId){
var empParamsObj = {};
empParamsObj["domId"] = domId;
var cssTag = "#"+domId+" param";
var paramNodeList = glow.dom.get(cssTag);
var l=paramNodeList.length;
for (var i=0; i<l; i++){
var p=paramNodeList[i];
if (p.nodeType==1) {empParamsObj[p.name] = p.value;}
}
this.playerInstances[domId]=empParamsObj;
}
bbc.emp_fmtj.prototype.writeAllEmpContent = function(){
var flashVersion = deconcept.SWFObjectUtil.getPlayerVersion();
for (player in this.playerInstances) {
var thisPlayer = this.playerInstances[player];
if(flashVersion.major< this._targetFlashVersion){
this.renderNoFlashContent(thisPlayer);
}else{
this.displayEMP(thisPlayer);
}
}
}
bbc.emp_fmtj.prototype.displayEMP = function(o){
this.so = new SWFObject(this.swf, this._propertiesObj.id, this.height, this.width, this._targetFlashVersion,"#000000");
this.setParam("wmode", this._propertiesObj.wmode);
this.setParam("allowFullScreen", this._propertiesObj.allowFullScreen);
if (this._propertiesObj.skin){
this.setVariable("config_settings_skin", this._propertiesObj.skin);
}
if (this._propertiesObj.showShareButton){
this.setVariable("config_settings_showShareButton", this._propertiesObj.showShareButton);
}
if (this._propertiesObj.config_settings_language){
this.setVariable("config_settings_language", this._propertiesObj.config_settings_language);
}
if (this._propertiesObj.config_settings_showUpdatedInFooter){
this.setVariable("config_settings_showUpdatedInFooter", this._propertiesObj.config_settings_showUpdatedInFooter);
}
this.setVariable("config", this._propertiesObj.configURL);
if (o["playlist"]) {this.setVariable("playlist", this._URLEncode(o["playlist"]))};
this.setVariable("embedReferer", document.referrer);
if (o["fmtjDocURI"]) {this.setVariable("embedPageUrl", o["fmtjDocURI"])};
if (o["id"]) {this.setAttribute("id", o["id"])};
if (!o["height"] && !o["width"]) {
if (o["size"]=="Small") {
this._setDimensions(this._propertiesObj.audioWidthSmall, this._propertiesObj.audioHeight);
} else if (o["size"]=="Full"){
this._setDimensions(this._propertiesObj.audioWidthLarge,this._propertiesObj.audioHeight);
}
} else {
var h= Number(o["height"])+this._propertiesObj.toolbarPadding;
this._setDimensions(o["width"], h);
}
if (o["config_settings_autoPlay"]) {this.setVariable("config_settings_autoPlay", o["config_settings_autoPlay"])};
if (o["config_settings_showPopoutButton"]) {this.setVariable("config_settings_showPopoutButton", o["config_settings_showPopoutButton"])};
if (o["config_settings_showFooter"]) {this.setVariable("config_settings_showFooter", o["config_settings_showFooter"])};
if (o["config_settings_showUpdatedInFooter"]) {this.setVariable("config_settings_showUpdatedInFooter", o["config_settings_showUpdatedInFooter"])};
if (o["config_messages_postLiveAvailabilityTitle"]) {this.setVariable("config_messages_postLiveAvailabilityTitle", o["config_messages_postLiveAvailabilityTitle"])};
if (o["config_messages_postAvailabilityTitle"]) {this.setVariable("config_messages_postAvailabilityTitle", o["config_messages_postAvailabilityTitle"])};
if (o["config_settings_language"]) {this.setVariable("config_settings_language", o["config_settings_language"])};
if (o["config_plugin_fmtjLiveStats_pageType"]) {this.setVariable("config_plugin_fmtjLiveStats_pageType", o["config_plugin_fmtjLiveStats_pageType"])};
if (o["config_plugin_fmtjLiveStats_edition"]) {this.setVariable("config_plugin_fmtjLiveStats_edition", o["config_plugin_fmtjLiveStats_edition"])};
if (o["config_settings_showShareButton"]) {this.setVariable("config_settings_showShareButton", o["config_settings_showShareButton"])};
if (o["config_settings_skin"]) {this.setVariable("config_settings_skin", o["config_settings_skin"])};
if (typeof BBC === "object" && typeof BBC.adverts.empCompanion === 'function') {
this.setVariable("preroll", BBC.adverts.empCompanion());
this.setVariable("companionSize", this._propertiesObj.companionSize);
this.setVariable("companionType", this._propertiesObj.companionType);
if (o["companionId"]) {this.setVariable("companionId", o["companionId"])};
if (o["config_settings_suppressItemKind"]) {this.setVariable("config_settings_suppressItemKind", o["config_settings_suppressItemKind"])};
};
var domId = o["domId"];
this.so.write(domId);
}
bbc.emp_fmtj.prototype.changeStreamInEmp = function(playlist,domId){
this.playerInstances[domId].playlist=playlist;
var thisPlayer = this.playerInstances[domId];
this.displayEMP(thisPlayer);
}
bbc.emp_fmtj.prototype._setDimensions = function(w,h){
this.setAttribute("width", w);
this.setAttribute("height", h);
}
bbc.emp_fmtj.prototype.setAttribute = function(key, value){
this.so.setAttribute(key, value);
}
bbc.emp_fmtj.prototype.setParam = function(key, value){
this.so.addParam(key, value);
}
bbc.emp_fmtj.prototype.setVariable = function(key, value){
this.so.addVariable(key, value);
}
bbc.emp_fmtj.prototype.renderNoFlashContent = function(paramObj){
var noFlashNode = glow.dom.get("#"+paramObj.domId);
var noFlashHTML=this._propertiesObj.getNoFlashHTML(paramObj)
noFlashNode.append(noFlashHTML);
}
bbc.emp_fmtj.prototype.isFlashVersionValid = function(version)
{
var v = version || this._targetFlashVersion;
var valid = true;
if(v != null)
{
var detection = deconcept.SWFObjectUtil.getPlayerVersion();
var assets = [detection.major, detection.minor, detection.rev];
if (typeof(v) == 'number') {
v = v.toString()
}
var targets = v.split(".");
for(var i = 0; i < targets.length; ++i)
{
var target = parseInt(targets[i]);
if(i < assets.length)
{
var asset = parseInt(assets[i]);
if(target > asset)
{
valid = false;
break;
}
else if(asset > target)
{
break;
}
}
else
{
if(target > 0)
{
valid = false;
break;
}
}
}
}
return valid;
}
bbc.emp_fmtj.prototype._URLEncode = function(clearString){
var output = '';
var x = 0;
clearString = clearString.toString();
var regex = /(^[a-zA-Z0-9_.]*)/;
while (x < clearString.length) {
var match = regex.exec(clearString.substr(x));
if (match != null && match.length > 1 && match[1] != '') {
output += match[1];
x += match[1].length;
} else {
if (clearString[x] == ' ') {
output += '+';
} else {
var charCode = clearString.charCodeAt(x);
var hexVal = charCode.toString(16);
output += '%' + (hexVal.length < 2 ? '0' : '') + hexVal.toUpperCase();
}
x++;
}
}
return output;
}
}
}
);
var embeddedMedia = { console: function(){
var that = this;
var thatParams;
var popVidHeight;
var popWinHeight;
var popVidWidth;
that.notifyParent=null;
that.theLssrc=null;
that.popoutVideo = function( theParams, theHeight, theWidth, theMode ){
thatParams=theParams;
var footerHeight = 77;
popVidHeight = parseInt(theHeight) + footerHeight
popWinHeight = parseInt(theHeight) + 35 + footerHeight
popVidWidth = parseInt(theWidth);
if(that.theLssrc==null){
var hasLs = document.getElementById("livestats");
if(hasLs != undefined){
that.theLssrc=hasLs.getAttribute('src');
}
}
if (!that.notifyParent) {
that.notifyParent = function(theWin){theWin.updatePlayer(thatParams, popVidWidth, popVidHeight, theMode, that.theLssrc);}
}
var paramsStr = 'height='+popWinHeight+', width='+popVidWidth+', scrollbars="no", resizable="no", toolbar="no", left=100, top=100, location=0, menubar=0';
var popWindow = window.open("http://news.bbc.co.uk/player/emp/pop.stm", "emppop", paramsStr);
if (!popWindow.opener) {popWindow.opener = window.self;}
if (window.focus) {popWindow.focus();}
}
return that;
}()
};