//set up radio station array

var radio_name = new Array();
var radio_stream = new Array ();
var radio_url = new Array(); 
var radio_image = new Array(); 

var i=0;
radio_name[i]='Select Radio Station...';
radio_stream[i]='';
radio_url[i]='';
radio_image[i]='';

i=1;
radio_name[i]='BBC Radio1';
radio_stream[i]='http://www.bbc.co.uk/radio1/realaudio/media/r1live.ram';
radio_url[i]='http://www.bbc.co.uk/radio1/';
radio_image[i]='bbcr1.gif';


i=2;
radio_name[i]='BBC Radio1 Xtra';
radio_stream[i]='rtsp://rmlive.bbc.co.uk/bbc-rbs/rmlive/ev7/live24/1xtra/live/1xtra_dsat_g2.ra';
radio_url[i]='http://www.bbc.co.uk/1xtra/';
radio_image[i]='bbcr1x.gif';
	
i=3;
radio_name[i]='BBC Radio2';
radio_stream[i]='http://www.bbc.co.uk/radio2/realmedia/fmg2.ram';
radio_url[i]='http://www.bbc.co.uk/radio2/';
radio_image[i]='bbcr2.gif';

i=4;
radio_name[i]='BBC Radio3';
radio_stream[i]='http://www.bbc.co.uk/radio3/ram/r3g2.ram';
radio_url[i]='http://www.bbc.co.uk/radio3/';
radio_image[i]='bbcr3.gif';

i=5;
radio_name[i]='BBC Radio4';
radio_stream[i]='rtsp://rmlive.bbc.co.uk/bbc-rbs/rmlive/ev7/live24/radio4/live/r4_dsat_g2.ra';
radio_url[i]='http://www.bbc.co.uk/radio4/';
radio_image[i]='bbcr4.gif';

i=6;
radio_name[i]='BBC Radio5 Live';
radio_stream[i]='http://www.bbc.co.uk/fivelive/live/surestream.ram';
radio_url[i]='http://www.bbc.co.uk/fivelive/';
radio_image[i]='bbcr5l.gif';

i=7;
radio_name[i]='BBC Radio5 Live Sports Extra';
radio_stream[i]='rtsp://rmlive-acl.bbc.co.uk/bbc-rbs/rmlive-acl/ev7/live24/radio5/sportsextra/live/r5sx_tl_g2.ra';
radio_url[i]='http://www.bbc.co.uk/fivelive/sportsextra/';
radio_image[i]='bbcr5lsx.gif';

i=8;
radio_name[i]='BBC Radio 6 Music';
radio_stream[i]='http://www.bbc.co.uk/6music/ram/dsatg2.ram';
radio_url[i]='http://www.bbc.co.uk/6music/';
radio_image[i]='bbcr6.gif';

i=9;
radio_name[i]='BBC Radio 7';
radio_stream[i]='http://www.bbc.co.uk/bbc7/realplayer/dsatg2.ram';
radio_url[i]='http://www.bbc.co.uk/bbc7/';
radio_image[i]='bbcr7.gif';

i=10;
radio_name[i]='BBC Asian Network';
radio_stream[i]='http://www.bbc.co.uk/asiannetwork/rams/asiannetwork.ram';
radio_url[i]='http://www.bbc.co.uk/asiannetwork/';
radio_image[i]='bbcran.gif';

i=11;
radio_name[i]='BBC World Service';
radio_stream[i]='http://www.bbc.co.uk/worldservice/meta/tx/nb/live_infent_au_nb.ram';
radio_url[i]='http://www.bbc.co.uk/worldservice/';
radio_image[i]='bbcrws.gif';

i=12;
radio_name[i]='Capital FM';
radio_stream[i]='http://www.radio-now.co.uk/l/capitalfmlo.asx';
radio_url[i]='http://www.capitalfm.com/';
radio_image[i]='caprad.gif';

i=13;
radio_name[i]='Virgin Radio';
radio_stream[i]='http://www.smgradio.com/core/audio/wmp/live.asx?service=vr';
radio_url[i]='http://www.virginradio.co.uk/';
radio_image[i]='virrad.gif';


//setup tv atation array

var tv_name = new Array();
var tv_stream = new Array();
var tv_url = new Array();
var tv_image = new Array();


i=0;
tv_name[i]='Select TV Station...';
tv_stream[i]='';
tv_url[i]='';
tv_image[i]='';

i=1;
tv_name[i]='BBC News';
tv_stream[i]='http://www.bbc.co.uk/newsa/n5ctrl/tvseq/n24/bb/rm/video/heads_bb.ram';
tv_url[i]='http://news.bbc.co.uk/';
tv_image[i]='bbcn24.gif';


