// JavaScript Document
var NSsound = navigator.plugins && navigator.plugins["audio/x-pn-realaudio-plugin"] && navigator.javaEnabled();
var IEsound = navigator.plugins && document.all;
var curVolume = 5;
var timerID = null;
var intervalID = null;
var sliding = true;
var ready = true;
var shouldPlay = true;
var loaded = true;

var off = new Image(5, 5);
off.src = "pics/volumeoff.gif";
var on = new Image(5, 5);
on.src = "pics/volumeon.gif";

var stream = new Array();
stream[0] = new makeSong("http://www.livingwordbroadcast.org:8000/listen.pls", "Select Station/Stream To Tune-in");
stream[1] = new makeSong("http://www.livingwordbroadcast.org:8000/listen.pls", "Today's Featured Sermon");
stream[2] = new makeSong("http://www.livingwordbroadcast.org:8002/listen.pls", "Bible Study");
stream[3] = new makeSong("http://www.livingwordbroadcast.org:8004/listen.pls", "Prayer Line");
stream[4] = new makeSong("http://www.livingwordbroadcast.org:8006/listen.pls", "End Time Gospel Music");
stream[5] = new makeSong("http://www.livingwordbroadcast.org:8000/content/1959/59-0419A.pls", "William Branham\'s Life Story");
stream[6] = new makeSong("http://www.livingwordbroadcast.org:8000/content/1960/60-0930.pls", "Visions Of William Branham");
stream[7] = new makeSong("http://www.livingwordbroadcast.org:8000/content/EyeWitnessAccounts/GwendolynFarmer/GwendolynFarmer.pls", "Gwendolyn Farmer\'s EyeWitness Testimony");
stream[8] = new makeSong("http://www.livingwordbroadcast.org:8000/content/EyeWitnessAccounts/PearryGreen/PearryGreen-1.pls", "Pearry Green\'s EyeWitness Testimony Part #1");
stream[9] = new makeSong("http://www.livingwordbroadcast.org:8000/content/EyeWitnessAccounts/PearryGreen/PearryGreen-2.pls", "Pearry Green\'s EyeWitness Testimony Part #2");
stream[10] = new makeSong("http://www.livingwordbroadcast.org:8000/content/EyeWitnessAccounts/DawsonRiley/DawsonRiley-1.pls", "Dawson Riley\'s EyeWitness Testimony Part #1");
stream[11] = new makeSong("http://www.livingwordbroadcast.org:8000/content/EyeWitnessAccounts/DawsonRiley/DawsonRiley-2.pls", "Dawson Riley\'s EyeWitness Testimony Part #2");
stream[12] = new makeSong("http://www.livingwordbroadcast.org:8000/content/EyeWitnessAccounts/DawsonRiley/DawsonRiley-Zion.pls", "Dawson Riley\'s EyeWitness Testimony Part #3");

var NSvolume = new Array();
for (var i = 0; i <= 10; i++) {
  NSvolume[i] = i * 10;
}

var MyVolume = new Array();
MyVolume[0] = 0;
MyVolume[1] = 10;
MyVolume[2] = 20;
MyVolume[3] = 30;
MyVolume[4] = 40;
MyVolume[5] = 50;
MyVolume[6] = 60;
MyVolume[7] = 70;
MyVolume[8] = 80;
MyVolume[9] = 90;
MyVolume[10] = 100;

fetchsongId = window.setTimeout('fetchtitle();', 5000);
    var timerRunning = false;
    var idsongtitle,pause=0,position=0;
