function createSilverlight()
{
 Silverlight.createObjectEx({
  source: "player.xaml",
  parentElement: document.getElementById("SilverPlayer"),
  id: "SilverPlayerControl",
  properties: {
   width: "100%",
   height: "100%",
   version: "2.0.30523",
            background:'transparent',
            isWindowless:'true',
   enableHtmlAccess: "true"
  },
  events: {onLoad:onLoad}
 });
    
 // Give the keyboard focus to the Silverlight control by default
    document.body.onload = function() {
      var silverPlayerControl = document.getElementById('SilverPlayerControl');
      if (silverPlayerControl)
      silverPlayerControl.focus();
      main();
    }
}

function media_mute(sender, args) {
	var bMuteState;
	bMuteState = sender.findName("media").IsMuted;
	if (bMuteState == true) {
		sender.findName("media").IsMuted = "false";
	    sender.findName("muteftb").Fill = "lightgray"; 
	    sender.findName("ftbmute").Text = "mute"; 
	} else {
		sender.findName("media").IsMuted = "true";
	    sender.findName("muteftb").Fill = "red"; 
	    sender.findName("ftbmute").Text = "muted"; 
	}
}

function media_gbr(sender, args) {
	sender.findName("media").source = "mms://81.171.38.91:80/gbr";
    sender.findName("media").play();
    sender.findName("recgbr").Fill = "lightgreen"; 
    sender.findName("recftb").Fill = "lightgray"; 
    sender.findName("recpre").Fill = "black"; 
    sender.findName("recstopftb").Fill = "lightgray"; 
    sender.findName("jlisten").Text = "You are listening to: Got Bass Radio (hit buttons to stop music or switch channels). No music? Click Here!!"; 
//	document.getElementById('gbrhide').style.display='inline';
//	document.getElementById('gbrshow').style.display='none';
//	document.getElementById('scheduleftb').style.display='none';
//	document.getElementById('schedulegbr').style.display='inline'
}

function media_gbr_low(sender, args) {
	sender.findName("media").source = "mms://81.171.38.91:80/gbrs";
    sender.findName("media").play();
    sender.findName("recgbr").Fill = "green"; 
    sender.findName("recftb").Fill = "lightgray"; 
    sender.findName("recpre").Fill = "black"; 
    sender.findName("recstopftb").Fill = "lightgray"; 
    sender.findName("jlisten").Text = "You are listening to: GBR -low bandwith- (hit buttons to stop music or switch channels). No music? Click Here!!"; 
//	document.getElementById('gbrhide').style.display='inline';
//	document.getElementById('gbrshow').style.display='none';
//	document.getElementById('scheduleftb').style.display='none';
//	document.getElementById('schedulegbr').style.display='inline'
}

function media_ftb(sender, args) {
	sender.findName("media").source = "mms://81.171.38.91:80/ftb";
    sender.findName("media").play();
    sender.findName("recgbr").Fill = "lightgray"; 
    sender.findName("recftb").Fill = "lightgreen"; 
    sender.findName("recpre").Fill = "black"; 
    sender.findName("recstopftb").Fill = "lightgray"; 
    sender.findName("jlisten").Text = "You are listening to: Face the Bass (hit buttons to stop music or switch channels). No music? Click Here!!"; 
//	document.getElementById('gbrhide').style.display='none';
//	document.getElementById('gbrshow').style.display='inline';
//	document.getElementById('scheduleftb').style.display='inline';
//	document.getElementById('schedulegbr').style.display='none'
}

function media_ftb_low(sender, args) {
	sender.findName("media").source = "mms://81.171.38.91:80/ftbs";
    sender.findName("media").play();
    sender.findName("recgbr").Fill = "lightgray"; 
    sender.findName("recpre").Fill = "black"; 
    sender.findName("recftb").Fill = "green"; 
    sender.findName("recstopftb").Fill = "lightgray"; 
    sender.findName("jlisten").Text = "You are listening to: -FTB -low bandwith- (hit buttons to stop music or switch channels). No music? Click Here!!"; 
//	document.getElementById('gbrhide').style.display='none';
//	document.getElementById('gbrshow').style.display='inline';
//	document.getElementById('scheduleftb').style.display='inline';
//	document.getElementById('schedulegbr').style.display='none'
}

function media_stop(sender, args) {
    sender.findName("media").stop();
    sender.findName("recftb").Fill = "lightgray"; 
    sender.findName("recgbr").Fill = "lightgray"; 
    sender.findName("recpre").Fill = "black"; 
    sender.findName("recstopftb").Fill = "lightgreen"; 
    sender.findName("jlisten").Text = "You are listening to: -nothing- (hit buttons to stop music or switch channels). No music? Click Here!!"; 
    document.getElementById('showmov').setAttribute('width',1);

}

function media_pre(sender, args) {
	sender.findName("media").source = "mms://81.171.38.91:80/pre";
    sender.findName("media").play();
    sender.findName("recgbr").Fill = "lightgray"; 
    sender.findName("recftb").Fill = "lightgray"; 
    sender.findName("recpre").Fill = "lightgreen"; 
    sender.findName("recstopftb").Fill = "lightgray"; 
    sender.findName("jlisten").Text = "You are listening to: -secret- (hit buttons to stop music or switch channels). No music? Click Here!!"; 
}

function old_player() {
  window.location="http://gotbassradio.com/chat/oldplayer.asp";
}


//added functions

function main(){
    nowplaying();

 //   document.getElementById('button1').innerHTML=Date();
}


function nowplaying(){
    getupdate();
//    updtime();
    timerID = setTimeout("main()",60000);
}

function GetXmlHttpObject(){
    xmlHttp = null;
    try
    {
        // Firefox, Opera, Safari
        xmlHttp=new XMLHttpRequest();
    }
    catch (e)
    {
        // Internet Explorer
        try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // 6.0+
        }
        catch (e)
        {
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); // 5.5+
        }
    }
    return xmlHttp;
}

var xmlHttp = GetXmlHttpObject();

function getupdate(){
    var url = "http://"+document.domain+"/chat/nowplaying.asp";
    xmlHttp.open("GET", url+'?bustcache='+new Date().getTime(), true);
    xmlHttp.onreadystatechange=stateChanged;
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
    xmlHttp.send(null);
}

function stateChanged() { 
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
        var response = xmlHttp.responseText;
        var lines = xmlHttp.responseText.split("\n");
        var newobj=document.getElementById("SilverPlayerControl");
	    newobj.content.findName("txtgbr").Text=lines[0];
	    newobj.content.findName("txtftb").Text=lines[1];
	    newobj.content.findName("txtpre").Text=lines[2];
    	if (newobj.content.findName("media").NaturalVideoHeight > 0)
		  {document.getElementById('showmov').setAttribute('width',350);}
		else
   		  {document.getElementById('showmov').setAttribute('width',1);}
    } 
}

function wacht(msecs)
{
var start = new Date().getTime();
var cur = start
while(cur - start < msecs)
{
cur = new Date().getTime();
} 
} 

