//player.js v1.15 (16/7/07,08:10)
newsi.Console=function(obj,stories,recObj){
window.focus();
if(newsi.RecommendedStories){this._recStoriesObject=newsi.RecommendedStories;}
this.sI=0;	
this._site=this._getSite();
this.index = 0;
this._hasScripting=false;
this.HTMLElementWithID = new Object();
this.HTMLElement = new Object();
this.cssData = new Object();
this.dom = new Object();
this.el = new Object();
this.bm = new Object();
this.po = new Object();
this.staf = new Object();
this.arr = new Object();
this._canLaunchOpener = true;
this._hWndOpened = false;
this._initOpener();
this._tz = false;
this._resizeWindow(675,540);
this._mediaObject=obj;
this._storiesObject=stories;
if(recObj[0]){
	this._recommendedObject=recObj;
	this._concatStories();
	}
this.linkColor="#fff";
//check the browser can do this - this is actually the entry point
this._checkFunctionality();
}
newsi.Console.prototype=newsi;
newsi.Console.prototype._initOpener=function(){
	if(window.opener){
		this._oOpener = new Object();
		var tryBlock = "try{window.opener.location.href;}catch(e){this._canLaunchOpener = false;}";
		this.tryFunc = new Function(tryBlock);
		this.tryFunc();
		if(this._canLaunchOpener){
			this._oOpener.href = window.opener.location.href;
			this._oOpener.width = this._getOpenerWidth();
			this._oOpener.height = this._getOpenerHeight();
			this._oOpener.x = (window.screenLeft)?window.opener.screenLeft:window.opener.screenX;
			this._oOpener.y = (window.screenTop)?window.opener.screenTop:window.opener.screenY;
			}
		}
	}
newsi.Console.prototype._getSupportedFeatures=function(){
	if (window.opener.innerWidth){return "innerWidth";} 
	else if (window.opener.document.documentElement && window.opener.document.documentElement.clientWidth){return "documentElement";} 
	else if (window.opener.document.body){return "documentbody";}
	return false;
	}
newsi.Console.prototype._getOpenerWidth=function(){
	var features=this._getSupportedFeatures();
	var w=0;
	var wo=window.opener;
	switch(features){
		case "innerWidth": w = wo.outerWidth;break;
		case "documentElement": w = wo.document.documentElement.clientWidth;break;
		case "documentbody": w = wo.document.body.clientWidth;break;
		}
	if (document.layers){w -= window.opener.outerWidth - window.opener.innerWidth;}
	return w;
	}
newsi.Console.prototype._getOpenerHeight=function(){
	var features=this._getSupportedFeatures();
	var h=0;
	var wo=window.opener;
	switch(features){
		case "innerWidth": h = wo.outerHeight;break;
		case "documentElement": h = wo.document.documentElement.clientHeight;break;
		case "documentbody": h = wo.document.body.clientHeight;break;
		}
	if (document.layers){h -= wo.outerHeight - wo.innerHeight;}
	return h;
}
newsi.Console.prototype._concatStories=function(){
	this._mediaObject=this._mediaObject.concat(this._recommendedObject);
	this._storiesObject=this._storiesObject.concat(this._recStoriesObject);
	}
newsi.Console.prototype._getSite=function(){
	if(document.title.search("BBC Sport Player")!=-1){return "sport";}
	if(document.title.search("BBC News Player")!=-1){return "news";}
	return "news";
	}
newsi.Console.prototype._resizeWindow=function(w,h){
	var offsetX=0;
	var offsetY=0;
	if(window.opener){window.resizeTo(w,h);}
	}
newsi.Console.prototype._checkFunctionality=function(){
	if(this.hasActiveX()){
		if(this.hasDOM() && this.true1_5){
			this.initStacker();
			this._setupForLatestBrowsers();																																							// S off
			}
		else{
			//old IE browser
			}
		}	
		else{	
			//no ActiveX (Mozilla - based and Mac OK)
			if(this.hasDOM() && this.true1_5){
				this.initStacker();
				this._setupForLatestBrowsers();																																							// S off
				}
			else{
			// old browser
			}
		}
	}
newsi.Console.prototype.initStacker=function(){
	this._queryString();
	this.HTMLElementWithId = {
		playerwindow:"playerwindow",
		content:"mediacontent",
		stories:"storylists",
		player:"player",
		nav:"navigation",
		options:"playeroptions",
		index:"indexitems",
		mainstory:"primary",
		related:"related",
		recom:"recommended",
		iItems:"indexitems",
		legacy:"legacy",
		terms:"terms",
		privacy:"privacy",
		feedback:"feedback",
		copyright:"copyright",
		help:"help",
		logo:"logo",
		email:"emailafriend"
		}
	this.HTMLElement = {
		head1:"h1",
		head2:"h2",
		head3:"h3",
		a:"a",
		summary:"div",
		list:"ol",
		li:"li",
		ul:"ul"
		}		
	this.cssData={
		storyItem:{
			Open:{audio:"storyItemOpenAudio",video:"storyItemOpenVideo"},
			Closed:{audio:"storyItemClosedAudio",video:"storyItemClosedVideo"}
		},
		storyItemOpen:"storyItemOpen",
		storyItemClosed:"storyItemClosed"
		}	
	this.po=new newsi.PlayerObject();
	this.dom = new newsi.HTML.DOM(this.HTMLElementWithId);
	if(this.dom.e_gebid("iphome") ){
		this.dom.moreAV = this.dom.e_gebid("iphome");
		}
	else{
		this.dom.moreAV = this.dom.e_gebid("moreva");
		}
	this.el=this.HTMLElement;
	this.bm=new newsi.Console.ButtonManager({domObj:this.dom,elObj:this.el,callingObj:this});		
	this.cs=new newsi.ConsoleStacker(this.dom,this.el,this.cssData);
	//this.staf=new newsi.Console.STAF(this); // if uk user ETP is set up...
	if(!document.all && !window.XMLHttpRequest && !this.po.flavour=="rm"){
		this._removeLegacyContent();
		}
	//look to disable stories based on users settings
	this._checkRegionalSettings("international");
	this.dom.setId({el:this.bm.thisElement({parent:this.dom.options,el:this.el.li,index:0}),id:"standalone"});
	//call init on ConsoleStacker...
	this.cs.init(this,this._mediaObject);
	this.arr=this.cs.arr;
	this._setUpChapterisation();
	}
