﻿//=============================================================================
var _ToolTip = null;
//=============================================================================
function ToolTip()
{
    //=========================================================================
    //Properties...
    //=========================================================================
    this.id               = "";
    this.position         = null;
    this.title            = "";
    this.message          = "";
    this.Container        = "toolTipContainer";
    //=========================================================================
    //Functions...
    //=========================================================================  
     this.draw = function()
     {
         try
         {         
              var strTip  = '<div class="bubble" id=' + this.id + ' style="z-index: 1000;left:' + this.getOffsetX()  + 'px; top:' + this.getOffsetY() + 'px;">';
              strTip     += '<div class="inner">';
              strTip     += '<div class="title">';             
              strTip     += '</div>';
              strTip     += '<div class="text">';
              strTip     += this.message;
              strTip     += '</div>';
              strTip     += '</div>';
              strTip     += '</div>';		
              return strTip;              
         }
         catch(e)
         {
              alert("***Error in ToolTip.draw**" + e.description);
         }
    }   
    //=========================================================================
    this.clear = function()
    {
         this.getContainer().innerHTML = "";
    }
    //=========================================================================     
    this.setVisible = function(setVisibleFlag)
    {
         this.getContainer().style.display = setVisibleFlag ? "" : "none";
    } 
    //=========================================================================     
    this.isVisible = function()
    {
          return (this.getContainer().style.display == "");
    } 
    //=========================================================================
    this.hide = function()
    {
          this.setVisible(false);
    }   
    //========================================================================= 
    this.show = function()
    {
          this.setVisible(true);
    }     
    //=========================================================================
    this.setPosition = function(objValue)
    {
         this.position = getElementPosition(objValue); 
    }              
    //=========================================================================
    this.getOffsetX = function()
    {
         var extra = (this.Container.indexOf('Popup') != -1) ? 32 : 10;
         return (this.position.x + this.position.width + extra);
    }      
    //=========================================================================
    this.getOffsetY = function()
    { 
         var extra = ((this.Container.indexOf('Popup') != -1)) ? 0 : 0;
         return (this.position.y - 4 + extra);
    }      
    //=========================================================================    
    this.getContainer = function()
    {
         return (this.Container.indexOf('Popup') != -1) ? window.top.document.getElementById(this.Container) : document.getElementById(this.Container);
    }      
    //=========================================================================
    this.setContainer = function(container)
    {
         this.Container = (container) ? container : "toolTipContainer";
    }       
    //=========================================================================           
}
//=============================================================================
function hideTooltip()
{
    try
    {
        _ToolTip.clear();
        _ToolTip.hide()
    }
    catch(e)
    {
    }
}
//=============================================================================
function isTooltipOpen()
{
    return (_ToolTip && _ToolTip.isVisible());
}
//=============================================================================
function tooltipCheckEsc(e)
{
    if (e && isEscClicked(e))
    {
        try
        {
            if (gTooltipsSupported && isTooltipOpen())
                hideTooltip();
        }
        catch(e){}
    }
}