
/*

AutoToolTip Core (ATT)
Copyright © 2002-2006 Voormedia.
All rights reserved.

WWW.VOORMEDIA.COM

DEPENDS ON:
  autotextreplacer.js
  tooltip.js
  autotooltip_definition.js

*/

function include(script_filename) {
    document.write('<' + 'script');
    document.write(' type="text/javascript"');
    document.write(' src="' + script_filename + '">');
    document.write('</' + 'script' + '>');
}

include('/javascripts/autotextreplacer.js');
include('/javascripts/tooltip.js');

function ATT(element)
{
    this.atr = false;
    this.baseElementId = 'page';
    this.element = 'a';
    this.elementClass = 'abbr';
    this.tooltipClass = 'def';
    this.tooltipWidth = 300;
    this.excludedElements = new Array('a');
    
    this.addDictionary = ATT_AddDictionary;
    this.setBaseElementId = ATT_SetBaseElementId;
    this.setElement = ATT_SetElement;
    this.setElementClass = ATT_SetElementClass;
    this.setTooltipClass = ATT_SetTooltipClass;
    this.setTooltipWidth = ATT_SetTooltipWidth;
    this.setExcludedElements = ATT_SetExcludedElements;
}

function ATT_AddDictionary(hash)
{
    if (!this.atr) {
        this.atr = new ATR(this.baseElementId);
    }
    for (index in this.excludedElements) {
        this.atr.excludeElement(this.excludedElements[index]);
    }
    // Iterate hash and add each item to the AutoTextReplacer. 
    for (key in hash) {
        hash[key] = escape(hash[key]);
        this.atr.add(key, // 'key' is the search term

                 // Inserted before each occurence of 'key'.
                 '<' + this.element + ' class="' + this.elementClass +
                 '" onMouseOver="showTip(\'' + hash[key] + '\',\'' + this.tooltipClass + '\',' + this.tooltipWidth + ');"' +
                 ' onMouseOut="hideTip();">',

                 // Inserted after each occurence of 'key'.
                 '</' + this.element + '>'); 
    }
}

function ATT_SetBaseElementId(id)
{
    this.baseElementId = id;
}

function ATT_SetElement(element)
{
    this.element = element;
}

function ATT_SetElementClass(elementClass)
{
    this.elementClass = elementClass;
}

function ATT_SetTooltipClass(tooltipClass)
{
    this.tooltipClass = tooltipClass;
}

function ATT_SetTooltipWidth(tooltipWidth)
{
    this.tooltipWidth = tooltipWidth;
}

function ATT_SetExcludedElements(excludedElements)
{
    this.excludedElements = excludedElements;
}

include('/javascripts/autotooltip_definition.js.php');