newsi.Console.prototype.setRollover=function(o){
	this.bm.addEvent({evType:"onmouseover",id:o.id,method:"addClass",arg:o.id});
	this.bm.addEvent({evType:"onmouseout",id:o.id,method:"takeOffClass",arg:o.id});
	}
newsi.Console.prototype.addClass=function(o){this.dom.setClass({el:this.dom.e_gebid(o[0]),className:"jshover"})}
newsi.Console.prototype.takeOffClass=function(o){this.dom.removeClass({el:this.dom.e_gebid(o[0]),className:"jshover"})}
newsi.Console.prototype._checkRegionalSettings=function(item){
	//_tz is a class level timezone var boolean
	this._tz=this._domesticTimezone();
	//local length of mediastories array
	var len=this._mediaObject.length;
	var i=1;
	//for every story, call closeLinkAnd Diable
	while(i < len){
		var k=0;
		//var audiencelen = this._mediaObject[i].audience.length;
		this.closeLinkAndDisable(item,i);
		i++;
		}
	if(this.dom.related){
		if(this._hasRedundantHeader(this.dom.related)){this._hideHeader(1);}
		if(this._hasRedundantRecommendedHeader(this.dom.recom)){this._hideHeader(2);}
		}
	else{
		if(this._hasRedundantRecommendedHeader(this.dom.recom)){this._hideHeader(1);}
		}
	}
newsi.Console.prototype.closeLinkAndDisable=function(item,i){
	if(!this._hasItem(item,i)){
		if(this.getServeLoc()!="THDO"||this.getServeLoc()=="THDO" && !this._tz && i >=1){
			this._hideLink(i);
			return true;
			}
		}
	return false;	
	};
newsi.Console.prototype._domesticTimezone=function(){
	var d=new Date().getTimezoneOffset();
	if(d <= 0 && d >= -60){
		return true;
		}
	return false;
	};
newsi.Console.prototype._hasItem=function(item,num){
	var k=0;
	//mo is "domestic" or "international"
	var mo=this._mediaObject[num].audience
	var len=mo.length;
	//search through each value in audience - if any match "international"
	while(k < len){
		if(mo[k]==item){return true;};
		k++;
		}
	return false;
	}
newsi.Console.prototype._setUpChapterisation=function(){
	if(!this.po.canDoChapterisation()){this._removeChapterisationContent();}
	}
newsi.Console.prototype._removeChapterisationContent=function(){
	var len=this.arr.length
	for(var i=0;i<len;i++){
		sum=this.dom.e_gebid("s"+i+"_content");
		if(this.dom.gebtn({parent:sum,el:this.el.list}).length!=0){
			this.dom.rC({parent:sum,el:this.dom.gebtn({parent:sum,el:this.el.list})[0]});
			this.dom.rC({parent:sum,el:this.dom.gebtn({parent:sum,el:this.el.head2})[0]});
			}
		}
	}
newsi.Console.prototype.doChapterisation=function(obj){
	this.po.setPosition(obj);
	}
newsi.Console.prototype._setupForLatestBrowsers=function(){
	this._addButtons();
	}
newsi.Console.prototype._queryString=function(){
	this.qs = new newsi.QueryString();
	this.qString = this.qs.getQueryString();
	this.index = this.qString.selected || 0;
	}
newsi.Console.prototype._removeLegacyContent=function(){
	this.dom.iH({el:this.dom.player,text:""});
	}
newsi.Console.prototype._hasRedundantHeader=function(mainEl){
	if(!mainEl){return true;}
	var li=this.dom.gebtn({parent:mainEl,el:this.el.li});
	for(var i=0;i<li.length;i++){
		if(this.dom.getClass({el:li[i]}) != "none" && this.dom.pN({el:this.dom.pN({el:li[i]})}).id == mainEl.id){
			return false;
			}
		}
	return true;	
	}
newsi.Console.prototype._hasRedundantRecommendedHeader=function(mainEl){
	if(!mainEl){return true;}
	var li=this.dom.gebtn({parent:mainEl,el:this.el.li});
	for(var i=0;i<li.length;i++){
		var parent=this.dom.pN({el:li[i]});
		var grandparent=this.dom.pN({el:parent});
		var greatgrandparent=this.dom.pN({el:grandparent});
		if(this.dom.getClass({el:li[i]}) != "none" && grandparent.id==mainEl.id){
			return false;
			}
		}
	return true;	
	}
newsi.Console.prototype._hideHeader=function(num){
	var head=this.dom.gebtn({parent:this.dom.stories,el:this.el.head2});
	if(head[num]){
		this.dom.setClass({el:head[num],className:"none"});
		}
	}