function fetchtitle() {
	if (streamtitle != null) {
		var streamtitleorg = streamtitle;
	} else {
	var streamtitleorg = "";
	}
var streamtitle = document.RBNPlayer.GetAuthor();
var streamsource = document.RBNPlayer.GetSource();
if (streamtitle == "") {
	streamtitle = streamsource;
	for (var i = 0; i < stream.length; i++) {
		 if (stream[i].url == streamsource) {
			var streamtitle = stream[i].name + " - Unable to fetch currently playing title";
		 }
	}
}
if (streamtitle == "") {
	 var streamtitle = "WMB1.com :: William Branham Legacy :: William Marrion Branham";
}
//document.getstreamtitle.streamtitle.value = streamtitle;
document.title = "WMB1.com :: William Branham Legacy :: William Marrion Branham ";
if (streamtitleorg != streamtitle) {
clearTimeout(idsongtitle);
document.getstreamtitle.streamtitlevalue.value = "" + streamtitle + "";
ticker();
}
fetchsongId = window.setTimeout('fetchtitle();', 5000);
}

//Scrolling message title

/*
    function ticker() {
	  var i,k
	  var msg = document.getstreamtitle.streamtitlevalue.value;
      k=(75/msg.length)+1;
      for(i=0;i<=k;i++) msg+=" "+msg;
      document.getstreamtitle.streamtitle.value=
                    msg.substring(position,position+75);
      if(position++==38) position=0;
      idsongtitle=setTimeout("ticker()",1000/10); 
    }
*/
   var beginPos = 0;
    
function ticker() {
  var scrollMsg = "                                                                 " + document.getstreamtitle.streamtitlevalue.value;
    var msgSpace = "";
 
  document.getstreamtitle.streamtitle.value=scrollMsg.substring(beginPos,scrollMsg.length)
    +msgSpace+scrollMsg.substring(0,beginPos);
    beginPos=beginPos + 1;
    if (beginPos > scrollMsg.length)
     { beginPos = 0;}
    
    idsongtitle=window.setTimeout("ticker();",200);

}

function makeSong(url, name) {
	this.url = url;
	this.name = name;
}

function changeVolume(step) {
	document.MuteBtn.src='pics/unmute.gif';
  if (!loaded) return;
  var newVolume = curVolume + step;
  if ((newVolume >= 0) && (newVolume <= 10))
    setVolume(newVolume);
  else if (sliding)
    stopSlide();
}

function mute() {
	  var isMuted = document.RBNPlayer.GetMute();
	  if (isMuted) {
	    document.RBNPlayer.SetMute(false);
		document.MuteBtn.src='pics/unmute.gif';
	  } else {
		document.RBNPlayer.SetMute(true);
		document.MuteBtn.src='pics/mute.gif';
	  }
checkimages();
}
imagesid = window.setTimeout('checkimages();', 2000);
function checkimages () {
	if (document.RBNPlayer.GetPlayState() == 0) {
	   document.playbtn.src = "pics/playoff.gif";
	   document.stopbtn.src = "pics/stopon.gif";
	   document.pausebtn.src = "pics/pauseoff.gif";
	} else if (document.RBNPlayer.GetPlayState() == 3) {
	   document.playbtn.src = "pics/playon.gif";
	   document.stopbtn.src = "pics/stopoff.gif";
	   document.pausebtn.src = "pics/pauseoff.gif";
	} else if (document.RBNPlayer.GetPlayState() == 4) {
	   document.playbtn.src = "pics/playoff.gif";
	   document.stopbtn.src = "pics/stopoff.gif";
	   document.pausebtn.src = "pics/pauseon.gif";	
	} else {
	   document.playbtn.src = "/pics/playon.gif";
	   document.stopbtn.src = "/pics/stopoff.gif";
	   document.pausebtn.src = "/pics/pauseoff.gif";
	}
imagesid = window.setTimeout('checkimages();', 60000);
}

function setVolume(vol) {
  if (!loaded) return;
  curVolume = vol;
  if (NSsound)
    document.RBNPlayer.SetVolume(NSvolume[vol]);
  else
    document.RBNPlayer.SetVolume(MyVolume[vol]);
  for (var i = 0; i < 10; i++) {
    document.images["vol" + i].src = (i < vol) ? on.src : off.src;
  }
}

function startSlide(direction) {
  changeVolume(direction);
  timerID = setTimeout("slideVolume(" + direction + ")", 500);
  return false;
}