i=2;
tv_name[i]='BBC Newsnight';
tv_stream[i]='http://www.bbc.co.uk/newsa/n5ctrl/tvseq/od/bbc2/bb/rm/video/newsnight_bb.ram';
tv_url[i]='http://news.bbc.co.uk/1/hi/programmes/newsnight/';
tv_image[i]='bbc2.gif';

i=3;
tv_name[i]='BBC Newsnight Review';
tv_stream[i]='rtsp://rmgeo.bbc.net.uk/news/media_acl/mps/fix/news/video/75000/bb/75868_16x9_bb.rm';
tv_url[i]='http://news.bbc.co.uk/1/hi/programmes/newsnight/';
tv_image[i]='bbc2.gif';


i=4;
tv_name[i]='BBC Entertainment News (Liquid News)';
tv_stream[i]='http://www.bbc.co.uk/newsa/n5ctrl/summaries/entertain/nb_liquid_news.ram';
tv_url[i]='http://www.bbc.co.uk/pressoffice/pressreleases/stories/2003/11_november/13/liquid_news.shtml';
tv_image[i]='bbc3.gif';

i=5;
tv_name[i]='CBC News Canada';
tv_stream[i]='http://www.cbc.ca/MRL/clips/latest/latest-CBCNewsworld.ram';
tv_url[i]='http://www.cbc.ca/news/';
tv_image[i]='cbc.gif';

i=6;
tv_name[i]='Bloomberg';
tv_stream[i]='http://www.bloomberg.com/streams/video/LiveUK_nb.asx';
tv_url[i]='http://www.bloomberg.com/';
tv_image[i]='bloomberg.gif';

i=7;
tv_name[i]='Perfume - Film Trailer';
tv_stream[i]='rtsp://lonrle.interoutemediaservices.com/{1a80e472-fdf0-4698-82b0-8208e5671dd2}/{1d3dca00-049c-44e2-8be9-82832ab39489}/perfume_trlr_hi.rm';
tv_url[i]='http://www.bbc.co.uk/films/trailers/';
tv_image[i]='bbcfilm.gif';
	
i=8;
tv_name[i]='HOT FUZZ - Film Trailer';
tv_stream[i]='rtsp://lonrle.interoutemediaservices.com/{1a80e472-fdf0-4698-82b0-8208e5671dd2}/{637ea1b2-db51-442a-a444-073a02ee2c0d}/HotFuzz_Trailer2_large.rm';
tv_url[i]='http://www.bbc.co.uk/films/trailers/';
tv_image[i]='bbcfilm.gif';

i=9;
tv_name[i]="Pan's Labyrinth - Film Trailer";
tv_stream[i]='rtsp://lonrle.interoutemediaservices.com/{1a80e472-fdf0-4698-82b0-8208e5671dd2}/{ee20d860-d666-4712-a442-c8d742f9ef74}/pans_hi.rm';
tv_url[i]='http://www.bbc.co.uk/films/trailers/';
tv_image[i]='bbcfilm.gif';


i=10;
tv_name[i]='SHREK the Third - Film Trailer';
tv_stream[i]='rtsp://lonrle.interoutemediaservices.com/{1a80e472-fdf0-4698-82b0-8208e5671dd2}/{37b3d954-91a5-462d-ad93-178bdd892319}/shrek_the_third_trailer_1500k.rm';
tv_url[i]='http://www.bbc.co.uk/films/trailers/';
tv_image[i]='bbcfilm.gif';

i=11;
tv_name[i]='Apocalypto - Film Trailer';
tv_stream[i]='rtsp://lonrle.interoutemediaservices.com/{1a80e472-fdf0-4698-82b0-8208e5671dd2}/{3615dbc1-f1f7-4d04-8bd2-79beb20c2b27}/trailer_real_hi_500x288.rm';
tv_url[i]='http://www.bbc.co.uk/films/trailers/';
tv_image[i]='bbcfilm.gif';

i=12;
tv_name[i]='The Last King Of Scotland - Film Trailer';
tv_stream[i]='rtsp://lonrle.interoutemediaservices.com/{1a80e472-fdf0-4698-82b0-8208e5671dd2}/{05670624-7d8d-4098-8406-d579dba21d34}/trailer_real_hi_500x276.rm';
tv_url[i]='http://www.bbc.co.uk/films/trailers/';
tv_image[i]='bbcfilm.gif';

i=13;
tv_name[i]='Borat - Film Trailer';
tv_stream[i]='rtsp://lonrle.interoutemediaservices.com/{1a80e472-fdf0-4698-82b0-8208e5671dd2}/{3f38043a-9b0a-4678-baf2-46c0b804bf81}/borat_trailer2_1500k.rm';
tv_url[i]='http://www.bbc.co.uk/films/trailers/';
tv_image[i]='bbcfilm.gif';

