﻿SideBar = function(SIPServer) {
  this.showLivelink(false);
  this.sipServer = SIPServer;  
};

SideBar.prototype = {
  isViewingLivestream: false,
  sipServer: '_',

  // event handler
  onSwitchToLivestreamEvent: function() { },

  // user clicked a link
  switchToLivestream: function() {
    this.isViewingLivestream = true;
    $('#liveLink').hide();
    $('#liveSnapshot img').remove();
    this.onSwitchToLivestreamEvent();
  },

  updateVideoCount: function(c) {
    //    $('#videoCount').text(c.toString());
  },

  showSIPstatus: function(isLive) {
  if (isLive) {
      $("#MessageTIP").hide();
      $('#imgLive').attr('title', 'Session Initiation Protocol (' + Username + '@' + this.sipServer + ') status: Active');
    } else {
      $("#MessageTIP").show();
      $('#imgLive').attr('title', 'Session Initiation Protocol (' + Username + '@' + this.sipServer + ') status: Inactive');
    }  
  },

  showLivelink: function(webcastID, seqNum) {
    this.showSIPstatus(webcastID);

    if (webcastID && !this.isViewingLivestream) {
      $('#liveLink').show();
      var html = '<img  height="54" width="71" src="/ajax/GetPreviewThumb.ashx?id={id}&seq={s}">'
          .replace(/{id}/, webcastID)
          .replace(/{s}/, seqNum);
      $('#liveSnapshot').html(html);
    }
    else {
      $('#liveLink').hide();
      $('#liveSnapshot img').remove();
    }
  }
};