newsi.Console.prototype._hideLink=function(num){
	if(!num){	
		this._hideMain();return true;
		}
	//set a value on innerHTML, update GUI
	this.dom.iH({el:this.dom.player,text:""});
	var len=this.dom.gebtn({parent:this.dom.related,el:this.el.head3}).length;
	//hide recommeded and related
	if(num <= len && this.dom.related){
		this._hideRelated(num);
		return;
	}
	if(this.dom.recom){
		this._hideRecommended(num,len);
	}
	return false;
}
newsi.Console.prototype._hideMain=function(){
	//update the gui
	this.dom.iH({el:this.dom.player,
	text:"<h2>MEDIA PLAYER</h2><div id=\"legacy\" class=\"ukonly\"><p class=\"bolder\">We're sorry,</p><p>the media you are trying to play is only for UK audiences</p></div>"});
	this.dom.setClass({el:this.dom.mainstory,className:"rightsrestricted"});
	var ev=new newsi.Event();
	this.bm.addEvent({evType:"onclick",id:"s0",method:"doNothing"});
	}
newsi.Console.prototype._hideRelated=function(num){
	var all_li = this.dom.gebtn({parent:this.dom.related,el:this.el.li});
	var i=0;
	var li=[];
	while(i<all_li.length){
		if(this.dom.pN({el:this.dom.pN({el:all_li[i]})}) == this.dom.related){
			li=this.pushIt({arr:li,item:all_li[i]});
			}
		i++;
		}
	this.dom.setClass({el:li[(num-1)],className:"none"});
	}
newsi.Console.prototype._hideRecommended=function(num,storiesListLen){
	num=num-(storiesListLen+1);
	this.dom.setClass({el:this.dom.gebtn({parent:this.dom.recom,el:this.el.li})[num],className:"none"});
	}
newsi.Console.prototype.doNothing=function(){return;}
newsi.Console.prototype._addButtons=function(){
	var element=this.bm.thisElement({parent:this.dom.iItems,el:this.el.li,index:0});
	this.dom.setId({el:element,id:"morefromthissection"});
	this.bm.addEvent({evType:"onclick",method:"launchInParent",id:element.id,arg:this.dom.gebtn({parent:element,el:"a"})[0].href});
	// More Audio and Video link	
	this.addOnClickLaunchInParent({element:this.dom.gebtn({parent:this.dom.moreAV,el:"a"})[0], id:this.dom.moreAV.id});
	if(window.opener && !window.opener.closed && this._canLaunchOpener){
		var a=this.dom.cE({el:this.el.a});
		this.dom.iH({el:a,text:"Back to launch page"});
		this.dom.setId({el:a,id:"backtolaunch"});
		var li=this.dom.cE({el:this.el.li});
		this.dom.aC({parent:li,el:a});
		this.dom.iB({parent:this.dom.gebtn({parent:this.dom.iItems,el:this.el.ul})[0],el:li,existing:element});
		this.bm.addEvent({evType:"onclick",method:"backToLaunch",id:a.id});
		this.setRollover({id:a.id});
		}
	this.addOnClickLaunchInParent({element:this.dom.gebtn({parent:this.dom.moreAV,el:"a"})[0], id:this.dom.moreAV.id});// More Audio and Video link	
	this.addOnClickLaunchInParent({element:this.bm.thisElement({parent:this.dom.terms,el:this.el.a,index:0}),id:"termslaunch"});// terms link
	this.addOnClickLaunchInParent({element:this.bm.thisElement({parent:this.dom.privacy,el:this.el.a,index:0}),id:"privacylaunch"});// privacy link
	this.addOnClickLaunchInParent({element:this.bm.thisElement({parent:this.dom.feedback,el:this.el.a,index:0}), id:"feedbacklaunch"});// feedback link
	this.addOnClickLaunchInParent({element:this.bm.thisElement({parent:this.dom.copyright,el:this.el.a,index:0}), id:"copyrightlaunch"});// copyright link
	this.addOnClickLaunchInParent({element:this.bm.thisElement({parent:this.dom.help,el:this.el.a,index:0}), id:"helplaunch"});// help link
	this.addOnClickLaunchInParent({element:this.dom.pN({el:this.dom.logo}),id:"logolaunch"});// logo launch
	this._addCloseButton();
	this._addEmailToAFriendButton();
	this._addFullScreenButtonRM();
	}
newsi.Console.prototype.addOnClickLaunchInParent=function(o){
	this.dom.setId({el:o.element,id:o.id});
	this.bm.addEvent({evType:"onclick",method:"launchInParent",id:o.element.id, arg:o.element.href});
	}
newsi.Console.prototype._addFullScreenButtonRM=function(){
	if(this.po.canShowFullScreen()){
		var li=this.dom.cE({el:this.el.li});
		this.dom.setId({el:li,id:"fullscreen"});
		this.dom.iH({el:li,text:"Full screen"});
		var ul=this.dom.gebtn({parent:this.dom.options,el:this.el.ul})[0];
		var existingLi=this.dom.gebtn({parent:ul,el:this.el.li})[0];
		this.dom.iB({parent:ul,el:li,existing:existingLi});
		this.bm.addEvent({evType:"onclick",method:"doFullScreenRM",id:"fullscreen"});
		this.setRollover({id:"fullscreen"});
		}
	}
newsi.Console.prototype.doFullScreenRM=function(){
	if(this.po.canShowFullScreen()){this.po.showFullScreen();}else{
		this.dom.setClass({el:newsi.html.gebid("fullscreen"),className:"none"});
		}
	}
newsi.Console.prototype._addLauncherLink5=function(o){
	var liTag=newsi.html.gebid(o.hookId).getElementsByTagName(o.el)[o.num];
	var anchorTag=liTag.getElementsByTagName("a")[0];
	anchorTag.href=o.url
	}
