﻿/// <reference name="MicrosoftAjax.js"/>

Type.registerNamespace("DiscoverTec.Web.UI.WebControls");

DiscoverTec.Web.UI.WebControls.Tooltip = function(element)
{
  DiscoverTec.Web.UI.WebControls.Tooltip.initializeBase(this, [element]);
  this._tooltipHtml;
  this._tooltipClass;
  this._closeable;
  this._showOnClick;
  this._title;
  this._closeBtnUrl;
}

DiscoverTec.Web.UI.WebControls.Tooltip.prototype =
{
  initialize: function()
  {
    DiscoverTec.Web.UI.WebControls.Tooltip.callBaseMethod(this, 'initialize');
    var elem = this.get_element();
    if (this.get_showOnClick())
      $addHandlers(elem, { "click": this.showTooltip }, this);
    else
      $addHandlers(elem, { "mouseover": this.showTooltip }, this);
    if (!this.get_closeable())
      $addHandlers(elem, { "mouseout": this.mouseOut }, this);
  },

  get_tooltipHtml: function() { return this._tooltipHtml; },
  set_tooltipHtml: function(value) { this._tooltipHtml = value; },

  get_tooltipClass: function() { return this._tooltipClass; },
  set_tooltipClass: function(value) { this._tooltipClass = value; },

  get_closeable: function() { return this._closeable; },
  set_closeable: function(value) { this._closeable = value; },

  get_showOnClick: function() { return this._showOnClick; },
  set_showOnClick: function(value) { this._showOnClick = value; },

  get_title: function() { return this._title; },
  set_title: function(value) { this._title = value; },

  get_closeButtonUrl: function() { return this._closeBtnUrl; },
  set_closeButtonUrl: function(value) { this._closeBtnUrl = value; },

  showTooltip: function()
  {
    var css = this.get_tooltipClass();
    if (css.length == 0)
      css = 'dtec_tooltip_class';
    var closeable = this.get_closeable() ? 'true' : '';
    ajax_showTooltip(window.event, this.get_tooltipHtml(), this.get_element(), closeable, css, null, null, this.get_title(), this.get_closeButtonUrl());
    return true;
  },

  mouseOut: function()
  {
    ajax_hideTooltip();
  },

  dispose: function()
  {
    DiscoverTec.Web.UI.WebControls.Tooltip.callBaseMethod(this, 'dispose');
  }
}

DiscoverTec.Web.UI.WebControls.Tooltip.registerClass('DiscoverTec.Web.UI.WebControls.Tooltip', Sys.UI.Behavior);

if (typeof (Sys) !== 'undefined')
  Sys.Application.notifyScriptLoaded();