mywin = null;
var unLoad;
var surl;
function openwindow(url, width, height, scrollableBoolean) {
									 if (height==375) scrollableBoolean=1; // FORCE SCROLLBAR FOR E-SURVEY 
	surl = url;
	(scrollableBoolean==0) ? scrollable="no": scrollable="yes";
	if (url != "") {
		if (!mywin) {
			mywin = window.open(url,"mywin", "status=no, scrollbars=" + scrollable + ", resizable=yes, width=" + width + ", height=" + height + ",screenX=10,screenY=10,top=10,left=10");
			unLoad = (function () {mywin = null;});
			mywin.onunload = unLoad;
		}
		else {
			if (mywin.closed) {
				mywin = null;
				openwindow(surl, width, height, scrollableBoolean);
			}
			mywin.focus();
			mywin.location.href = url;
		}
	} 					
}
function popmailwin(x, y) {
  window.open(x,y,'status=no,scrollbars=no,resizable=yes,width=370,height=450');
}

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) {
		
		}
		else {
			
			consoleurl = consoleurl+'&bbram=1&bbwm=1';
		}
		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(pathtosection.indexOf('urdu') == -1) {
		
		}
		else {
			url = url+'&bbram=1&bbwm=1';
		}

		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"));
}

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
{
	var s = navigator.appVersion;
	s = s.substr(s.indexOf("("),s.length);
	while (isNaN(parseInt(s)))
	{
		s = s.substr(1,s.length);
	}
	return parseInt(s);
}