newsi.Console.prototype.launchInParent=function(obj){
	var url=obj[0];
	if(!window.opener || window.opener.closed){
		window.open(url);
		return;
		}
	window.opener.location=url;
	window.opener.focus();
	return false;
	}
newsi.Console.prototype.backToLaunch=function(){
	if(!this._hWndOpened){
		if(!window.opener || window.opener.closed){
			if(this._canLaunchOpener){
				var hWnd = window.open(this._oOpener.href);
				//IE browsers dont locate by window top/left - dont move them
					if (window.opener){
						//move browser to 0,0, store client width
						hWnd.moveTo(0,0);
						var yPos = hWnd.screenTop;
						hWnd.moveTo(this._oOpener.x, ((this._oOpener.y - yPos)) >=0 ? this._oOpener.y - yPos : 0);
						hWnd.resizeTo(this._oOpener.width,((this._oOpener.height + yPos) < screen.availHeight)?this._oOpener.height + yPos:screen.availHeight);
						}
					else{
						hWnd.moveTo(this._oOpener.x,this._oOpener.y);
						hWnd.resizeTo(this._oOpener.width,this._oOpener.height);
						}
					this._hWndOpened = true;
					}
				}
			else{window.opener.focus();}
		}
	return;
	}
newsi.Console.prototype._addEmailToAFriendButton=function(){
	var ev=new newsi.Event();
	ev.addListener("onclick","emailafriend",this,"showEmail",false);
	var ev1=new newsi.Event();
	ev1.addListener("onclick","accessemailafriend",this,"showEmail",false);
	}
newsi.Console.prototype._addCloseButton=function(){
	var element=this.dom.cE({el:this.el.li});
	this.dom.setId({el:element,id:"close"});
	this.dom.iH({el:element,text:"Close"});
	this.dom.gebtn({parent:this.dom.nav,el:this.el.ul})[0]
	this.dom.aC({parent:this.dom.gebtn({parent:this.dom.nav,el:this.el.ul})[0],el:element});
	this.bm.addEvent({evType:"onclick",method:"doClose",id:element.id});
	}
newsi.Console.prototype.showEmail=function(){
	//if(this.getServeLoc()!="THDO"){ // switch for ETP for UK users if required...
	var URL="http://newsvote.bbc.co.uk/mpapps/pagetools/email/";
	var site=this._mediaObject[this.index].cs;
	if(site!="sport"){site="news";}
	var finalurl=this.buildURL({index:this.index,stafURL:URL})+"?section="+site+"&tmpl=n";
	newsi.window.popup({url:finalurl,height:450,width:310});
	//}
	/*else{
	this._changeEmailToAFriend("none","show");
	this.staf.init();
	//}*/
	}
newsi.Console.prototype.buildURL=function(o){
	if(this._mediaObject[o.index].cs=="sport"){
		this._mediaObject[o.index].cs4URL="sol";
		}
	else{
		this._mediaObject[o.index].cs4URL="nol";
		}
	var storyId=Number(this._storiesObject[o.index].id)
	var parentFolder=parseInt(storyId/10000)*10000;
	var childFolder=parseInt(storyId/100)*100;
		var storyURL = "/player/" + this._mediaObject[o.index].cs4URL + "/newsid_" + parentFolder + "/newsid_" + childFolder + "/" + this._storiesObject[o.index].id + ".stm";
		if(o.stats){
		return storyURL;
		}
	storyURL="news.bbc.co.uk"+storyURL;
	if(o.stafURL){
		storyURL=o.stafURL+storyURL;
		}
	else{
		storyURL="http://"+storyURL;
		}
	return storyURL;
	}
newsi.Console.prototype.hideEmail=function(){this._changeEmailToAFriend("show","none");}
newsi.Console.prototype.doClose=function(){if(window.confirm("This will close the player window \nAre you sure you want to do this?")){window.close();}}
newsi.Console.prototype._hideTopStory=function(){
	this.dom.setClass({el:this.dom.gebtn({parent:document,el:this.el.head1})[0],className:"none"});
	this.dom.setClass({el:this.dom.gebtn({parent:this.dom.related,el:this.el.summary})[0],className:"none"});
	}	
newsi.Console.prototype._changeEmailToAFriend=function(a,b){
	this.dom.setClass({el:this.dom.mainstory,className:a});
	if(this.dom.related){this.dom.setClass({el:this.dom.related,className:a});}
	if(this.dom.recom){this.dom.setClass({el:this.dom.recom,className:a});}
	if(a=="show"){this.dom.rC({parent:this.dom.stories,el:this.dom.e_gebid("emailContent")});}
	}
newsi.Console.prototype.loadMedia=function(i){
	this._storyNum=i;
	this._index=(i-1);
	}
newsi.Console.prototype._canDoScripting=function(num){
	this._setValuesForScripting(num);
	if(this.po.player=="real"&&this.po.canDoSetSource()){return true;}
	// versionInfo will not be defined if the player cannot be scripted.
	if(this.po.player=="wm"&&document[this.getObjectTagId()].versionInfo){return true;}
	return false;
	}
newsi.Console.prototype.placeMovie=function(num){
	this._adjustRealControls();
	if(this._canDoScripting(num)){
		this._useScripting(num);
	}else{
		this.dom.iH({el:this.dom.player,text:this._getMedia(num)});
		this._updateLinksToExternalPlayer();
	}
	}
newsi.Console.prototype._adjustRealControls=function(){
	if(this.po.player=="real"){
		this.dom.setClass({el:this.dom.gebid("activecontrols"),className:"show"});
		this.dom.setClass({el:this.dom.gebid("inactivecontrols"),className:"none"});
		}
	}
