


var  player; 

function VLC_RunActivate(width,height,contentURL)
{
      try
      {
        
        player = VLCobject.embedPlayer('vlc1', width, height, true);        
        VLCobject.getInstance('vlc1').play(contentURL);
        player.stop();
       
      }
      catch(e)
      {
        
         No_VLC(e);
      }
//    var vol = 50;

//    var str="";
//    str += '<object classid="clsid:E23FE9C6-778E-49D4-B537-38FCDE4887D8" ';
//    str += ' codebase="http://downloads.videolan.org/pub/videolan/vlc/latest/win32/axvlc.cab" ';
//    str += ' width="' + width + '" ';
//    str += ' height="' + height + '" ';
//    str += ' id="vlc">';
//    str += '<param name="src" value="' + contentURL  + '" />';
//    str += '<param name="ShowDisplay" value="False" />';
//    str += '<param name="Menu" value="True" />';
//    str += '<param name="AutoLoop" value="True" />';
//    str += '<param name="loop" value="yes" />';
//    
//    str += '<param name="AutoPlay" value="False" />';
//    str += '<param name="AutoStart" value="True" />';
//    str += '<param name="Volume" value="' + vol + '" />';
//    str += '<param name="hidden" value="yes" />';    
//    str += '<embed id="vlc_embed"  version="VideoLAN.VLCPlugin.2" target="' + contentURL + '" width="' + width + '" height="' + height + '" type="application/x-vlc-plugin" autoplay="no" autostart="yes" loop="yes" AutoLoop="yes" hidden="no" " volume="' + vol + '" />';
//    str += '</object>';

//    document.write(str);
//    
//    if (contentURL)
//    {
//       window.onload = vlc_play;
//    }
}
function vlc_stop_play(id,img1, img2)
{

    var _vlc = get_VLC()
    if (!_vlc)
    {
        return 
    }
    var pl;
    
    if (_vlc.id=='vlc')
    {
        pl=_vlc.Playing
    }
    else if (_vlc.id=='vlc_embed')
    {
        pl=_vlc.isplaying()
    }
    if (pl==true)
    {
        vlc_stop(id,img2);
    }
    else if (pl==false)
    {
        vlc_play(id,img1);
    }
}

function vlc_play(id,img)
{
      player.play();
    var _vlc = get_VLC()
    if (!_vlc)
    {
        return 
    }
    //SetPlayPauseImage(id, img);
    try
    {
      _vlc.play();
    }
    catch(e)
    {
      No_VLC(e);
    }
    //ShowVLC('block');
}

function vlc_stop(id,img)
{
    //ShowVLC('none');
    var _vlc = get_VLC()
    if (!_vlc)
    {
        return 
    }
    //SetPlayPauseImage(id, img);
    try
    {
      _vlc.stop();
    }
    catch(e)
    {
      No_VLC(e);
    }
}

function vlc_togglemute()
{
    var _vlc = get_VLC()
    if (!_vlc)
    {
        return 
    }
    try
    {
      if (_vlc.id=='vlc')
      {
          _vlc.toggleMute();
      }
      else if (_vlc.id=='vlc_embed')
      {
          _vlc.mute();
      }
    }
    catch(e)
    {
      No_VLC(e);
    }
}

function vlc_fullscreen()
{
    var _vlc = get_VLC()
    if (!_vlc)
    {
        return 
    }
    try
    {
      _vlc.fullscreen();
    }
    catch(e)
    {
      No_VLC(e);
    }
}

function vlc_setVolume(vol)
{
    var _vlc = get_VLC()
    if (!_vlc)
    {
        return 
    }
    try
    {
      if (_vlc.id=='vlc')
      {
          _vlc.volume = vol;
      }
      else if (_vlc.id=='vlc_embed')
      {
          _vlc.set_volume(vol);
      }
    }
    catch(e)
    {
      No_VLC(e);
    }
}

function vlc_getVolume()
{
    var _vlc = get_VLC()
    if (!_vlc)
    {
        return 
    }
    try
    {
      if (_vlc.id=='vlc')
      {
          return _vlc.volume;
      }
      else if (_vlc.id=='vlc_embed')
      {
          return _vlc.get_volume();
      }
    }
    catch(e)
    {
      No_VLC(e);
    }
    return 0;
}

function get_VLC()
{
    var o;
    var topFrame = window.top.VideoFrame;
    var topDoc;
    if (!topFrame)
    {
      return o;
    }
    topDoc = topFrame.document;
    if(!topDoc)
    {
      return o;
    }
    if(window.opera)
    {
        o = topDoc.getElementById("vlc_embed");
    }
    else
    {
      o = topDoc.getElementById("vlc");
      var pl;
      try
      {
        pl  = o.Playing;
      }
      catch(e){}
      if (pl!=true && pl !=false)
      {
          o = topDoc.getElementById("vlc_embed");
      }
    }
    return o;
}
function ShowVLC(param)
{
    //return;
    //setVisible('VLC_DIV',param)
    setVisible('VLC_BG_DIV',param == 'block' ? 'none':'block')
    
    function setVisible(ElementID,displayValue)
    {
        var element=document.getElementById(ElementID)
        if (element)
        {
            element.style.display = displayValue;
        }
    }
}
/*------------------------------------*/
function No_VLC(e)
{
     var el = document.getElementById('vlc1');
    el.style.display = 'none';
    
    var el = document.getElementById('MessageNoVlc');
    el.style.display = 'block';
//  var videoF = window.top.VideoFrame;
//  if(videoF)
//  {
//    videoF.location = "NoVLC.htm";
//  }
}
function No_SkynetUser(e)
{
    var el = document.getElementById('vlc1');
    el.style.display = 'none';
    
    var el = document.getElementById('MessageNoSkynet');
    el.style.display = 'block';   
//  var videoF = window.top.VideoFrame;
//  if(videoF)
//  {
//    videoF.location = "NoSkynet.htm";
//  }
}
