/*
Change log
10.9.2005 - Ami
- upravena metoda view, protoze IE nezna vlastnost overflow (alespon me to neustale hazelo chyby), cili ted se ta cast provadi, pouze v pripade, ze mame mozillu
- TODO - chtelo by to asi jeste doresit
*/
/***************************************
      Infobar by Eskel - 2005
      
      Mode 1 : Plující za kurzorem
      Mode 2 : Držící na místě
      Mode 3 : Pro dlouhé seznamy
***************************************/

function infoBar(element){
  var content;
  var visible;
  var x;
  var y;
  var mod;
  var width;
  var winWidth;
  var winHeight;
  this.overPanel = 0;
  this.timeBreak = 0;
  this.offX      = 20;
  this.offY      = 10;
  this.time      = 500;
  this.id        = element;
  this.pointer   = document.getElementById(this.id);
  this.view      = view;
  this.hide      = hide;
  this.move      = move;
  this.setBreak  = setBreak;
  this.drawBar   = drawBar;

  function view(text, e, mode, width){
    if(panel){
      if(this.timeBreak){
        clearInterval(this.timeBreak);
        this.hide(1);
      }
      this.mode = mode;
      this.width = width;
      this.content = text;
      this.visible = 1;
      this.pointer.innerHTML = this.content;
      this.pointer.style.display = "block";
      this.pointer.style.width = this.width;
      this.winWidth  = window.innerWidth  || document.body.offsetWidth - 20;
      if(this.timeBreak == 0){
        this.x = e.pageX || e.clientX + document.body.scrollLeft;
        this.y = e.pageY || e.clientY + document.body.scrollTop;
        this.drawBar();
      }
      if(this.mode == 3){
        this.pointer.style.height = "400";
        if(ns6noopera || ns6)
          this.pointer.style.overflow = "auto";
      }
      else{
        this.pointer.style.height = "auto";       
        if(ns6noopera || ns6)
          this.pointer.style.overflow = "none";
      }
    }
    return true;
  }
  function drawBar(){
    if(this.x + this.width >= this.winWidth - 50){
      this.pointer.style.left = this.winWidth - this.width - 30;
    }
    else{
      this.pointer.style.left = this.x + this.offX;
    }
    this.pointer.style.top  = this.y + this.offY;
  }
  function setBreak(){
    if(this.timeBreak == 0){
      this.timeBreak = setInterval("panel.hide(1)", this.time);
    }
  }
  function hide(unusual){
    if(panel){
      if(this.mode == 2 || this.mode == 3){
        if(unusual == 1 && this.overPanel == 0){
          clearInterval(this.timeBreak);
          this.timeBreak = 0;
          this.content = 0;
          this.visible = 0;
          this.pointer.style.display = "none";
          this.pointer.innerHTML = "";
        }
        else{
          this.setBreak();
        }
      }
      else{
        this.content = 0;
        this.visible = 0;
        this.pointer.style.display = "none";
        this.pointer.innerHTML = "";
      }
    }
    return true;
  }
  function move(e){
    if(panel){
      this.x = e.pageX || e.clientX + document.body.scrollLeft;
      this.y = e.pageY || e.clientY + document.body.scrollTop;
      this.drawBar();
    }
    return true;
  }
}