newsi.Console.prototype._setValuesForScripting=function(num){	
	var url="clipURL"+this.po.band+"_"+this.po.flavour;
	this.po.band4class=this._getBandSettings();
	this.po.flavour4class=this._getFlavourSettings();
	this.po.completeUrl=this._mediaObject[num][url];
	this.po.appliedURL=this.po.completeUrl;
	}
newsi.Console.prototype._useScripting=function(num){
	this._hasScripting=true;
	if(this.po.flavour=="rm"){this._useScriptingReal();}else{this._useScriptingWMP();}
	this._updateLinksToExternalPlayer();
	}
newsi.Console.prototype._useScriptingReal=function(o){
	this._setUpElement({element:"nolplayer1"});
	this._setUpElement({element:"mediaPlayerObject"});
	this._setUpElement({element:"mediaPlayerEmbed"});
	}
newsi.Console.prototype._setUpElement=function(o){
	if(this.po.hasElement({element:o.element})){
		if(!this.hasActiveX()){ // only check FF for SetSource - IE will have it...
			if(this.po.hasFunction({element:o.element,functionName:"SetSource"})){
				this._setPosition({url:this.po.completeUrl,element:o.element});
				}
			}
		else{
			this._setPosition({url:this.po.completeUrl,element:o.element});
			}
		}
	}
newsi.Console.prototype._setPosition=function(o){
	document[o.element].SetSource(o.url);
	document[o.element].SetPosition(0);
	//document[o.element].DoPlay();
	}
newsi.Console.prototype._useScriptingWMP=function(){
	this._setUpIntervalWM();
	document[this.getObjectTagId()].URL=this.po.completeUrl;
}	
newsi.Console.prototype._setUpIntervalWM=function(){
this._clearPreviousWM();
this.sI=setInterval(listenForPlayStateChange,500);
flag=true;
};
function listenForPlayStateChange(){
	if(document[c.getObjectTagId()].playState==3){
		if(!c.dom.gebid("fullscreen")){
			c._addFullScreenButtonWM(true);// add 'Full screen' link if av is playing (WMP)
			flag=false;
			}
		}
	else{
		if(!c.dom.gebid("fullscreendisabled")){c._addNonLinkWM();} // add greyed out 'Full screen' text if av is not playing (WMP)
		}	
	};
newsi.Console.prototype._clearPreviousWM=function(){
	if(this.sI!=0){clearInterval(this.sI);}
	this._removeOldFSElementWM();
	}
newsi.Console.prototype._removeOldFSElementWM=function(o){
	var ul=this.dom.gebtn({parent:this.dom.options,el:'ul'})[0];
	if(this.dom.gebid("fullscreen")){this.dom.rC({parent:ul,el:this.dom.e_gebid("fullscreen")});}
	if(this.dom.gebid("fullscreendisabled")){this.dom.rC({parent:ul,el:this.dom.e_gebid("fullscreendisabled")});}
	}
newsi.Console.prototype._createNewFSElementWM=function(o){
	var ul=this.dom.gebtn({parent:this.dom.options,el:'ul'})[0];
	var li=this.dom.cE({el:this.el.li});
	this.dom.setId({el:li,id:o.name});
	this.dom.iH({el:li,text:"Full screen"});
	var existingLi=this.dom.gebtn({parent:ul,el:this.el.li})[0];
	this.dom.iB({parent:ul,el:li,existing:existingLi});
	if(this.sI!=0){clearInterval(this.sI);}
	this.sI=setInterval(listenForPlayStateChange,500);
	return li;
	}
newsi.Console.prototype._addNonLinkWM=function(){
	var ul=this.dom.gebtn({parent:this.dom.options,el:'ul'})[0];
	this._removeOldFSElementWM();
	var li=this._createNewFSElementWM({name:"fullscreendisabled"})
	this.dom.setClass({el:li,className:"fullscreendisabled"});
	}
newsi.Console.prototype._addFullScreenButtonWM=function(flag){
	if(flag==true){
		this._removeOldFSElementWM();
		var li=this._createNewFSElementWM({name:"fullscreen"})
		this.bm.addEvent({evType:"onclick",method:"doFullScreenWM",id:"fullscreen"});
		this.setRollover({id:"fullscreen"});
		}
	}
newsi.Console.prototype.doFullScreenWM=function(){this.po.showFullScreen({obj:this});}	
newsi.Console.prototype._updateLinksToExternalPlayer=function(num){
	var element=this.dom.e_gebid("standalone");
	var a=this.bm.thisElement({parent:element,el:this.el.a,index:0});
	a.href = this.po.completeUrl;
	a.innerHTML = "Launch in stand alone player";
	}
newsi.Console.prototype._checkRightsRestriction=function(zone){
	var i=0;
	var len=this._mediaObject[this.index].audience.length;
	while(i<len){if(this._mediaObject[this.index].audience[i]==zone){return "";}i++;}
	return "_acl";
	}
newsi.Console.prototype._getBandSettings=function(){
	if(this.po.band == ""){return "nb";}else{return "bb";}
	}
newsi.Console.prototype._getFlavourSettings=function(){
	if(this.po.flavour=="wmv"){return "wm";}else{return "rm";}
	}