i=14;
tv_name[i]='The Sentinel - Film Trailer';
tv_stream[i]='rtsp://lonrle.interoutemediaservices.com/{1a80e472-fdf0-4698-82b0-8208e5671dd2}/{5d115e3d-ef8b-43e5-b439-050fa8006e79}/the_sentinel_trailer_850k.rm';
tv_url[i]='http://www.bbc.co.uk/films/trailers/';
tv_image[i]='bbcfilm.gif';

i=15;
tv_name[i]='Rocky Balboa - Film Trailer';
tv_stream[i]='rtsp://lonrle.interoutemediaservices.com/{1a80e472-fdf0-4698-82b0-8208e5671dd2}/{2c0fce6c-634a-42bf-85e4-21b84202f7b3}/rocky_balboa_trailer_850k.rm';
tv_url[i]='http://www.bbc.co.uk/films/trailers/';
tv_image[i]='bbcfilm.gif';

i=16;
tv_name[i]='Deep Water - Film Trailer';
tv_stream[i]='rtsp://lonrle.interoutemediaservices.com/{1a80e472-fdf0-4698-82b0-8208e5671dd2}/{be48c547-84c5-46fc-9653-e466c3faec82}/deep_water_ hi.rm';
tv_url[i]='http://www.bbc.co.uk/films/trailers/';
tv_image[i]='bbcfilm.gif';

i=17;
tv_name[i]='The Grudge 2 - Film Trailer';
tv_stream[i]='rtsp://lonrle.interoutemediaservices.com/{1a80e472-fdf0-4698-82b0-8208e5671dd2}/{5ecd9910-31dc-4dbe-97b1-e8176cfa03e9}/the_grudge_2_trailer_1500k.rm';
tv_url[i]='http://www.bbc.co.uk/films/trailers/';
tv_image[i]='bbcfilm.gif';

i=18;
tv_name[i]='Babel - Film Trailer';
tv_stream[i]='rtsp://lonrle.interoutemediaservices.com/{1a80e472-fdf0-4698-82b0-8208e5671dd2}/{48840867-8196-47b6-887e-c265c52ecb8f}/babel_trailer_1500k.rm';
tv_url[i]='http://www.bbc.co.uk/films/trailers/';
tv_image[i]='bbcfilm.gif';




