//
//  JS for Flash FLV player
//
//  Clio Soleil (clio@PrettyGetter.TV)
//  PrettyGetter Productions (http://PrettyGetter.TV) 
//  

///////////////////////////////////////////////
// these functions are called from the flash FLV player 
///////////////////////////////////////////////

var FLV_ready = false;
var FLV_queue = new Array();

//--------------------------------------------------------------------------------------------------------------------------------------------
function FLV_flashReady(objName)
// called by FLVPlayer swf when fully loaded and initialized
// this is the first point we can interact with the flash movie
//--------------------------------------------------------------------------------------------------------------------------------------------
{
  //window.alert("JS:"+objName+":"+FLV_queue.length);
  FLV_ready = true;
  for (var i = 0; i < FLV_queue.length; i++)
    FLV_play(FLV_queue[i][0], FLV_queue[i][1]);
  FLV_queue = new Array();
}

//--------------------------------------------------------------------------------------------------------------------------------------------
// callback for when used in a Window
function FLV_closeWindow()
//--------------------------------------------------------------------------------------------------------------------------------------------
{
  FLV_ready = false;
  FLV_queue = new Array();
  return true;
}

///////////////////////////////////////////
// these functions are called from HTML
///////////////////////////////////////////

//--------------------------------------------------------------------------------------------------------------------------------------------
//function FLV_play(url, title, artist, autoplay) 
function FLV_play(url, autoplay) 
//--------------------------------------------------------------------------------------------------------------------------------------------
{
  //window.alert('Calling flash:FLV_play(' + url + ')');
  if (url == undefined) return;
  autoplay = (autoplay == true) ? true : false;
  //if (title == undefined) title = "";
  //if (artist == undefined) artist = "";
  if (document.getElementById("FLVPlayer") && FLV_ready)
  {
    //window.alert("adding "+url+":"+autoplay);
    getFlashComponent("FLVPlayer").setAutoPlay(autoplay);
    getFlashComponent("FLVPlayer").setVideo(url);
    if (autoplay)
      getFlashComponent("FLVPlayer").playVideo(); 
  }
  else
  {
    //window.alert("queueing "+url);
    FLV_queue.push(new Array(url, autoplay));
  }
}

//--------------------------------------------------------------------------------------------------------------------------------------------
//function FLV_play(url, title, artist, autoplay) 
function FLV_playWin(name, url, autoplay) 
//--------------------------------------------------------------------------------------------------------------------------------------------
{
  if (name == undefined) name = "FLVWindow";
  if (autoplay == undefined) autoplay = true;
  var win = window[name];
    
  FLV_play(url, autoplay); 
  if ((typeof(win) == "undefined") || (win.isClosed))
    if (typeof(win) != "undefined") 
    { 
      win.show(); 
      if (typeof(win) != "undefined") 
        win.load("div", name+"Div", "Muse TV");
    } 
    else win = dhtmlwindow.open(name, 
                                "div",
                                name+"Div", 
                                "Muse TV", 
                                "width=640px,height=480px,center=1,resize=1,scrolling=1", 
                                "recal");
  win.onclose=FLV_closeWindow
}

//--------------------------------------------------------------------------------------------------------------------------------------------
function __flash__removeCallback(instance, name) 
// this hack function is needed since Flash Player 10... their code doesn't check for null... thanks, guys! 
//--------------------------------------------------------------------------------------------------------------------------------------------
{
  if (instance) 
    instance[name] = null;
}