newsi.Console.prototype._getTagId=function(){return this._getDefinition()+"ImageWindow";}
newsi.Console.prototype._getDefinition=function(){
	this.po.band4class=="bb"?band="bb":band="nb";
	this.po.flavour4class=="rm"?flav="RP":flav="WM";
	return band+flav;
}
newsi.Console.prototype.getObjectTagId=function(){return "obj"+this._getTagId();}
newsi.Console.prototype._getMedia=function(num){
	this.index=num;
	this.dom.iH({el:this.dom.player,text:""});
	this._RR=this._checkRightsRestriction("international");
	var url = "clipURL" + this.po.band + "_" + this.po.flavour;
	this.po.band4class=this._getBandSettings();
	this.po.flavour4class=this._getFlavourSettings();
	this.po.completeUrl=this._mediaObject[this.index][url];
	var mediaHTML="";
	if(this.po.player == "real"){mediaHTML=this.getREAL();}
	else{var mediaHTML=this.getWMP();};
	if(this.po.band == ""){
		this.dom.setClass({el:this.dom.player,className:"narrowband"});
		}
	return mediaHTML;
	}
newsi.Console.prototype.getWMP=function(){
	return '<!--js generated (wmp)--><h2><a name="mediaplayer">MEDIA PLAYER</a></h2>'
	+'<object id="obj' + this._getTagId() + '" '
	+'name="WMP1" '
	+'classid="'+this.po.classid+'" '
	+'type="'+this.po.type+'" '
	+'standby="Loading Stream..." '
	+'>'
	+'<param '
	+'name="console" '
	+'value="av"/>'
	+'<param name="url" '
	+'value="'+this.po.completeUrl+'"'
	+'><param '
	+'name="controls" '
	+'value="all"'
	+'>'
	+'<param name="AUTOSTART" value="true">'
	+'<param name="mute" value="false">'
	+'<param name="windowlessvideo" value="false">'
	+'<param name="enableContextMenu" value="true">'
	+'<param name="stretchToFit" value="false">'
	+'<embed '
	+'name="mediaPlayerObject" '
	+'id="embed' + this._getTagId() + '" '
	+'src="'+this.po.completeUrl+'" '
	+'showtracker="1" '
	+'EnableContextMenu="0" '
	+'type="application/x-mplayer2" '
	+'autostart="1" '
	+'loop="0" '
	+'autosize="1" '
	+'showcontrols="'+this.po.showcontrols+'" '
	+'showstatusbar="1" '
	+'pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/" '
	+' />'
	+'</object>';
	};
newsi.Console.prototype.getREAL=function(){
	return '<!--js generated (Real)--><h2><a name="mediaplayer">MEDIA PLAYER</a></h2>'
	+'<object id="obj' + this._getTagId() + '" '
	+'classid="'+this.po.classid+'" '
	+'>'
	+'<param '
	+'name="console" '
	+'value="av"/>'
	+'<param name="SRC" '
	+'value="'+this.po.completeUrl+'"'
	+'><param '
	+'name="controls" '
	+'value="ImageWindow"'
	+'>'
	+'<param name="AUTOSTART" value="true">'
	+'<embed '
	+'name="mediaPlayerObject"'
	+'id="embed' + this._getTagId() + '" '
	+ this.po.mediaTag+'="'+this.po.completeUrl+'" '
	+'controls="ImageWindow" '
	+'console="av" '
	+'type="'+this.po.type+'" '
	+'autostart="true" '
	+'showcontrols="'+this.po.showcontrols+'" '
	+'showstatusbar="1" '
	+'scriptcallbacks="onPlayStateChange,onClipOpened,onClipClosed" '
	+' />'
	+'<embed '
	+'name="mediaPlayerStatus" '
	+'id="objrpstatus" '
	+'controls="StatusBar" '
	+'console="av" '
	+'type="'+this.po.type+'" '
	+'showcontrols="1" '
	+'showstatusbar="1" '
	+' />'
	+'</object>'
	+'<div id="activecontrols">'
	+'<embed '
	+'name="mediaPlayerControl" '
	+'id="objrpcontrols" '
	+'controls="ControlPanel" '
	+'console="av" '
	+'type="'+this.po.type+'" '
	+'showcontrols="1" '
	+'showstatusbar="1" '
	+' />'
	+'<object '
	+'classid="'+this.po.classid+'" '
	+'name="activemediaPlayerControl" '
	+'<param '
	+'name="controls" '
	+'value="controlpanel"/>'
	+'<param '
	+'name="console" '
	+'value="av"/>'
	+'</object>'
	+'</div>'
	+'<div id="inactivecontrols" class="none">'
	+'<embed '
	+'name="mediaPlayerControl" '
	+'id="objrpcontrols" '
	+'controls="ControlPanel" '
	+'console="non_av" '
	+'type="'+this.po.type+'" '
	+'showcontrols="1" '
	+'showstatusbar="1" '
	+' />'
	+'<object '
	+'classid="'+this.po.classid+'" '
	+'name="activemediaPlayerControl" '
	+'<param '
	+'name="controls" '
	+'value="controlpanel"/>'
	+'<param '
	+'name="console" '
	+'value="non_av"/>'
	+'</object>'
	+'</div>'
	;
	}
newsi.Console.prototype.pushIt=function(o){
	this._x=o;
	var f="if(this._x.item instanceof Array){len=this._x.item.length;for(var i=0;i<len;i++){this._x.arr[this._x.arr.length]=this._x.item[i]};return this._x.arr;}";
	this.func=new Function(f)
	this.func();
	o.arr[o.arr.length]=o.item;
	return o.arr;
	}
newsi.Console.prototype.manageStats=function(num){this.dom.gebid("livestats").setAttribute("src",this._storiesObject[num].stats);}
newsi.Console.prototype.getPageType=function(o){
	var pt="Console"+o.bnd.toUpperCase()+this.getPlayerType();
	return pt;
	}