function insert_player(station_id, selector_id) {

var IMAGE_DIR="../scl_images/thirdparty/";
var showcontrols=true;
var showstatusbar=false;
var showdisplay=true;


var stationstart=false;
(station_id>0)&&(stationstart=true);

//select the correct stream url and station name arrays depending on the selector control - tv or radio
var stream_url=""; 
var station_name="";
var station_url="";
var station_image="tv-radio-no-station.gif";
(selector_id=="radio")&&(stream_url=radio_stream[station_id])&&(station_name=radio_name[station_id])&&(station_url=radio_url[station_id])&&(station_image=radio_image[station_id]);
(selector_id=="tv")&&(stream_url=tv_stream[station_id])&&(station_name=tv_name[station_id])&&(station_url=tv_url[station_id])&&(station_image=tv_image[station_id]);

station_image=IMAGE_DIR+station_image;

var fileext3 = stream_url.substr(stream_url.length-3,3);
var fileext2 = stream_url.substr(stream_url.length-2,2);
var rp=((fileext2=="rm")||(fileext2=="ra")||(fileext3=="ram")||(fileext3=="pls")||(fileext3=="rpm"));
(station_id==0)&&(rp=true); //show rp by default at start
var inserthtml="";


//load default player...

!rp && (inserthtml="\n"+
"<OBJECT ID='Player' HEIGHT='400' WIDTH='500' classid='CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95' codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112' standby='Loading Microsoft® Windows® Media Player components...'      type='application/x-oleobject'>\n"+
"	 <PARAM NAME='Filename' value='"+stream_url+"'\n"+
"	 <PARAM NAME='ShowControls' VALUE='true'>\n"+
"   <PARAM NAME='ShowStatusBar' VALUE='true'>\n"+
"   <PARAM NAME='ShowPositionControls' value='False'>\n"+
"   <PARAM NAME='ShowTracker' value='False'>\n"+
"	<EMBED type='application/x-mplayer2'\n"+
"	pluginspage = 'http://www.microsoft.com/Windows/MediaPlayer/'\n"+
"	SRC='"+stream_url+"'\n"+
"	name='Player'\n"+
"	height='400'\n"+
"	width='500'\n"+
"	AutoStart="+stationstart+"\n"+
"	showcontrols='"+showcontrols+"' showstatusbar='"+showstatusbar+"' showdisplay='"+showdisplay+"'>\n"+
"	</EMBED>\n"+
"<noembed><a href='"+stream_url+"'>Play "+station_name+"</a></noembed>\n"+
"	</OBJECT>\n"
);


rp && (inserthtml="\n"+
"<OBJECT	ID='player_top'	CLASSID='clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA'\n"+
"	HEIGHT=300 WIDTH=500>\n"+
"	<PARAM NAME='controls' VALUE='ImageWindow'>\n"+
"	<PARAM NAME='console' VALUE='Clip1'>\n"+	
"	<PARAM NAME='autostart' VALUE="+stationstart+">\n"+
"	<PARAM NAME='src' VALUE='"+stream_url+"'>\n"+
"	<EMBED SRC='"+stream_url+"' type='audio/x-pn-realaudio-plugin' CONSOLE='Clip1' CONTROLS='ImageWindow' HEIGHT=300 WIDTH=500 AUTOSTART="+stationstart+" pluginspage='http://www.real.com/'></EMBED>\n"+ 
"              <noembed><a href='"+stream_url+"'>Play "+station_name+"</a></noembed>\n"+
"	</OBJECT>\n"+
"<OBJECT	ID='player_bot'	CLASSID='clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA'\n"+
"	HEIGHT=100 WIDTH=500>\n"+
"	<PARAM NAME='controls' VALUE='All'>\n"+
"	<PARAM NAME='console' VALUE='Clip1'>\n"+	
"	<PARAM NAME='autostart' VALUE="+stationstart+">\n"+
"	<PARAM NAME='src' VALUE='"+stream_url+"'>\n"+
"	<EMBED SRC='"+stream_url+"' type='audio/x-pn-realaudio-plugin' CONSOLE='Clip1' CONTROLS='All' HEIGHT=100 WIDTH=500 AUTOSTART="+stationstart+" pluginspage='http://www.real.com/'></EMBED>\n"+ 
"              <noembed><a href='"+stream_url+"'>Play "+station_name+"</a></noembed>\n"+
"	</OBJECT>\n"+
"<div class='clearer'>&nbsp;</d	iv>\n"
);

 
document.getElementById('coffee_radio_player').innerHTML = inserthtml;

//now set the images and links and highliting and reset the now unused dropdown 
inserthtml="<a class='coffee_player_logo_link' href='"+station_url+"'><img class='coffee_player_logo_image' src='"+station_image+"'></a>\n";
document.getElementById('coffee_player_logo_area').innerHTML = inserthtml;
(selector_id=="radio") && (document.getElementById('coffee_tv_dropdown').selectedIndex=0);
(selector_id=="tv")&& (document.getElementById('coffee_radio_dropdown').selectedIndex=0);
	
};


function populate_radiolist() {
//nb must insert whole select else msie bug

var inserthtml="<select id='coffee_radio_dropdown' name='select' onchange='insert_player(this.selectedIndex, \"radio\");'>";
var radio_id=0;
for (radio_id in radio_name) {
inserthtml += "<OPTION class='coffee_radio_dropdown_option' VALUE="+radio_id+">"+radio_name[radio_id]+"</OPTION>\n";
}
inserthtml+="</select>";
var obj = document.getElementById('coffee_radio_form');
obj.innerHTML = inserthtml;

}

function populate_tvlist() {
//nb must insert whole select else msie bug

var inserthtml="<select id='coffee_tv_dropdown' name='select' onchange='insert_player(this.selectedIndex,\"tv\");'>";
var tv_id=0;
for (tv_id in tv_name) {
inserthtml += "<OPTION VALUE="+tv_id+">"+tv_name[tv_id]+"</OPTION>\n";
}
inserthtml+="</select>";
var obj = document.getElementById('coffee_tv_form');
obj.innerHTML = inserthtml;

}

function menu_off() {
document.getElementById('navigationbarwrapper').style.visibility = "hidden";
}

function menu_on() {
document.getElementById('navigationbarwrapper').style.visibility = "visible";
}

function set_page_width(page_width) {

document.getElementById('curlpage').style.width = page_width+"px";
document.getElementById('copyrightpage').style.width = page_width+"px";
document.getElementById('fadepage').style.width = page_width+"px";
document.getElementById('imagepage').style.width = page_width+"px";
document.getElementById('logopage').style.width = page_width+"px";
document.getElementById('outercontainerpage').style.width = page_width+"px";

}



function setup_coffee_page () {
set_page_width("940");
populate_radiolist();
populate_tvlist();
insert_player(0,'');
menu_off();
}

setup_coffee_page();
