/*Generic pop up code - please use this only unless you really need something different*/
function popUpPage(url, parameters, name)
{
	var day = new Date();
	var pageName = name ? name : day.getTime()

	eval("bbc"+pageName+" = window.open('"+url+"','"+pageName+"','"+parameters+"')");

	if (eval("bbc"+pageName) && window.focus) eval("bbc"+pageName).focus();
}

/* Media Selector pop up code */

function popwin(aPage, aTarget, w, h, var1, var2){
	        window.open (aPage,aTarget,'status=no,scrollbars=no,resizable=yes,width='+w+',height='+h);

}

/* launch code for avconsole */
function launch_main_player(site)
{
	
	if (site == null) //no site name passed in - have to leave this check in
	{
		clickmain=window.open("http://news.bbc.co.uk/broadband/news_console.stm","clickmain","toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0,top=100,left=100,width=671,height=373");
	}
	else
	{
		if (site == 'ukfs')
		{
			clickmain=window.open("http://news.bbc.co.uk/broadband/news_console.stm","clickmain","toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0,top=100,left=100,width=671,height=373");

		}
		else if (site == 'ifs')
		{
			clickmain=window.open("/narrowband/static/audio_video/avconsole/ifs/f_news_console.stm","clickmain","toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0,top=100,left=100,width=671,height=373");
		}
	}
}

function getPlatform()
{
	var myUserAgent;
	myUserAgent = navigator.userAgent.toLowerCase();

	if ((myUserAgent.indexOf("win") != -1) ||  (myUserAgent.indexOf("16bit") != -1))
	{
		return "win";
	}
	
	if (myUserAgent.indexOf("mac") != -1)
	{
		return "mac";
	}  
	
	if (myUserAgent.indexOf("x11") != -1)
	{
		return "unx";
	}  
	
	return "other";
}

function getBrowserType()
{
	var myUserAgent;

	var myMajor;
	myUserAgent= navigator.userAgent.toLowerCase();
	myMajor= parseInt(navigator.appVersion);
	if( (myUserAgent.indexOf('mozilla')!= -1) &&(myUserAgent.indexOf('spoofer')== -1) &&(myUserAgent.indexOf('compatible') == -1) &&(myUserAgent.indexOf('opera') == -1) &&(myUserAgent.indexOf('webtv')  == -1) )
	{  
		if (myMajor > 4 )
			{
				return "nav6";
			} 
		else if ((myMajor == 4 ) || (myMajor == 5 ))
			{
				return "nav4";
			}
	}
	
	if (myUserAgent.indexOf("msie") == 4)
		{
			return "ie4";
			
	}
	else if (myUserAgent.indexOf("msie") == 5)
		{
			return "ie5";
		}	
// dom compliant browsers are allowed
	if(document.body.firstChild) 
	return "domCompliant";
	return "other";
}

function getBrowserVersion() //this is for the ticker to identify between mac IE4 and IE5
{
	alert ('SIMON');
	var s = navigator.appVersion;
	s = s.substr(s.indexOf("("),s.length);
	while (isNaN(parseInt(s)) && (s.length > 0))
	{
		alert('s - '+ s);
		s = s.substr(1,s.length);
	}
	return parseInt(s);
}

function request_launch(site)
{
	if (getPlatform() != "other" &&(getBrowserType() == "ie4" || getBrowserType() == "nav4" || getBrowserType() == "domCompliant"))
	{
		launch_main_player(site);
	} 
	else 
	{
		self.location.href="/1/shared/bsp/hi/services/help/html/av_console_browsers.stm";
	}
	
	return;
}


function openWindow(){
	var mywin = null;var unLoad;
	var surl = "http://news.bbc.co.uk/hi/english/static/business/data_desktop/mardata/ftse.stm";
	if (!mywin){mywin = window.open(surl,'BBCNewsOnline','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=370,height=292');
		mywin.location = surl;
		if (mywin.opener == null) mywin.opener = window; 
		mywin.opener.name = "opener";
	}else{
		if (mywin.closed){	
			mywin = null;openWindow();
		}
		if (mywin.focus) mywin.focus();
		mywin.location.href = surl;
	}
}