newsi.Console.prototype.getPlayerType=function(){
	if(this.po.player=="wm"){return "WinM_Story";}
	return "Real_Story";
	}
newsi.Console.ButtonManager=function(o){
	this.dom=o.domObj;
	this.el=o.elObj;
	this.obj=o.callingObj;
	}
newsi.Console.ButtonManager.prototype=newsi.html;
newsi.Console.ButtonManager.prototype.thisElement=function(o){return this.dom.gebtn({parent:o.parent,el:o.el})[o.index];}
newsi.Console.ButtonManager.prototype.addEvent=function(o){
	if(!o.arg){o.arg='';}
	var ev=new newsi.Event();
	ev.addListener(o.evType,o.id,this.obj,o.method,false,o.arg);
	}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
newsi.ConsoleStacker=function(domInstance,el,css){
	this.eb=new newsi.EventBroadcaster(this);
	this.css=css;
	this.dom=domInstance;
	this.el=el;
	this.arr=[];
	}
newsi.ConsoleStacker.prototype=new newsi.HTML.Stacker();
newsi.ConsoleStacker.prototype.init=function(c,obj){
	this.consoleInstance=c;
	this.qString=this.consoleInstance.qString;
	this.qString.selected=this.consoleInstance.qString.selected||0;
	this._mediaObject=obj;
	this._lookAtMarkup();
	this._manageLinks();	
	this.doInit(this.arr);																											
	this._setDefaultSetting();																														
	}
newsi.ConsoleStacker.prototype._lookAtMarkup=function(){
	this._getStories();  																																		
	if(this.dom.recom){
		this._getRecommended();
		}
	}
newsi.ConsoleStacker.prototype._getStories=function(){
	this._getMainStory();
	this._getOtherStories();
	}
newsi.ConsoleStacker.prototype._getMainStory=function(){
	var H1=this.dom.gebtn({	parent:this.dom.stories,
	el:this.el.head1})[0];
	var lnk=this.dom.gebtn({parent:H1,el:this.el.a})[0];
	this.dom.setId({el:lnk,id:"s0"});
	var sum=this.dom.gebtn({parent:this.dom.mainstory,el:this.el.summary})[0];
	this.dom.setId({el:sum,id:"s0_content"});
	var chap=0;
	chap.id=false;
	var chapHead=0;
	chapHead.id=false;
	if(this._hasChapterisation({parent:sum})){
		var chapter=this.dom.gebtn({parent:sum,el:this.el.list})[0];
		chapHead=this._addChapterHeader({existing:chapter,parent:sum});
		this.dom.setId({el:chapter,id:"c0"});
		this.dom.setId({el:chapHead,id:"ch0"});
		}
	this.arr[0]={linkId:lnk.id,contentId:sum.id};
	}
newsi.ConsoleStacker.prototype._addChapterHeader=function(o){
	var header=this.dom.cE({el:this.el.head2} );
	this.dom.iH({text:"Jump to...",el:header});
	this.dom.setClass({el:header,className:"indent"});
	this.dom.iB({el:header,existing:o.existing,parent:o.parent});
	return header;
	}
newsi.ConsoleStacker.prototype._getOtherStories=function(){
	if(this.dom.related){
		this._getRelateds(this.dom.gebtn({parent:this.dom.related,el:this.el.li}));
		}
	}
newsi.ConsoleStacker.prototype._getRecommended=function(){
	var len=this.arr.length;
	this.numStories=this.arr.length;
	var list=this.dom.gebtn({parent:this.dom.recom,el:this.el.li});
	var lilen=list.length;
	for(var i=0;i<lilen;i++){
		var h3=this.dom.gebtn({parent:list[i],el:this.el.head3});
		var sum=this.dom.gebtn({parent:list[i],el:this.el.summary});
		var a=h3[0].childNodes[0];
		if(a.tagName.toLowerCase()=="a"){this.dom.setId({el:a,id:"s"+(len)});}
		this.dom.setId({el:sum[0],id:"s"+(len)+"_content"});
		this.arr=this.consoleInstance.pushIt({arr:this.arr,item:{linkId:a.id,contentId:sum[0].id}})
		len=this.arr.length;
		}
	}
newsi.ConsoleStacker.prototype._hasChapterisation=function(o){
	if(this.dom.gebtn({el:this.el.list,parent:o.parent})[0]){return true;}
	return false;
	}
newsi.ConsoleStacker.prototype._getRelateds=function(listItems){
	var list=[];
	var len=listItems.length;
	var x=1;
	for(var i=0;i<len;i++){
		var htag=this.dom.gebtn({parent:listItems[i],el:this.el.head3});
		var sum=this.dom.gebtn({parent:listItems[i],el:this.el.summary});
		if(htag[0]){
			var a=htag[0].childNodes[0];
			if(a.tagName.toLowerCase()=="a"){this.dom.setId({el:a,id:"s"+x});}
			this.dom.setId({el:sum[0],id:"s"+x+"_content"});
			if(this._hasChapterisation({parent:sum[0]})){
				var ol=this.dom.gebtn({parent:sum[0],el:this.el.list})[0];
				var head=this._addChapterHeader({existing:ol,parent:sum[0]});
				this.dom.setId({el:ol,id:"c"+x});
				this.dom.setId({el:head,id:"ch"+x});
				}
			x++;
			this.dom.setClass({el:sum[0],className:"none"});
			list=this.consoleInstance.pushIt({arr:list,item:listItems[i]})
			this.arr=this.consoleInstance.pushIt({arr:this.arr,item:{linkId:a.id,contentId:sum[0].id}})
			}
		}
	}
