//player.js v1.17 (12/6/07:11:42)
newsi.Console=function(obj,stories,recObj){
//refocus
window.focus();
//create a local recStories Object
if(newsi.RecommendedStories){
this._recStoriesObject=newsi.RecommendedStories;
}
// these aren't declared here but seem to be used?
this.index = 0;
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;
if(window.opener){
this._oOpener = new Object();
//wrapped try block for Netscape
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 = 0;
this._oOpener.height = 0;
this._oOpener.x = (window.screenLeft)?window.opener.screenLeft:window.opener.screenX;
this._oOpener.y = (window.screenTop)?window.opener.screenTop:window.opener.screenY;
if (window.opener.innerWidth){
this._oOpener.width = window.opener.outerWidth;
this._oOpener.height = window.opener.outerHeight;
}
else if (window.opener.document.documentElement && window.opener.document.documentElement.clientWidth){
this._oOpener.width = window.opener.document.documentElement.clientWidth;
this._oOpener.height = window.opener.document.documentElement.clientHeight;
}
else if (window.opener.document.body){
this._oOpener.width = window.opener.document.body.clientWidth;
this._oOpener.height = window.opener.document.body.clientHeight;
}
if (document.layers){
tmp1 = window.opener.outerWidth - window.opener.innerWidth;
tmp2 = window.opener.outerHeight - window.opener.innerHeight;
this._oOpener.width -= tmp1;
this._oOpener.height -= tmp2;
}
}
else{
this._canLaunchOpener = false;
}
}
else{
this._canLaunchOpener = false;
}
this._tz = false;
//do the sizing
this._resizeWindow();
//create an object to hold the media object arg
this._mediaObject=obj;
//and one for stories
this._storiesObject=stories;
//if recommended is populated, create a local prop for it
if(recObj[0]){
this._recommendedObject=recObj;
//join
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._concatStories=function(){
this._mediaObject=this._mediaObject.concat(this._recommendedObject);
this._storiesObject=this._storiesObject.concat(this._recStoriesObject);
}
newsi.Console.prototype._resizeWindow=function(){
var offsetX=0;
var offsetY=0;
if(window.opener){
/*if(this.hasActiveX() ){
window.resizeTo(680,557);
return;
}*/
window.resizeTo(675,540);
}
else{
/*if(this.hasActiveX() ){
window.resizeTo(680,737);
return;
}
window.resizeTo(700,725);*/
}	
}
newsi.Console.prototype._checkFunctionality=function(){
//see if 
if(this.hasActiveX()){
//ok, ActiveX, DOM and Mac OK
if(this.hasDOM() && this.true1_5){
this.initStacker();
this._setupForLatestBrowsers();																																							// S off
}
else{
trace("old IE browser");}
}
else{	
//no ActiveX (Mozilla - based and Mac OK)
if(this.hasDOM() && this.true1_5){
this.initStacker();
this._setupForLatestBrowsers();																																							// S off
}
/*else{
trace("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();
//create a DOM Object with HTML Params
this.dom = new newsi.HTML.DOM(this.HTMLElementWithId);
if(this.dom.e_gebid("stats")){	
//ok, this element hasn't been written
var image=this.dom.cE({el:"img"});
var src=unescape(this._buildStatsURL());
image.setAttribute("src",src);
}
//not sure about this
if(this.dom.e_gebid("iphome") ){
this.dom.moreAV = this.dom.e_gebid("iphome");
}
else{
this.dom.moreAV = this.dom.e_gebid("moreva");
}
//why is there a local variable of this class var
this.el=this.HTMLElement;
this.bm=new newsi.Console.ButtonManager({domObj:this.dom,elObj:this.el,callingObj:this});		
//local console stacker (dom HTML DOM, html elements,css Object
var cs=new newsi.ConsoleStacker(this.dom,this.el,this.cssData);
//class level playerobject
//this.po=new newsi.PlayerObject();
this.staf=new newsi.Console.STAF(this);
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 (console,media stroies)
cs.init(this,this._mediaObject);
this.arr=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.dom.related){
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){
//getServerLoc() is declared on newsi
if(!this._hasItem(item,i) && this.getServeLoc()!="THDO"){
this._hideLink(i);
return true;
}
if(!this._hasItem(item,i)&& 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"
//return true, otherwise false
while(k < len){
if(mo[k]==item){
return true;
};
k++;
}
return false;
}
newsi.Console.prototype._setUpChapterisation=function(){
if(this.po.canDoChapterisation() == false){
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 this is the main story
if(num == 0){
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);
}
}
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(){
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});
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.bm.addEvent({evType:"onclick",method:"launchInParent",id:this.dom.moreAV.id,arg:this.dom.gebtn({parent:this.dom.moreAV,el:"a"})[0].href});// More Audio and Video link
element=this.bm.thisElement({parent:this.dom.terms,el:this.el.a,index:0});// terms link
this.dom.setId({el:element,id:"termslaunch"});
this.bm.addEvent({evType:"onclick",method:"launchInParent",id:element.id,arg:element.href});
element=this.bm.thisElement({parent:this.dom.privacy,el:this.el.a,index:0});// privacy link
this.dom.setId({el:element,id:"privacylaunch"});
this.bm.addEvent({evType:"onclick",method:"launchInParent",id:element.id,arg:element.href});
element=this.bm.thisElement({parent:this.dom.feedback,el:this.el.a,index:0});// feedback link
this.dom.setId({el:element,id:"feedbacklaunch"});
this.bm.addEvent({evType:"onclick",method:"launchInParent",id:element.id,arg:element.href});
element=this.bm.thisElement({parent:this.dom.copyright,el:this.el.a,index:0});// copyright link
this.dom.setId({el:element,id:"copyrightlaunch"});
this.bm.addEvent({evType:"onclick",method:"launchInParent",id:element.id,arg:element.href});
element=this.bm.thisElement({parent:this.dom.help,el:this.el.a,index:0});// help link
this.dom.setId({el:element,id:"helplaunch"});
this.bm.addEvent({evType:"onclick",method:"launchInParent",id:element.id,arg:element.href});
element=this.dom.pN({el:this.dom.logo});
this.dom.setId({el:element,id:"logolaunch"});
this.bm.addEvent({evType:"onclick",method:"launchInParent",id:element.id,arg:element.href});
this._addCloseButton();
this._addEmailToAFriendButton();
this._addFullScreenButton();
}
newsi.Console.prototype._addFullScreenButton=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:"doFullScreen",id:"fullscreen"});
this.setRollover({id:"fullscreen"});
}
}
newsi.Console.prototype.doFullScreen=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});
this.setRollover({id:"close"});
}
newsi.Console.prototype.showEmail=function(){
//if(this.getServeLoc()!="THDO"){
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();
//}*/
}
// mr added 12/6/07 - quick test for sports pages
newsi.Console.prototype._isSport=function(){
	var pageURL=document.location.href;
	var contains_sol=pageURL.indexOf("sol");
	if (contains_sol>-1){return true;}else{return false;}
}
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";
}	*/
// mr added 12/6/07 - confirm to delete above conditional test
	this._mediaObject[o.index].cs4URL="nol";
	if (this._isSport()==true){this._mediaObject[o.index].cs4URL="sol";};
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.placeMovie=function(num){
//stop real on Opera
if(this.po.player == "real" && document.all && window.XMLHttpRequest && (document.nolplayer1 || document.mediaPlayerObject)){
this._useScripting(num);
return;
}
else{
this.dom.iH({el:this.dom.player,text:this._getMedia(num)});
this._updateLinksToExternalPlayer();
}
//this._embedPlayer(num);
}
newsi.Console.prototype._useScripting=function(num){
var url="clipURL"+this.po.band+"_"+this.po.flavour;
this.po.completeUrl=this._mediaObject[num][url];
if(document.nolplayer1){
document.nolplayer1.SetSource(this.po.completeUrl);
document.nolplayer1.SetPosition(0);
document.nolplayer1.DoPlay();
}
else{
document.mediaPlayerObject.SetSource(this.po.completeUrl);
document.mediaPlayerObject.SetPosition(0);
document.mediaPlayerObject.DoPlay();
}
this._updateLinksToExternalPlayer();
}
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";
// a must have an id if you want to attach an event handler to it...
//this.dom.setId({el:a,id:"standaloneonclick"});
//var s = document.location.href;
//var ev=new newsi.Event();
//ev.addListener("onclick","standaloneonclick",this,"redirectStandAlone",true,s);		
}
newsi.Console.prototype.redirectStandAlone = function(str){
//document.location.href = str;	
}
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._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;
if(this.po.band == ""){
this.po.band4class="nb";
}
else{
this.po.band4class="bb";
}
if(this.po.flavour=="wmv"){
this.po.flavour4class="wm";
}
else{
this.po.flavour4class="rm";
}
this.po.completeUrl=this._mediaObject[this.index][url];
switch(this.po.flavour4class){
case "rm":
if(this.po.band4class == "bb" ){
this.po.ObjectTagId = "embedbbRPImageWindow";
}
else if(this.po.band4class == "nb"){
this.po.ObjectTagId = "embednbRPImageWindow_js";
}
break;
case "wm":
if(this.po.band4class == "bb"){
this.po.ObjectTagId = "objbbWMImageWindow";
}
else{
this.po.ObjectTagId = "objnbWMImageWindow_js";
}
}
var mediaHTML='<h2><a name="mediaplayer">MEDIA PLAYER</a></h2>'
+'<embed '
+'name="mediaPlayerObject"'
+'id="' + this.po.ObjectTagId + '" '
+ this.po.mediaTag+'="'+this.po.completeUrl+'" '
+'controls="ImageWindow" '
+'console="av" '
+'type="'+this.po.type+'" '
+'autostart="true" '
+'showcontrols="'+this.po.showcontrols+'" '
+'showstatusbar="1" '
+" />";
var mediaHTMLCntrls="";
if(this.po.player == "real"){
mediaHTMLCntrls='<embed '
+'name="mediaPlayerControl" '
+'id="objrpcontrols" '
+'controls="ControlPanel" '
+'console="av" '
+'type="'+this.po.type+'" '
+'showcontrols="1" '
+'showstatusbar="1" '
+' />'
+ '<embed '
+'name="mediaPlayerStatus" '
+'id="objrpstatus" '
+'controls="StatusBar" '
+'console="av" '
+'type="'+this.po.type+'" '
+'showcontrols="1" '
+'showstatusbar="1" '
+' />';
}
if(this.po.band == ""){
this.dom.setClass({el:this.dom.player,className:"narrowband"});
}
return mediaHTML+mediaHTMLCntrls;
}
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(){
var image=this.dom.cE({el:"img"});
if(this.dom.e_gebid("statsImg")){
this.dom.rC({parent:this.dom.options,el:this.dom.e_gebid("statsImg")});
}
var src=unescape(this._buildStatsURL());
image.setAttribute("src",src);
this.dom.setId({el:image,id:"statsImg"});
if(src!=""){
this.dom.aC({parent:this.dom.options,el:image});
}
}
newsi.Console.prototype._buildStatsURL=function(){
var regex=/~RS~i~RS~\d+/;
var regey=/\d+/;
var id=regey.exec(regex.exec(this._storiesObject[this.index].stats));
if(!id){return "";}
var c=new newsi.Cookie({name:"x",content:"y"});
var audience="Domestic";
var flavour="wm";
if(this.po.flavour=="rm"){
flavour="rm"
}
c.load("BBCNewsAudience");
if(this.po.band=="_bb"){
var band="bb";
}
else{
var band="nb";
}
if(c.content){
audience=c.content
};
if(this._mediaObject[this.index].cs=="sport"){var site="Sport";}else if(this._mediaObject[this.index].cs=="news"){var site="News";}else{var site="News";}
	// mr added 12/06/07 - try new _isSport method
	var site="News";
	//var pageURL=document.location.href;
	//var contains_sol=pageURL.indexOf("sol");
	if (this._isSport()==true){var site="Sport"};
var rand=parseInt((Math.random()*10000)/100);
if(rand==100||rand<10){rand=99;}
var url="http://stats.bbc.co.uk/o.gif?~RS~s~RS~"+
site+
"~RS~t~RS~"+
this.getPageType({bnd:band})+
"~RS~i~RS~"+
id+
"~RS~p~RS~"+
"0"+
"~RS~a~RS~"+
audience+
"~RS~u~RS~"+
this.buildURL({index:this.index,stats:true})+
"~RS~r~RS~"+
"(none)"+
"~RS~q~RS~bw="+
band+
"&amp;mp="+
flavour+
"~RS~z~RS~"+
rand+
"~RS~";
return url;
}
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.css=css;
this.dom=domInstance;
this.el=el;
//class level array of links?
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();	
//what is this doing?
this.doInit(this.arr);
//draw the movie																												
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.consoleInstance.placeMovie(obj[1]);
if(obj.length==4){
//document.nolplayer1.DoPause();
//document.nolplayer1.SetPosition(80000);
}
else{
this.consoleInstance.manageStats();
}
}
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.cntrlsHeight=newsi.ConsoleSetup.cntrlsHeight;
//this.cntrlsWidth=newsi.ConsoleSetup.cntrlsWidth;
this.type=newsi.ConsoleSetup.type;
this.showcontrols=newsi.ConsoleSetup.showcontrols;
this.canDoChapterisation=newsi.ConsoleSetup.canDoChapterisation;
this.setPosition=newsi.ConsoleSetup.setPosition;
this.canShowFullScreen=newsi.ConsoleSetup.canShowFullScreen;
this.showFullScreen=newsi.ConsoleSetup.showFullScreen;
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;
newsi.Console.STAF=function(c){
this.dom=c.dom;
this.consoleInstance=c;
this.cI=this.consoleInstance;
this._mediaObject=c._mediaObject;
this._storiesObject=c._storiesObject;
this.stafPath="http://news.bbc.co.uk/apps/mp/pagetools/email/";
}
newsi.Console.STAF.prototype=newsi;
newsi.Console.STAF.prototype.init=function(){
this._buildFormMarkup();
}
newsi.Console.STAF.prototype._buildFormMarkup=function(){
if(!this.cI.dom.e_gebid("emailContent")){
this.headline=newsi.html.gebid("s"+this.cI.index).innerHTML;
if(newsi.html.gebid("s"+this.cI.index+"_content").innerText){
var summary=newsi.html.gebid("s"+this.cI.index+"_content").innerText;
}
else{
var summary=newsi.html.gebid("s"+this.cI.index+"_content").textContent;
}
var storyId=Number(this.cI._storiesObject[this.cI.index].id)
var parentFolder=parseInt(storyId/10000)*10000;
var childFolder=parseInt(storyId/100)*100;
var storyURL=this.cI.buildURL({index:this.cI.index});
var url=this.cI.po.completeUrl;
var emailDiv=this.cI.dom.cE({el:"div"});
this.cI.dom.setId({el:emailDiv,id:"emailContent"});
var emailForm=this.cI.dom.cE({el:"form"});
emailForm.setAttribute("method","post");
emailForm.setAttribute("name","stafForm");
var fieldSet1=this.cI.dom.cE({el:"fieldset"});
var legend1=this.cI.dom.cE({el:"legend"});
this.cI.dom.iH({el:legend1,text:"SEND:"});
var p1=this.cI.dom.cE({el:"p"});
this.cI.dom.iH({el:p1,text:this.headline});
//  fieldset 1
var fieldSet11=this.cI.dom.cE({el:"fieldset"});
var legend11=this.cI.dom.cE({el:"legend"});
this.cI.dom.setClass({className:"none",el:legend11});
this.cI.dom.iH({el:legend11,text:"TO:"});
this.label11=this.cI.dom.cE({el:"label"});	
this.label11.setAttribute("for","emailsString");
this.cI.dom.iH({el:this.label11,text:"To E-mail address <small>(required)</small>"});
var small11=this.cI.dom.cE({el:"small"});
this.cI.dom.iH({el:small11,text:"Seperate multiple addresses with a comma(,)"});
this.input11=this.cI.dom.cE({el:"input"});
this.input11=this.decorateInputTag(this.input11,"emailsString","emailsString");
this.cI.dom.aC({parent:fieldSet11,el:legend11});
this.cI.dom.aC({parent:fieldSet11,el:this.label11});
this.cI.dom.aC({parent:fieldSet11,el:small11});
this.cI.dom.aC({parent:fieldSet11,el:this.input11});
//  fieldset 2
var fieldSet12=this.cI.dom.cE({el:"fieldset"});
var legend12=this.cI.dom.cE({el:"legend"});
this.cI.dom.setClass({className:"none",el:legend12});
this.cI.dom.iH({el:legend12,text:"FROM:"});
this.label121=this.cI.dom.cE({el:"label"});
this.label121.setAttribute("for","fromName");
this.cI.dom.iH({el:this.label121,text:"Your name <small>(required)</small>"});
this.input121=this.cI.dom.cE({el:"input"});
this.input121=this.decorateInputTag(this.input121,"fromName","fromName");
this.label122=this.cI.dom.cE({el:"label"});
this.label122.setAttribute("for","fromEmail");	
this.cI.dom.iH({el:this.label122,text:"Your E-mail address <small>(required)</small>"});	
this.input122=this.cI.dom.cE({el:"input"});
this.input122=this.decorateInputTag(this.input122,"fromEmail","fromEmail");
var label123=this.cI.dom.cE({el:"label"});	
label123.setAttribute("for","message");
this.cI.dom.iH({el:label123,text:"Your Message:"});														
var textarea12=this.cI.dom.cE({el:"textarea"});
textarea12.setAttribute("name","message");
this.cI.dom.setId({el:textarea12,id:"message"});
var small12=this.cI.dom.cE({el:"small"});
this.cI.dom.iH({el:small12,text:"(Max length - 1000 characters)"});
this.cI.dom.aC({parent:fieldSet12,el:legend12});
this.cI.dom.aC({parent:fieldSet12,el:this.label121});
this.cI.dom.aC({parent:fieldSet12,el:this.input121});
this.cI.dom.aC({parent:fieldSet12,el:this.label122});
this.cI.dom.aC({parent:fieldSet12,el:this.input122});
this.cI.dom.aC({parent:fieldSet12,el:label123});
this.cI.dom.aC({parent:fieldSet12,el:textarea12});
this.cI.dom.aC({parent:fieldSet12,el:small12});
//  fieldset 3
var fieldSet13=this.cI.dom.cE({el:"fieldset"});
var input131=this.cI.dom.cE({el:"input"});
input131.setAttribute("type","button");
input131.setAttribute("value","CANCEL");
this.cI.dom.setId({el:input131,id:"cancelEmail"});
var input132=this.cI.dom.cE({el:"input"});
input132.setAttribute("type","submit");
input132.setAttribute("value","SEND");
this.cI.dom.setClass({className:"inputSubmit",el:input132});	
this.cI.dom.setId({el:input132,id:"emailSubmit"});
this.cI.dom.aC({parent:fieldSet13,el:input132});
this.cI.dom.aC({parent:fieldSet13,el:input131});
//  fieldset 4
var fieldSet14=this.cI.dom.cE({el:"fieldset"});
this.hiddenDiv141=this.cI.dom.cE({el:"div"});
this.cI.dom.setClass({className:"error",el:this.hiddenDiv141});	
this.cI.dom.setId({el:this.hiddenDiv141,id:"submissionError"});
this.cI.dom.iH({el:this.hiddenDiv141,text:"ERROR:Please check the required fields below."});
var hiddenInput141=this.cI.dom.cE({el:"input"});
hiddenInput141.setAttribute("type","hidden");
hiddenInput141.setAttribute("name","storyURL");
hiddenInput141.setAttribute("value",storyURL);
var hiddenInput142=this.cI.dom.cE({el:"input"});
hiddenInput142.setAttribute("type","hidden");
hiddenInput142.setAttribute("name","summary");
hiddenInput142.setAttribute("value",summary);
var hiddenInput143=this.cI.dom.cE({el:"input"});
hiddenInput143.setAttribute("type","hidden");
hiddenInput143.setAttribute("name","headline");
hiddenInput143.setAttribute("value",this.headline);
var hiddenInput144=this.cI.dom.cE({el:"input"});
hiddenInput144.setAttribute("type","hidden");
hiddenInput144.setAttribute("name","hash");
hiddenInput144.setAttribute("value",this._storiesObject[this.consoleInstance.index].hash);
var hiddenInput145=this.cI.dom.cE({el:"input"});
hiddenInput145.setAttribute("type","hidden");
hiddenInput145.setAttribute("name","emailURL");	
hiddenInput145.setAttribute("value","http://www.bbc.co.uk/mediaselector/check/player/"+this._mediaObject[this.cI.index].cs4URL+"/newsid_"+parentFolder+"/newsid_"+childFolder+"?redirect="+this._storiesObject[this.cI.index].id+".stm&news=1&nbram=1&bbwm=1&nbwm=1&bbram=1")
this.cI.dom.aC({parent:fieldSet14,el:this.hiddenDiv141});
this.cI.dom.aC({parent:fieldSet14,el:hiddenInput141});
this.cI.dom.aC({parent:fieldSet14,el:hiddenInput142});
this.cI.dom.aC({parent:fieldSet14,el:hiddenInput143});
this.cI.dom.aC({parent:fieldSet14,el:hiddenInput144});
this.cI.dom.aC({parent:fieldSet14,el:hiddenInput145});
this.cI.dom.aC({parent:fieldSet1,el:legend1});
this.cI.dom.aC({parent:fieldSet1,el:p1});
this.cI.dom.aC({parent:fieldSet1,el:fieldSet11});
this.cI.dom.aC({parent:fieldSet1,el:fieldSet12});
this.cI.dom.aC({parent:fieldSet1,el:fieldSet13});
this.cI.dom.aC({parent:fieldSet1,el:fieldSet14});
this.cI.dom.aC({parent:emailForm,el:this.hiddenDiv141});
this.cI.dom.aC({parent:emailForm,el:fieldSet1});
this.cI.dom.aC({parent:emailDiv,el:emailForm});
this.cI.dom.aC({parent:this.cI.dom.stories,el:emailDiv});
this.cI.dom.emailDiv=emailDiv;
var ev1=new newsi.Event();
ev1.addListener("onclick","cancelEmail",this.consoleInstance,"hideEmail",false);	
var ev2=new newsi.Event();
ev2.addListener("onclick","emailSubmit",this,"sendToAFriendWithJavaScript",false);
var fields=["emailsString","fromName","fromEmail","message"];
this._addStyleHandlers(fields);
newsi.html.showHide("submissionError","hide");
this.input11.focus();
}
}
newsi.Console.STAF.prototype._addStyleHandlers=function(fields){
var len=fields.length;
for(var i=0;i<len;i++){
var ev=new newsi.Event();
ev.addListener("onfocus",fields[i],this,"fieldFocus",false,fields[i]);
ev.addListener("onblur",fields[i],this,"fieldBlur",false,fields[i]);
}
}
newsi.Console.STAF.prototype.sendToAFriendWithJavaScript=function(){
if(this._doValidate()){
this.doSend();
}
}
newsi.Console.STAF.prototype.doSend=function(){
var fm=document.forms["stafForm"];
this._o={};
this._o.type="post";
this._o.feedback="report";
this._o.callback="mycallback";
sURL=fm.storyURL.value;
if(sURL.substring((sURL.length-1),sURL.length)=="#"){
var sURL=sURL.substring(0,(sURL.length-1));
}
var finalStoryURL=fm.storyURL.value.substring(0,(fm.storyURL.value.length-1));
this._o.body=
"summary="
+this._correctSpaces(this._escape(fm.summary.value))
+"&"
+"storyURL="
+this._escape(sURL)
+"&"
+"emailURL="
+this._escape(fm.emailURL.value)
+"&"
+"headline="
+this._correctSpaces(this._escape(fm.headline.value))
+"&"
+"fromName="
+fm.fromName.value
+"&"
+"fromEmail="
+this._escape(fm.fromEmail.value)
+"&"
+"emailsString="
+this._escape(fm.emailsString.value)
+"&"
+"message="
+this._correctSpaces(this._escape(fm.message.value))
+"&"
+"hash="
+fm.hash.value;
this._o.body+="&fmt=xml";
this._o.caller=this;
this._o.instance=this._o;
var url=sURL.replace(/http:\/\//,"");
this._o.url=this.stafPath+""+url;
this._o.mycallback=this.callback;
var ajx=new newsi.XMLHTTPRequest(this._o);
ajx._load(this._o);
this._o.report=function(msg){
//alert(msg.id+" FEEDBACK : "+msg.text);
}
}
newsi.Console.STAF.prototype.callback=function(o,obj){
if(o.text.search("<headline>")!=-1){
obj._onConfirmation();return;
}
obj._onError();
}
newsi.Console.STAF.prototype._escape=function(str){
str2=escape(str);
str2=str2.replace(/\//g,"%2F"); 
str2=str2.replace(/@/g,"%40"); 
return str2;
}
newsi.Console.STAF.prototype._correctSpaces=function(str){
str=str.replace(/%20/g,"+");
return str;
}
newsi.Console.STAF.prototype._doValidate=function(){
validate=true;
var msg="ERROR - Your submission cannot be processed.\n\nCheck that:\n"
if(this._emptyFields()){msg+="You haven't left any of the required fields empty.\n";validate=false;}
if(this._emailWrong()){msg+="You have a correct email address.\n";validate=false;}
if(!validate){newsi.html.showHide("submissionError","hide");return false;}	
newsi.html.showHide("submissionError","hide");
return true;
}
newsi.Console.STAF.prototype._emptyFields=function(){
var rFA=[this.input11,this.input121,this.input122];//requiredFieldsArray
var rFLA=[this.label11,this.label121,this.label122];//requiredFieldLabelsArray
var len=rFA.length;
var i=0;
var validate=false;
while(i<len){
rFA[i]=this._removeClass(rFA[i]);
rFLA[i]=this._removeClass(rFLA[i]);
if(rFA[i].value==""){
this.cI.dom.setClass({className:"inputTextError",el:rFA[i]});
this.cI.dom.setClass({className:"error",el:rFLA[i]});
validate=true;
}
i++;
}
if(validate){return true;}	
return false;
}
newsi.Console.STAF.prototype._emailWrong=function(){
var emails=[];
emails=this.input11.value.split(",");
var validate=false;
if(emails[emails.length-1]==""){emails.length--;}
var i=0;
var len=emails.length;
while(i<len){
if(!this.isValidEmail(emails[i])){
this.input11=this._setClass(this.input11,"inputTextError");
this.label11=this._setClass(this.label11,"error");
validate=true;
}
i++;
}
if(this.input122.value!=""&&!this.isValidEmail(this.input122.value)){
this.input122=this._setClass(this.input122,"inputTextError");
this.label122=this._setClass(this.label122,"error");
validate=true;
}	
if(validate){return true;}	
return false;
}
newsi.Console.STAF.prototype.fieldFocus = function(obj){
var id=obj[0];
newsi.html.gebid(id).style.background="#ff9";
}
newsi.Console.STAF.prototype.fieldBlur = function(obj){
var id=obj[0];
newsi.html.gebid(id).style.background="#fff";
}
newsi.Console.STAF.prototype._onError = function(){
text="Sorry, there has been an error: Please try again later";
this._buildResponseMarkup(text,false);
}
newsi.Console.STAF.prototype._onConfirmation = function(){
text="Thank you ";
this._buildResponseMarkup(text,true);
}
newsi.Console.STAF.prototype._buildResponseMarkup=function(_text,success){
this.cI.dom.rC({parent:this.cI.dom.stories,el:this.cI.dom.emailDiv});
var confirmationDiv=this.cI.dom.cE({el:"div"});
this.cI.dom.setId({el:confirmationDiv,id:"confirmation"});
var h21=this.cI.dom.cE({el:this.cI.dom.head2});
var p1=this.cI.dom.cE({el:this.cI.dom.p});
this.cI.dom.setClass({el:p1,className:"headline"});
var p2=this.cI.dom.cE({el:this.cI.dom.p});
var strong1=this.cI.dom.cE({el:"strong"});
var em1=this.cI.dom.cE({el:"em"});
var button1=this.cI.dom.cE({el:"button"});
this.cI.dom.iH({el:button1,text:"OK"});
this.cI.dom.setId({el:button1,id:"closeConfirmation"});
var p3=this.cI.dom.cE({el:this.cI.dom.p});
var em31=this.cI.dom.cE({el:"em"});
if(success){this.cI.dom.iH({el:em1,text:this.input11.value});}
this.cI.dom.aC({parent:strong1,el:em1});
if(success){this.cI.dom.iH({el:em1,text:"The details you provide on this page will not be used to send unsolicited e-mail, and will not be sold to a 3rd party. Privacy Statement<br/><br/>Find out more about the BBC's e-mail a friend service in our frequently asked questions"});}
this.cI.dom.aC({parent:p3,el:em31});
this.cI.dom.iH({el:p1,text:this.headline});
this.cI.dom.iH({el:p2,text:_text});
this.cI.dom.aC({parent:p2,el:strong1});
if(success){this.cI.dom.iH({el:h21,text:"EMAIL CONFIRMATION:"});}
this.cI.dom.aC({parent:confirmationDiv,el:h21});
this.cI.dom.aC({parent:confirmationDiv,el:p1});
this.cI.dom.aC({parent:confirmationDiv,el:p2});
this.cI.dom.aC({parent:confirmationDiv,el:button1});
this.cI.dom.aC({parent:confirmationDiv,el:p3});
var emailDiv=this.cI.dom.cE({el:"div"});
this.cI.dom.setId({el:emailDiv,id:"emailContent"});
this.cI.dom.aC({parent:emailDiv,el:confirmationDiv});
this.cI.dom.aC({parent:this.cI.dom.stories,el:emailDiv});
var ev=new newsi.Event();
ev.addListener("onclick","closeConfirmation",this.consoleInstance,"hideEmail",false);	
}
newsi.Console.STAF.prototype.decorateInputTag=function(the_el,name,the_id){
the_el.setAttribute("type","text");
the_el.setAttribute("name",name);
the_el.setAttribute("size","10");
the_el.setAttribute("maxlength","250");
the_el.setAttribute("value","");
this.cI.dom.setId({el:the_el,id:the_id});
this.cI.dom.setClass({el:the_el,className:"inputText"});
return the_el;
}
newsi.Console.STAF.prototype.setID=function(el,id){
el.setAttribute("id",id);
el.id=id;
return el;
}
newsi.Console.STAF.prototype._removeClass=function(element){
this.cI.dom.removeClass({el:element})
return element;
}
newsi.Console.STAF.prototype._setClass=function(element,name){
this.cI.dom.setClass({el:element,className:name});
return element;
}
newsi.Console.STAF.prototype.isValidEmail=function(field){
var filter=/^.+\@[A-Za-z0-9\-\.]+\.[A-Za-z]{2,6}$/;
if(filter.test(field)){return true;}
return false;
}
newsi.XMLHTTPRequest=function(obj){
this.flag=true;
this._ins=obj.instance;
this.versions=[
"MSXML2.XMLHttp.5.0",
"MSXML2.XMLHttp.4.0",
"MSXML2.XMLHttp.3.0",
"MSXML2.XMLHttp",
"Microsoft.XMLHttp"
];
}
newsi.XMLHTTPRequest.prototype=newsi;
newsi.XMLHTTPRequest.prototype._createXMLHTTPObject=function(){
if(typeof XMLHttpRequest != "undefined"){return new XMLHttpRequest();}
else if(window.ActiveXObject){
var f="for(var i=0;i<this.versions.length;i++){try{var req=new ActiveXObject(this.versions[i]);return req;}catch(oError){}}"
this.func=new Function(f)
return this.func();
}
}
newsi.XMLHTTPRequest.prototype._load=function(obj){
this._ins.request=this._createXMLHTTPObject();
this._ins.feedback=obj.feedback||"_noFeedback";
if(!obj.contentType){obj.contentType="application/x-www-form-urlencoded"}	
this._ins._cb=obj.callback||null;
var url=obj.url||null;
if(url==null||this._ins._cb==null){this._ins._report('no file to load or no callback function specified !',1);return;}
var type=obj.type.toLowerCase()||"get";
var async=true;
this._ins.body=obj.body||null;
if(type=="post"&&obj.body==null){this._ins._report("ERROR : Can't make a POST request without any body data.\nYou should either pass in body data or change the request type to GET.",2);return;}
if(this.flag){
this.flag=false;
this._ins.request.open(type,url,async);
this._ins.request.setRequestHeader('Content-Type', obj.contentType);
var _instance=this._ins;
var _ref=this
this._ins.request.onreadystatechange=function(){
if(_instance.request.readyState==4){
_ref._report('got something',3);
if(_instance.request.status==200){
_ref.process(_instance.request.responseText);
}
else{
_ref._report("ERROR : no load.",4);
}
}
}
var f="try{var _instance=this._ins;this._ins.request.send(this._ins.body);}catch(c){if(c.number==-2146697208){_instance._report('ERROR: Please set your Language Preference (Tools, Internet Options)',5);return;}_instance._report('ERROR: Send not possible.',6);return;}";
this.func=new Function(f)
return this.func();
}
else{this._ins._report("ERROR : cannot load two files simultaneously.",7);}
}
newsi.XMLHTTPRequest.prototype.process=function(file){
if(this._ins.request.getAllResponseHeaders()!='undefined'){
var _headtxt=this._ins.request.getAllResponseHeaders();
var _h=_headtxt.split(/\r?\n/);
var _headers={};
for(var i=_h.length;i>=0;i--){if(_h[i]==''){_h.splice(i,1);}}
for(var i=0;i<_h.length;i++){
var a=_h[i].split(': ');
_headers[a[0]]=a[1];
}
var rtrn={};
rtrn.headers=_headers;
if(rtrn.headers["Content-Type"].search(/xml/)!=-1){
rtrn.XML=this._ins.request.responseXML;
rtrn.text=null;
}
else{
rtrn.XML=null;
rtrn.text=this._ins.request.responseText;}
this._callback(rtrn);
}
}
newsi.XMLHTTPRequest.prototype._callback=function(msg){this.flag=true;this._ins[this._ins._cb](msg,this._ins.caller);}
newsi.XMLHTTPRequest.prototype._report=function(text,id){
var msg={};
msg.id=id;
msg.text=text;
this._ins[this._ins.feedback](msg);
}
newsi.XMLHTTPRequest.prototype._noFeedback=function(msg){return;}