function popup(url) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(url, '" + id + "', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=370,height=220');");
} 


function popUp(pageurl,width,height,scroll){
	day = new Date();
	id = day.getTime();
	if (window.screen) {  
		lpos = (screen.width/2)-(width/2);  
		hpos = (screen.height/2)-(height/2);
	}else	{
		lpos = 1;
		hpos = 1;		
	}		 		
	eval("bbcnews"+id+" = window.open('"+pageurl+"','"+id+"','toolbar=0,scrollbars="+scroll+",location=0,status=0,menubar=0,resizable=0,width="+width+",height="+height+",left="+lpos+",top="+hpos+"')");
}

//RSS
function getArgs() { 
	var Args = new Object(); 
	var query = location.search.substring(1); 
	var pairs = query.split("&"); 
	for (var i = 0; i < pairs.length; i++) 
	{ 
		var pos = pairs[i].indexOf('='); 
		if (pos == -1) continue; 
		var argname = pairs[i].substring(0,pos); 
		var value = pairs[i].substring(pos+1); 
		Args[argname] = unescape(value); 
	} 
	return Args;
}

function getRssUrl() { 
if (document.getElementsByTagName)
{
	var url = "http://news.bbc.co.uk/hi/arabic/help/rss/";
	var linkTags = document.getElementsByTagName("link");
	var rssURI;
	for (var i = 0; i < linkTags.length; i++) {if (linkTags[i].getAttribute('type') == "application/rss+xml") {rssURI = linkTags[i].getAttribute('href');}}
	if (rssURI){document.write('<div style="padding-left:0px; padding-right:0px;" class="lhsdl">-----------------<br/></div><div class="lhsdl" style="padding:0 0px 0 0;margin:2px 4px 0 4px;"><a href="'+rssURI+'"><img height="16" hspace="0" vspace="0" border="0" width="16" alt="News feeds" src="http://newsimg.bbc.co.uk/shared/img/v3/feed.gif" title="News feeds" /></a></div><div class="lhsdl" style="padding:0 0px 0 0;margin:2px 0 2px 4px;"><a href="'+url+'" title="What is RSS?">ما هي خدمة RSS؟</a></div>')}
}
}

function getRssUrlStory(rssURI) { 

if (document.getElementsByTagName)
{
	var url = "http://news.bbc.co.uk/hi/arabic/help/rss/";
	if (rssURI){document.write('<span class="lhsdl"><a href="'+rssURI+'"><img height="16" hspace="0" vspace="0" border="0" width="16" alt="News feeds" src="http://newsimg.bbc.co.uk/shared/img/v3/feed.gif" title="News feeds" align="right" /></a> | <a href="'+url+'?rss='+rssURI+'" title="What is RSS?">ما هي خدمة RSS؟</a></span><br clear="all"/>')}
}
}


/* functions to open video console */

function launchAVConsoleStory(storyid, pathtoconsole,pathtostory)

{

            if(bbcV2Tst())

            {

            

                        consoleurl = "http://www.bbc.co.uk/mediaselector/check"+pathtoconsole+"?redirect=fs.shtml&nbram=1&nbwm=1&ws_storyid=" + storyid +"&ws_pathtostory="+pathtostory;

 

                        if(
		(pathtoconsole.indexOf('urdu') == -1)
		&&(pathtoconsole.indexOf('arabic') == -1)
		&&(pathtoconsole.indexOf('persian') == -1)
		&&(pathtoconsole.indexOf('russian') == -1)
		&&(pathtoconsole.indexOf('spanish') == -1)
		&&(pathtoconsole.indexOf('portuguese') == -1)
			) {

                        

                        }

                        else {

                                    
									var resetStr = resetMediaSelectorPref(pathtoconsole);
                                    consoleurl = consoleurl+'&bbram=1&bbwm=1' + resetStr;
									
                        }

                        clickmain=window.open(consoleurl,"console","toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=0,width=681,height=387");

 

                        clickmain.focus();

 

            }

            else

            {

                        self.location.href="http://news.bbc.co.uk/2/hi/help/3681938.stm";

            }

}

 