newsi.ConsoleStacker.prototype._manageLinks=function(){this._addEvents();}
newsi.ConsoleStacker.prototype._addEvents=function(){
	var len=this.arr.length;
	for(var i=0;i<len;i++){
		var id=this.arr[i].linkId;
		this[id]=new newsi.Event();
		this[id].addListener("onclick",id,this,"_onclicked",false,this.arr[i],i);
		if(this.dom.e_gebid("c"+i)){this._addChapterisationEvents(i);}
		}	
	}
newsi.ConsoleStacker.prototype._addChapterisationEvents=function(i){
	var ol=this.dom.e_gebid("c"+i);
	var liList=this.dom.gebtn({parent:ol,el:this.el.li});
	var x=0,len=liList.length;
	while(x<len){
		var offset=this.dom.getClass({el:liList[x]});
		this.dom.setId({el:liList[x],id:"chap"+i+"_"+x});
		var ev=new newsi.Event();
		ev.addListener("onclick",liList[x].id,this,"_chapterisationOnclicked",false,this.arr[i],i,offset);
		this.consoleInstance.setRollover({id:liList[x].id});
		x++;
		}
	}
newsi.ConsoleStacker.prototype._chapterisationOnclicked=function(obj){this.consoleInstance.doChapterisation(obj);}
newsi.ConsoleStacker.prototype._setDefaultSetting=function(){
	var len=this.arr.length;
	for(var i = 0;i < len;i++){this._toggle(this.arr[i],i);}
	if(this.qString.selected != 0){
		this._toggle(this.arr[this.qString.selected],this.qString.selected);
		if(!this.consoleInstance.closeLinkAndDisable("international",0)){return;}
		this.consoleInstance.placeMovie(this.qString.selected);
		return;
		}
	this._toggle(this.arr[0],0);
	if(!this.consoleInstance.closeLinkAndDisable("international",0)){this.consoleInstance.placeMovie(0);}
	} 
newsi.ConsoleStacker.prototype._onclicked=function(obj){
	this._toggle(obj[0],obj[1]);
	this.broadcastMessage("rhsLinkClicked"); // take out ad content (banner etc) if clip has no pre-roll
	this.consoleInstance.placeMovie(obj[1]);
	if(obj.length!=4){this.consoleInstance.manageStats(obj[1]);} // change live stats URL if not changing chapters
	}
newsi.ConsoleStacker.prototype._flushAdContent=function(){this.consoleInstance.flushAdContent();}
newsi.ConsoleStacker.prototype._setStyles=function(sel,number){
	var len=this.arr.length;
	for(var i=0;i<len;i++){
		this.dom.pN({el:this.gebid(this.arr[i].linkId)});
		this.dom.setClass({el:this.dom.pN({el:this.gebid(this.arr[i].linkId)}),className:this.audioOrVideo({num:i,state:"Closed"})});
		}
	this.dom.setClass({el:this.dom.pN({el:this.gebid(sel)}),className:this.audioOrVideo({num:number,state:"Open"})});
	}
newsi.ConsoleStacker.prototype.audioOrVideo=function(o){return this.css.storyItem[o.state][this._mediaObject[o.num].av];}
newsi.ConsoleStacker.prototype._toggle=function(obj,num){
	this._setStyles(obj.linkId,num);
	if(!this.gebid(obj.contentId)){this.loopAndHide({linkId:obj.linkId,str:"contentId",showClass:"show",hideClass:"none"});}
	else{
		if(this.hasDOM()){
			this.loopAndHide({linkId:obj.linkId,str:"contentId",showClass:"show",hideClass:"none"});
			this.changeStack({state:"show",linkId:obj.linkId,contentId:obj.contentId,showClass:"show",hideClass:"none"});
			}
		}
	}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
newsi.PlayerObject=function(){
	this.band=newsi.ConsoleSetup.band;
	this.flavour=newsi.ConsoleSetup.flavour;
	this.player=newsi.ConsoleSetup.player;
	this.suffix=newsi.ConsoleSetup.suffix;
	this.ratio=newsi.ConsoleSetup.ratio;
	this.classid=newsi.ConsoleSetup.classid;
	this.autostart=newsi.ConsoleSetup.autostart;
	this.mediaTag=newsi.ConsoleSetup.mediaTag;
	this.otherParamsAX=newsi.ConsoleSetup.otherParamsAX;
	this.width=newsi.ConsoleSetup.width;
	this.height=Number(newsi.ConsoleSetup.height)+Number(newsi.ConsoleSetup.heightOffset);
	this.type=newsi.ConsoleSetup.type;
	this.showcontrols=newsi.ConsoleSetup.showcontrols;
	this.canDoChapterisation=newsi.ConsoleSetup.canDoChapterisation;
	this.canDoSetSource=newsi.ConsoleSetup.canDoSetSource;
	this.setPosition=newsi.ConsoleSetup.setPosition;
	this.canShowFullScreen=newsi.ConsoleSetup.canShowFullScreen;
	this.showFullScreen=newsi.ConsoleSetup.showFullScreen;
	this.hasFunction=newsi.ConsoleSetup.hasFunction;
	this.hasElement=newsi.ConsoleSetup.hasElement;
	this.doFuncTest=newsi.ConsoleSetup.doFuncTest;
	this.url="http://news.bbc.co.uk/media_acl/avdb/";
	if(this.hasActiveX()){
		this.ObjectTagName="player";
		this.ObjectTagId="playerid";
		}
	else{
		this.ObjectTagName="na";
		this.ObjectTagId="na1";
		}	
	}
newsi.PlayerObject.prototype=newsi;
