var theID;
var thePlayID;
var faktor = 245 / 100;
var changePic = 3;
var now = 0;
var mm = 0;
var ss = 0;
var bControl;
var intVolumeBarState=6;
var idVideoClockTimer;
var previousstate;
	
// Define and preload image rollovers
var tabs_stationinfo = new Image();
var tabs_choosestation= new Image();
var tabs_chat = new Image();
var tabs_helpcenter = new Image();
tabs_stationinfo.src  = "eradiobasic/22a.gif";
tabs_choosestation.src  = "eradiobasic/22b.gif";
tabs_chat.src  = "eradiobasic/22c.gif";
tabs_helpcenter.src  = "eradiobasic/22c.gif";

	
	function monitorBuffering ()
	{
		if (navigator.userAgent.indexOf("MSIE") != -1 )
		{
			if (MediaPlayer.BufferingProgress!=0 && MediaPlayer.BufferingProgress!=100){
				document.all.playpos.innerHTML = "Buffering " + MediaPlayer.BufferingProgress + " %";
				imageSwap('iconstate','connecting');
			}
		}
		else{
			if (MediaPlayer.BufferingProgress!=0 && MediaPlayer.BufferingProgress!=100){
				document.all.playpos.innerHTML = "Buffering " + document.MediaPlayer.BufferingProgress + " %";
				imageSwap('iconstate','connecting');
			}
		}
	}
	function monitorPlaying ()
	{
		if (MediaPlayer.BufferingProgress==100){
			document.all.playpos.innerHTML = "Playing " + parseInt(MediaPlayer.Bandwidth / 1024) + "kbps";
		}
	}
	
	function onPlay()
	{
		if (navigator.userAgent.indexOf("MSIE") != -1 )
		{
			if ( now != 0 )
			{
				clearInterval ( theID );
				MediaPlayer.CurrentPosition = now;
				MediaPlayer.Play();
				now = 0;
				theID = setInterval('monitorBuffering()',100);
			}
			else{
				clearInterval ( theID );
				theID = setInterval('monitorPlaying()',100);
				imageSwap('iconstate','playing');
				MediaPlayer.Play();
			}
		}
		else{
			if ( now != 0 )
			{
				clearInterval ( theID );
				document.MediaPlayer.CurrentPosition = now;
				document.MediaPlayer.Play();
				now = 0;
				theID = setInterval('monitorBuffering()',100);
			}
			else{
				clearInterval ( theID );
				theID = setInterval('monitorPlaying()',100);
				imageSwap('iconstate','playing');
				document.MediaPlayer.Play();
			}
		}
	}

	function onStop()
	{
		if (navigator.userAgent.indexOf("MSIE") != -1 )
		{
			clearInterval ( theID );
			MediaPlayer.Stop();
			document.all.playpos.innerHTML = "Stopped";
			imageSwap('iconstate','paused');
		}
		else document.MediaPlayer.Stop();
	}
	function onPause()
	{
		if (navigator.userAgent.indexOf("MSIE") != -1 ) MediaPlayer.Pause();
		else document.MediaPlayer.Pause();
		document.all.playpos.innerHTML = "Paused";
		imageSwap('iconstate','paused');
	}
	function onMute()
	{
		if (document.MediaPlayer.Mute==0){
			MediaPlayer.Mute=1;
			previousstate = document.all.playpos.innerHTML;
			document.all.playpos.innerHTML = "Muted";
			imageSwap('iconstate','paused');
			imageSwap('button_mute','yes');
		}
		else {
			document.MediaPlayer.Mute=0;
			document.all.playpos.innerHTML = previousstate;
			imageSwap('iconstate','playing');
			imageSwap('button_mute','off');
		}
	}
	function outofmute()
	{
		if (document.MediaPlayer.Mute==0){
			imageSwap('button_mute','off');
		}
		else {
			imageSwap('button_mute','yes');
		}
	}
	
	function toMins(secs)
	{
		mm = parseInt ( secs / 60 );
		if ( mm < 10 ) mm = "0" + mm;
		ss = parseInt ( secs % 60 );
		if ( ss < 10 ) ss = "0" + ss;
	}
	
/*
Function: volumeChange(strChangeDir)
Parameters: strChangeDir: string ("increase" or "decrease")
*/
	function volumeChange(strChangeDir)
	{
		var strDiv="divVolumeBar";
		var strEval;
		var strBarColor;
	
		if ((strChangeDir=="increase") && (intVolumeBarState < 8))
			{
			strBarColor="#2CBD00";
			intVolumeBarState++;
			strEval = strDiv + intVolumeBarState + ".style.backgroundColor=strBarColor;";
			eval(strEval);
			}
	
		if ((strChangeDir=="decrease") && (intVolumeBarState > 0))
			{
			var strBarColor="#F8F9FA";
			strEval = strDiv + intVolumeBarState + ".style.backgroundColor=strBarColor;";
			eval(strEval);
			intVolumeBarState--;
			}
	
		setVolume(intVolumeBarState);
	}
	
	
	
	function clickIE4(){
		if (event.button==2){
			return false;
		}
	}
	
	function clickNS4(e){
		if (document.layers||document.getElementById&&!document.all){
			if (e.which==2||e.which==3){
				return false;
			}
		}
	}
	
	if (document.layers){
		document.captureEvents(Event.MOUSEDOWN);
		document.onmousedown=clickNS4;
	}
	else if (document.all&&!document.getElementById){
		document.onmousedown=clickIE4;
	}
	
	document.oncontextmenu=new Function("return false")
	