
var vlcwin;

function onLoad()
{
  vlcwin = {};

  vlcwin.vlc = document.getElementById("vlc");
  vlcwin.streamTree = document.getElementById("stream_tree");

   update_status() 
}

function update_status()
{
   var statusPanel = document.getElementById("statusPanel");
   var timePanel = document.getElementById("timePanel");

   var playing = vlcwin.vlc.isplaying();

   if( playing == true )
   {
      got_time = vlcwin.vlc.get_time();
      hours = Math.floor(got_time/ 3600);
      minutes = Math.floor((got_time/60) % 60);
      seconds = got_time % 60;
      time = hours+":"+minutes+":"+seconds;
      got_length = vlcwin.vlc.get_length();
      hours = Math.floor(got_length/ 3600);
      minutes = Math.floor((got_length/60) % 60);
      seconds = got_length % 60;
      length = hours+":"+minutes+":"+seconds;

      statusPanel.label = "Playing";
      timePanel.label = time+"/"+length;
   }
   else
   {
      timePanel.label = "--:--:--";
      statusPanel.label = "Stopped";
   }
   setTimeout( "update_status()",500);
}

/* Playback control */
function play()
{
    vlcwin.vlc.play();
}
function stop()
{
    vlcwin.vlc.stop();
}

function set_item( name )
{
    vlcwin.vlc.stop();
    vlcwin.vlc.clear_playlist();
    vlcwin.vlc.add_item( name );
    vlcwin.vlc.play();
}

function set_playlist_item()
{
    var uri = vlcwin.streamTree.view.getCellText(
			 vlcwin.streamTree.currentIndex,"uri");

    set_item( uri );
/*
    var help = document.getElementById('help');

    if( name == "VOD" )
    {
	help.setAttribute("value","VOD" );
    }
    else if( name == "UDP" )
    {
	help.setAttribute("value","UDP");

    }
    else
    {
        help.setAttribute("value","");
    }
*/
}

function toggleSeparate()
{
//  var vlc = document.getElementById('video');
  var separate = document.getElementById('separate');

  alert(separate);
alert(separate.label);
separate.label="DTC";

/*
  if(separate.getAttribute("checked") == "true" )
      vlc.setAttribute('hidden','yes');
  else
      vlc.setAttribute('hidden','no');

  //window.close();
//  window.open('vlc.xul','xulex','chrome,resizable');
*/
}
