
//----------------------------------------------------
var browser = {
  isIE: (document.all)? true:false,
  isIE8: (navigator.userAgent.indexOf('MSIE 8') != -1),
  isMoz: !(document.all),
  isCompatibleW3C: function() {
    return (this.isIE8 || this.isMoz)
  }
};
//++++++++++++++++++++++++++++++++++++++++++++++++++++
var PainelInformativo = (function() {
    //---------------------------------
    _APP_HRE_ = "/webelat/informativo/webpage/php/";
    _INFORMATIVO_PHP_ = _APP_HRE_ +"displayChamadaInformativo.php?chamada_id=";
    _DISPLAY_ALL_CHAMADAS_INFORMATIVO_PHP_ = _APP_HRE_ +"displayAllChamadasInformativo.php?_informativo_id=";
    //---------------------------------
    _informativoID = "#informativo";
    _linkChamada  = ".linkChamada";
    //---------------------------------
    function startProcess(initParam) {
        //-----------------------------
        this._idxChamada = 0;
        this._numInfo    = initParam._numInfo;
        this._chamadas   = initParam._chamadas;
        this._maxIndex   = (this._chamadas.length -1);
        //-----------------------------
        _self = this;
        _setInformativoEvents();
        //-----------------------------
    }
    //-------------------------------------------------------
    function _setInformativoEvents() {
        if (!browser.isCompatibleW3C()) {
            $j(_linkChamada).mouseenter( _self.start );
            $j(_linkChamada).mouseout( _self.stop );
        }
        else {
            $j(_informativoID).mouseout( _self.start );
            $j(_informativoID).mouseover( _self.stop );
            
        }
        _self.startApp();
        
        $j("#infoTituloLink").click(function(){ _self.displayAllChamadas(_self._numInfo); });
        
        $j(_linkChamada).each(function(){
          $j(this).click(function(){
            _self.mostrarChamada(this.id);
          });
        });
    }
    //-------------------------------------------------------
    function _changeChamada() {
      var _html = "";
      for (var i=0; i<=_self._maxIndex; i++) { 
        _html += '<a name="linkChamada" class="linkChamada" id="'+_self._chamadas[i]._id+'" href="javascript:void(0);">'+_self._chamadas[i]._texto+'</a>';
      }
      $j("#informativo").html(_html);
    }
    //-------------------------------------------------------
    startProcess.prototype = {
        //---------------------------------------------------
        mostrarChamada: function(_chamada_id) {
          var _url = _INFORMATIVO_PHP_ + _chamada_id;
          window.open( _url, "_blank", "resizable=no,location=no,titlebar=no,toolbar=no,width=674,height=570,top=5,left=5,scrollbars=1");
        },
        displayAllChamadas: function( _informativo_id) {
          var _url = _DISPLAY_ALL_CHAMADAS_INFORMATIVO_PHP_ + _informativo_id;
          window.open( _url, "_blank", "resizable=no,location=no,titlebar=no,toolbar=no,width=674,height=570,top=5,left=5,scrollbars=1");
        },
        //---------------------------------------------------
        startApp: function() {
          _changeChamada();
        },
        //---------------------------------------------------
        stop: function() {
          $j(_informativoID).trigger('stop');
        },
        //---------------------------------------------------
        start: function() {
          $j(_informativoID).trigger('start');
        }
    };
    return startProcess;
})();