function launchAVConsoleV3(pathtosection,pathtoconsole)

{

            if(bbcV2Tst())

            {           

            

                        var url = "http://www.bbc.co.uk/mediaselector/check"+pathtoconsole+"?redirect=fs.shtml&nbram=1&nbwm=1";            

 
                       if(
		(pathtoconsole.indexOf('urdu') == -1)
		&&(pathtosection.indexOf('arabic') == -1)
		&&(pathtosection.indexOf('persian') == -1)
		&&(pathtosection.indexOf('russian') == -1)
		&&(pathtosection.indexOf('spanish') == -1)
		&&(pathtosection.indexOf('portuguese') == -1)
			) {
			// do nothing
				}
                        else {
									var resetStr = resetMediaSelectorPref(pathtosection);
                                    url = url+'&bbram=1&bbwm=1' + resetStr;
                        }

 

                        if (pathtosection)

                        {

                                    url = url + "&ws_pathtostory=" + pathtosection;

                        }

                        clickmain=window.open(url,"console","toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=0,width=681,height=387");

 

 

clickmain.focus();

 

            }

            else

            {

                        self.location.href="http://news.bbc.co.uk/2/hi/help/3681938.stm";

            }

}

 

 

function bbcV2Tst(){

 

            var type = getBrowserType();

            

            return (type  != "other" &&(type == "ie5" || type == "nav6" || type == "domCompliant"));

}




// pic Gallery colours
var currentPicColor = '#6A6dbe';
var unselectedColor = '#009';
var deadLinkColor = '#ccc';
	
	
function toggleCollapsable(linkId, contentId) {
	
	if (document.getElementById(contentId).style.display == "none") {
		
		for (var i = 2; i < arguments.length; i+=2) {	
			document.getElementById(arguments[i]).innerHTML = collapsableShowText ;
			document.getElementById(arguments[i]).className = 'show'; 
			document.getElementById(arguments[i+1]).style.display = "none";
		}
		document.getElementById(linkId).innerHTML = collapsableHideText ;
		document.getElementById(linkId).className = 'hide'; 
		document.getElementById(contentId).style.display = "";
	} else {
		document.getElementById(linkId).innerHTML = collapsableShowText;
		document.getElementById(linkId).className = 'show'; 
		document.getElementById(contentId).style.display = "none";
	}
}

// Media Selector cookie reset

    function makeCrumb(n,v,d) {
        var expires = '';
    	if (d) {
    		var date = new Date();
    		date.setTime(date.getTime()+(d*24*60*60*1000));
    		expires = "expires=" + date.toGMTString() + ";";
    	}

    	document.cookie = n + "=" + v + ";" + 
    	                  expires + " path=/; domain=.bbc.co.uk;";
    }

    function readCrumb(n) {
    	var nm = n + "=";
    	var cc = document.cookie.split(';');
    	for(var i=0;i<cc.length;i++) {
    		var c = cc[i];
    		while (c.charAt(0)==' ') c = c.substring(1,c.length);
    		if (c.indexOf(nm) == 0) return c.substring(nm.length,c.length);
    	}
    	return null;
    }

    function eraseCrumb(n) {
    	makeCrumb(n,"",-1);
    }

    function resetMediaSelectorPref(pathtoconsole) {
        var pref = readCrumb('BBCMediaSelector');
        var touch = readCrumb('mstouch');
        pref = unescape(pref);
        // Checks for "broadband" option in Media Selector cookie v2.
        var bb = /^.{7}bb/;

            if ( (pref && !touch) && (pref.search(bb) != 1 && touch != 1) ) {
                eraseCrumb('BBCMediaSelector');
                makeCrumb('mstouch',1,90); //expires the cookie in 90 days
                
                return '&prefs=1' + passMSLang(pathtoconsole);;
            }
         return passMSLang(pathtoconsole);
    }
    
    
    function passMSLang(url) {
                    if (url.indexOf('portuguese') != -1) {
                        return "&lang=pt-br";
                    } else if (url.indexOf('urdu') != -1) {
                        return "&lang=ur";
                    } else if (url.indexOf('persian') != -1) {
                        return "&lang=fa";
                    } else if (url.indexOf('spanish') != -1) {
                        return "&lang=es";
                    } else if (url.indexOf('russian') != -1) {
                        return "&lang=ru";
                    } else if (url.indexOf('arabic') != -1) {
                        return "&lang=ar";
                    }   
    }

	