function slideVolume(direction) {
  sliding = true;
  intervalID = setInterval("changeVolume(" + direction + ")", 50);
}

function stopSlide() {
  if (intervalID) clearInterval(intervalID);
  if (timerID) clearTimeout(timerID);
  sliding = false;
}

function display(text) {
  if (IEsound) event.srcElement.style.cursor = "hand";
  window.status = text;
  return true;
}

function dopause() {
  if (!loaded) return;
  shouldPlay = false;
  document.RBNPlayer.DoPause();
//checkimages();
imagesid = window.setTimeout('checkimages();', 1000);
}

function stop() {
  if (!loaded) return;
  shouldPlay = false;
  document.RBNPlayer.DoStop();
imagesid = window.setTimeout('checkimages();', 1000);
}

function play() {
	if (document.RBNPlayer.GetPlayState() == 0) {
	document.MuteBtn.src='pics/unmute.gif';
	document.RBNPlayer.SetMute(false);
	}
  if (!loaded) return;
  if (NSsound) ready = document.RBNPlayer.IsReady();
  if (!ready) {
    alert("The audio file hasn't loaded yet.");
    return;
  }
  var list = document.streamtitleform.stream;
  var songURL = list.options[list.selectedIndex].value;
    document.RBNPlayer.SetSource(songURL);
    document.RBNPlayer.DoPlay();
imagesid = window.setTimeout('checkimages();', 1000);
}
// this defn & See

function change() {
  if (!loaded) return;
  var list = document.streamtitleform.stream;
  var streamURL = list.options[list.selectedIndex].value;
  document.RBNPlayer.DoStop();
  if (NSsound)
    document.RBNPlayer.play(false, streamURL)
  else {
    document.RBNPlayer.filename = streamURL;
    shouldPlay = true;
  }
  play();
}

function mutebtn () {
	var isMuted = document.RBNPlayer.GetMute();
	  if (isMuted) {
	    //document.MediaPlayer.settings.mute = false;
		document.MuteBtn.src='pics/mute.gif';
	  } else {
		//document.MediaPlayer.settings.mute = true;
		document.MuteBtn.src='pics/unmute.gif';
	  }
	
}

function init() {
  loaded = true;
 setvolid = window.setTimeout('setVolume(' + curVolume + ');', 0);
  //setVolume(curVolume);
}

function makeVolume() {
  var str = ""; var j;
  for (var i = 0; i <= 9; i++) {
	  j = i + 1;
    str +=  "<IMG SRC='" + off.src + "' HEIGHT='" +
      off.width + "' WIDTH='" + off.width + "' NAME='vol" +
      i + "' onClick='setVolume(" + j + ");'>";
  }
  return str;
}

function parsefortime(num) {
	var u = num;
	var regex = new RegExp("^\\d{0,1}$");
	var hours = Math.floor((u / 3600)); 
	u = u - (hours * 3600);
	var minutes = Math.floor(u / 60);
	u = u - (minutes * 60);
	var seconds = u;
	if (regex.test(hours)) hours = "0" + hours;
	if (regex.test(minutes)) minutes = "0" + minutes;
	if (regex.test(seconds)) seconds = "0" + seconds;
	var result = hours + ":" + minutes + ":" + seconds;
	return result;
}

positiontimerid = window.setTimeout('streamposition();', 2000);
function streamposition () {
	if (document.RBNPlayer.GetPosition()) {
		var position = parsefortime(Math.floor((document.RBNPlayer.GetPosition() / 1000))) + " Live";
	} else {
		var position = "00:00:00";
	}
    document.positionform.position.value = position;
positiontimerid = window.setTimeout('streamposition();', 1000);
}

function resizeOuterTo(w,h) {
 if (parseInt(navigator.appVersion)>3) {
   if (navigator.appName=="Netscape") {
    top.outerWidth=w;
    top.outerHeight=h;
   }
   else top.resizeTo(w,h);
 }
}

<!-- resizeOuterTo(800,150); -->