/** bbcws library v1.11 */
// Flash embed code
var bbcws = {
name:"bbcws",
dom:false
};

bbcws.Client=function(){
if(document.getElementById){bbcws.dom={};bbcws.dom.w3c=true;}else {bbcws.dom.w3c=false;}
// test for Error - a 'true' JavaScript 1.5 piece of functionality - Mac IE5 will return undefined for this.	
if(!window.Error){window.Error="error";}
if(window.Error != "error"){bbcws.true1_5=true;}else{bbcws.true1_5=false;}
bbcws.global={};
bbcws.global.platform="other";
if(navigator.appVersion.indexOf("Windows") != -1){bbcws.global.platform="Windows";}
if(window.ActiveXObject){bbcws.global.hasActiveX = true;}
}
// make a client object in order to set global bbcws vars...
bbcws.clnt=new bbcws.Client();
bbcws.hasActiveX=function(){if(bbcws.global.hasActiveX){return true;}return false;}
bbcws.hasDOM=function(){if(bbcws.dom){return true;}return false;}
bbcws.isW3C=function(){if(bbcws.dom.w3c){return true;}return false;}
bbcws.getPlatform=function(){return bbcws.global.platform;}
bbcws.getDomain=function(){return document.domain;}
bbcws.getURL=function(){return window.location.href;}
function trace(){};

bbcws.HTML=function(){}
bbcws.HTML.prototype=bbcws;
bbcws.html=new bbcws.HTML();
bbcws.HTML.Flash=function(){
this.requiredVersion=7;
this.maxVersion=-1;
this.actualVersion=0; 
this.hasRightVersion=false;
this.jsVersion = 1.0;
this.path="";
this.getString="str"
this.flVersion="00008";
this.flName="dev";
this.flColor = "#FFFFFF";
this.flWidth = "300";
this.flHeight = "220";
this.flQuality = "high";
this.flScale = "noscale";
this.flSalign = "tl";
this.flGetFlashPlayerURL="http://www.adobe.com/products/flashplayer/";
this.noFlashContent='<table cellspacing="0" cellpadding="0" border="0" width="352">'
		+ '<tr>'
		+ '<td>'
		+ '<table cellspacing="1" cellpadding="30" border="0" bgcolor="#cccccc" width="100%" height="33">'
		+ '<tr>'
		+ '<td bgcolor="#fafafa"><div class="font-family:Times New Roman, Tahoma (Arabic); color:#333333; font-size:18px; font-weight:bold;">مطلوب "فلاش"</div>'
		+ '<div style="font-family:Times New Roman, Tahoma (Arabic); color:#000000; font-size:15px; font-weight:bold;">لمشاهدة هذه الصفحة تحتاج أن يكون لدى جهازك إمكانية ماكروميديا فلاش.</div>'
		+ '<div style="font-family:Times New Roman, Tahoma (Arabic); color:#000000; font-size:15px; font-weight:bold;">حجم الملف 466 كيلوبايت وسوف يستغرق تحميله نحو دقيقتين مع وجود مودم 56 كيلوبايت. </div>'
		+ '<div style="font-family:Times New Roman, Tahoma (Arabic); color:#000000; font-size:15px; font-weight:bold;"><a target="_blank" href="http://www.macromedia.com/software/flashplayer/">اضغط هنا لتحميل الخاصية المطلوبة من موقع ماكروميديا</a></div></td>'
		+ '</tr>'
		+ '</table></td>'
		+ '</tr>'
		+ '</table>';
}
bbcws.HTML.Flash.prototype=bbcws;
bbcws.HTML.Flash.prototype.placeMovie=function(obj){
var arr=[
'requiredVersion',
'maxVersion',
'jsVersion',
'path',
'getString',
'flVersion',
'flName',
'flColor',
'flWidth',
'flHeight',
'flQuality',
'flScale',
'flSalign',
'flGetFlashPlayerURL',
'noFlashContent'
];
if(obj){for(var i=0;i<arr.length;i++){if(obj[arr[i]]){this[arr[i]]=obj[arr[i]];}}}
this.detectSettings();
document.write(this.doPlace());
}
bbcws.HTML.Flash.prototype.detectSettings=function(){
// if user of api doesn't set a max version, set it to 10 as a default...
if(this.maxVersion==-1){this.maxVersion=10;}
if(this.hasActiveX()&&this.getPlatform()=="Windows"){
	var mv=this.maxVersion;
	var i=2;
	while(i<=mv){
		if(this.getversion(i)){this.actualVersion=i;}
		i++;
		}
	}
if(navigator.plugins){
	if(navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]){
		var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
		var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
		var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
		var i=2;
		while(i<=this.maxVersion){if(flashVersion==i){this.actualVersion=i}i++;}
		if(flashVersion>=this.maxVersion){this.actualVersion=this.maxVersion;}
		}
	}	
if(navigator.userAgent.indexOf("WebTV") != -1){this.actualVersion=3;}
if(this.actualVersion>=this.requiredVersion){this.hasRightVersion=true;}
}
bbcws.HTML.Flash.prototype.doPlace=function(){
var last=this.path.substring((this.path.length-1));
if(last!="/"&&last!=""){this.path+="/";}
this.url=this.path+""+this.flName;
if(this.hasRightVersion){return this.rightVersion();}else{return this.wrongVersion();}
}
bbcws.HTML.Flash.prototype.wrongVersion=function(){return this.noFlashContent;}
bbcws.HTML.Flash.prototype.rightVersion=function(){
var content='<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="' 
	+ this.flWidth 
	+ '" HEIGHT="' 
	+ this.flHeight 
	+ '" id="Untitled-1" ALIGN="">'
	+ '<PARAM NAME=movie VALUE="' 
	+ this.url 
	+ '"><PARAM NAME=flashvars VALUE="' 
	+ this.getString 
	+ '"><PARAM NAME=base VALUE="' 
	+ this.path 
	+ 'v_' 
	+ this.flVersion 
	+ '/swf"><PARAM NAME=quality VALUE="' 
	+ this.flQuality 
	+ '"><PARAM NAME=bgcolor VALUE="' 
	+ this.flColor 
	+ '"><PARAM NAME=menu value=false /><param name="allowScriptAccess" value="sameDomain" /><PARAM NAME="scale" value="' 
	+ this.flScale 
	+ '" /><PARAM NAME="salign" value="' 
	+ this.flSalign 
	+ '" />'
	+ '<EMBED src="' 
	+ this.url 
	+ '" flashvars="' 
	+ this.getString 
	+ '" base="' 
	+ this.path 
	+ 'v_' 
	+ this.flVersion 
	+ '/swf" quality="' 
	+ this.flQuality 
	+ '" scale="' 
	+ this.flScale 
	+ '" salign="' 
	+ this.flSalign 
	+ '" bgcolor="' 
	+ this.flColor 
	+ '" WIDTH="' 
	+ this.flWidth 
	+ '" HEIGHT="' 
	+ this.flHeight 
	+ '" MENU="false" allowScriptAccess="sameDomain" NAME="Untitled-1" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="'
	+ this.flGetFlashPlayerURL
	+ '"></EMBED>'
	+ '</OBJECT>';
return content;
}
bbcws.HTML.Flash.prototype.getversion=function(version){
this.sf="ShockwaveFlash.ShockwaveFlash."+version;
var f="try{var ax=new ActiveXObject(this.sf);return true;}catch(e){return false;}";
this.func=new Function(f);
return this.func();
}
bbcws.html.flash=new bbcws.HTML.Flash();
	