Subversion Repositories wimsdev

Rev

Rev 51 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. /* This notice must be untouched at all times.
  2.  
  3. wz_tooltip.js    v. 4.12
  4.  
  5. The latest version is available at
  6. http://www.walterzorn.com
  7. or http://www.devira.com
  8. or http://www.walterzorn.de
  9.  
  10. Copyright (c) 2002-2007 Walter Zorn. All rights reserved.
  11. Created 1.12.2002 by Walter Zorn (Web: http://www.walterzorn.com )
  12. Last modified: 13.7.2007
  13.  
  14. Easy-to-use cross-browser tooltips.
  15. Just include the script at the beginning of the <body> section, and invoke
  16. Tip('Tooltip text') from within the desired HTML onmouseover eventhandlers.
  17. No container DIV, no onmouseouts required.
  18. By default, width of tooltips is automatically adapted to content.
  19. Is even capable of dynamically converting arbitrary HTML elements to tooltips
  20. by calling TagToTip('ID_of_HTML_element_to_be_converted') instead of Tip(),
  21. which means you can put important, search-engine-relevant stuff into tooltips.
  22. Appearance of tooltips can be individually configured
  23. via commands passed to Tip() or TagToTip().
  24.  
  25. Tab Width: 4
  26. LICENSE: LGPL
  27.  
  28. This library is free software; you can redistribute it and/or
  29. modify it under the terms of the GNU Lesser General Public
  30. License (LGPL) as published by the Free Software Foundation; either
  31. version 2.1 of the License, or (at your option) any later version.
  32.  
  33. This library is distributed in the hope that it will be useful,
  34. but WITHOUT ANY WARRANTY; without even the implied warranty of
  35. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  36.  
  37. For more details on the GNU Lesser General Public License,
  38. see http://www.gnu.org/copyleft/lesser.html
  39. */
  40.  
  41. var config = new Object();
  42.  
  43.  
  44.  
  45. //===================  GLOBAL TOOPTIP CONFIGURATION  =========================//
  46. var  tt_Debug   = true          // false or true - recommended: false once you release your page to the public
  47. var  tt_Enabled = true          // Allows to (temporarily) suppress tooltips, e.g. by providing the user with a button that sets this global variable to false
  48. var  TagsToTip  = true          // false or true - if true, the script is capable of converting HTML elements to tooltips
  49.  
  50. // For each of the following config variables there exists a command, which is
  51. // just the variablename in uppercase, to be passed to Tip() or TagToTip() to
  52. // configure tooltips individually. Individual commands override global
  53. // configuration. Order of commands is arbitrary.
  54. // Example: onmouseover="Tip('Tooltip text', LEFT, true, BGCOLOR, '#FF9900', FADEIN, 400)"
  55.  
  56. config. Above                   = false         // false or true - tooltip above mousepointer?
  57. config. BgColor                 = '#E4E7FF' // Background color
  58. config. BgImg                   = ''            // Path to background image, none if empty string ''
  59. config. BorderColor     = '#002299'
  60. config. BorderStyle     = 'solid'       // Any permitted CSS value, but I recommend 'solid', 'dotted' or 'dashed'
  61. config. BorderWidth     = 1
  62. config. CenterMouse     = false         // false or true - center the tip horizontally below (or above) the mousepointer
  63. config. ClickClose              = false         // false or true - close tooltip if the user clicks somewhere
  64. config. CloseBtn                = false         // false or true - closebutton in titlebar
  65. config. CloseBtnColors  = ['#990000', '#FFFFFF', '#DD3333', '#FFFFFF']    // [Background, text, hovered background, hovered text] - use empty strings '' to inherit title colors
  66. config. CloseBtnText    = '&nbsp;X&nbsp;'       // Close button text (may also be an image tag)
  67. config. CopyContent             = true          // When converting a HTML element to a tooltip, copy only the element's content, rather than converting the element by its own
  68. config. Delay                   = 400           // Time span in ms until tooltip shows up
  69. config. Duration                = 0             // Time span in ms after which the tooltip disappears; 0 for infinite duration
  70. config. FadeIn                  = 0             // Fade-in duration in ms, e.g. 400; 0 for no animation
  71. config. FadeOut                 = 0
  72. config. FadeInterval    = 30            // Duration of each fade step in ms (recommended: 30) - shorter is smoother but causes more CPU-load
  73. config. Fix                     = null          // Fixated position - x- an y-oordinates in brackets, e.g. [210, 480], or null for no fixation
  74. config. FollowMouse             = true          // false or true - tooltip follows the mouse
  75. config. FontColor               = '#000044'
  76. config. FontFace                = 'Verdana,Geneva,sans-serif'
  77. config. FontSize                = '8pt'         // E.g. '9pt' or '12px' - unit is mandatory
  78. config. FontWeight              = 'normal'      // 'normal' or 'bold';
  79. config. Left                    = false         // false or true - tooltip on the left of the mouse
  80. config. OffsetX                 = 14            // Horizontal offset of left-top corner from mousepointer
  81. config. OffsetY                 = 8             // Vertical offset
  82. config. Opacity                 = 100           // Integer between 0 and 100 - opacity of tooltip in percent
  83. config. Padding                 = 3             // Spacing between border and content
  84. config. Shadow                  = false         // false or true
  85. config. ShadowColor     = '#C0C0C0'
  86. config. ShadowWidth     = 5
  87. config. Sticky                  = false         // Do NOT hide tooltip on mouseout? false or true
  88. config. TextAlign               = 'left'        // 'left', 'right' or 'justify'
  89. config. Title                   = ''            // Default title text applied to all tips (no default title: empty string '')
  90. config. TitleAlign              = 'left'        // 'left' or 'right' - text alignment inside the title bar
  91. config. TitleBgColor    = ''            // If empty string '', BorderColor will be used
  92. config. TitleFontColor  = '#ffffff'     // Color of title text - if '', BgColor (of tooltip body) will be used
  93. config. TitleFontFace   = ''            // If '' use FontFace (boldified)
  94. config. TitleFontSize   = ''            // If '' use FontSize
  95. config. Width                   = 0             // Tooltip width; 0 for automatic adaption to tooltip content
  96. //=======  END OF TOOLTIP CONFIG, DO NOT CHANGE ANYTHING BELOW  ==============//
  97.  
  98.  
  99.  
  100.  
  101. //======================  PUBLIC  ============================================//
  102. function Tip()
  103. {
  104.         tt_Tip(arguments, null);
  105. }
  106. function TagToTip()
  107. {
  108.         if(TagsToTip)
  109.         {
  110.                 var t2t = tt_GetElt(arguments[0]);
  111.                 if(t2t)
  112.                         tt_Tip(arguments, t2t);
  113.         }
  114. }
  115.  
  116. //==================  PUBLIC EXTENSION API      ==================================//
  117. // Extension eventhandlers currently supported:
  118. // OnLoadConfig, OnCreateContentString, OnSubDivsCreated, OnShow, OnMoveBefore,
  119. // OnMoveAfter, OnHideInit, OnHide, OnKill
  120.  
  121. var tt_aElt = new Array(10), // Container DIV, outer title & body DIVs, inner title & body TDs, closebutton SPAN, shadow DIVs, and IFRAME to cover windowed elements in IE
  122. tt_aV = new Array(),    // Caches and enumerates config data for currently active tooltip
  123. tt_sContent,                    // Inner tooltip text or HTML
  124. tt_scrlX = 0, tt_scrlY = 0,
  125. tt_musX, tt_musY,
  126. tt_over,
  127. tt_x, tt_y, tt_w, tt_h; // Position, width and height of currently displayed tooltip
  128.  
  129. function tt_Extension()
  130. {
  131.         tt_ExtCmdEnum();
  132.         tt_aExt[tt_aExt.length] = this;
  133.         return this;
  134. }
  135. function tt_SetTipPos(x, y)
  136. {
  137.         var css = tt_aElt[0].style;
  138.  
  139.         tt_x = x;
  140.         tt_y = y;
  141.         css.left = x + "px";
  142.         css.top = y + "px";
  143.         if(tt_ie56)
  144.         {
  145.                 var ifrm = tt_aElt[tt_aElt.length - 1];
  146.                 if(ifrm)
  147.                 {
  148.                         ifrm.style.left = css.left;
  149.                         ifrm.style.top = css.top;
  150.                 }
  151.         }
  152. }
  153. function tt_Hide()
  154. {
  155.         if(tt_db && tt_iState)
  156.         {
  157.                 if(tt_iState & 0x2)
  158.                 {
  159.                         tt_aElt[0].style.visibility = "hidden";
  160.                         tt_ExtCallFncs(0, "Hide");
  161.                 }
  162.                 tt_tShow.EndTimer();
  163.                 tt_tHide.EndTimer();
  164.                 tt_tDurt.EndTimer();
  165.                 tt_tFade.EndTimer();
  166.                 if(!tt_op && !tt_ie)
  167.                 {
  168.                         tt_tWaitMov.EndTimer();
  169.                         tt_bWait = false;
  170.                 }
  171.                 if(tt_aV[CLICKCLOSE])
  172.                         tt_RemEvtFnc(document, "mouseup", tt_HideInit);
  173.                 tt_AddRemOutFnc(false);
  174.                 tt_ExtCallFncs(0, "Kill");
  175.                 // In case of a TagToTip tooltip, hide converted DOM node and
  176.                 // re-insert it into document
  177.                 if(tt_t2t && !tt_aV[COPYCONTENT])
  178.                 {
  179.                         tt_t2t.style.display = "none";
  180.                         tt_MovDomNode(tt_t2t, tt_aElt[6], tt_t2tDad);
  181.                 }
  182.                 tt_iState = 0;
  183.                 tt_over = null;
  184.                 tt_ResetMainDiv();
  185.                 if(tt_aElt[tt_aElt.length - 1])
  186.                         tt_aElt[tt_aElt.length - 1].style.display = "none";
  187.         }
  188. }
  189. function tt_GetElt(id)
  190. {
  191.         return(document.getElementById ? document.getElementById(id)
  192.                         : document.all ? document.all[id]
  193.                         : null);
  194. }
  195. function tt_GetDivW(el)
  196. {
  197.         return(el ? (el.offsetWidth || el.style.pixelWidth || 0) : 0);
  198. }
  199. function tt_GetDivH(el)
  200. {
  201.         return(el ? (el.offsetHeight || el.style.pixelHeight || 0) : 0);
  202. }
  203. function tt_GetScrollX()
  204. {
  205.         return(window.pageXOffset || (tt_db ? (tt_db.scrollLeft || 0) : 0));
  206. }
  207. function tt_GetScrollY()
  208. {
  209.         return(window.pageYOffset || (tt_db ? (tt_db.scrollTop || 0) : 0));
  210. }
  211. function tt_GetClientW()
  212. {
  213.         return(document.body && (typeof(document.body.clientWidth) != tt_u) ? document.body.clientWidth
  214.                         : (typeof(window.innerWidth) != tt_u) ? window.innerWidth
  215.                         : tt_db ? (tt_db.clientWidth || 0)
  216.                         : 0);
  217. }
  218. function tt_GetClientH()
  219. {
  220.         // Exactly this order seems to yield correct values in all major browsers
  221.         return(document.body && (typeof(document.body.clientHeight) != tt_u) ? document.body.clientHeight
  222.                         : (typeof(window.innerHeight) != tt_u) ? window.innerHeight
  223.                         : tt_db ? (tt_db.clientHeight || 0)
  224.                         : 0);
  225. }
  226. function tt_GetEvtX(e)
  227. {
  228.         return (e ? ((typeof(e.pageX) != tt_u) ? e.pageX : (e.clientX + tt_scrlX)) : 0);
  229. }
  230. function tt_GetEvtY(e)
  231. {
  232.         return (e ? ((typeof(e.pageY) != tt_u) ? e.pageY : (e.clientY + tt_scrlY)) : 0);
  233. }
  234. function tt_AddEvtFnc(el, sEvt, PFnc)
  235. {
  236.         if(el)
  237.         {
  238.                 if(el.addEventListener)
  239.                         el.addEventListener(sEvt, PFnc, false);
  240.                 else
  241.                         el.attachEvent("on" + sEvt, PFnc);
  242.         }
  243. }
  244. function tt_RemEvtFnc(el, sEvt, PFnc)
  245. {
  246.         if(el)
  247.         {
  248.                 if(el.removeEventListener)
  249.                         el.removeEventListener(sEvt, PFnc, false);
  250.                 else
  251.                         el.detachEvent("on" + sEvt, PFnc);
  252.         }
  253. }
  254.  
  255. //======================  PRIVATE  ===========================================//
  256. var tt_aExt = new Array(),      // Array of extension objects
  257.  
  258. tt_db, tt_op, tt_ie, tt_ie56, tt_bBoxOld,       // Browser flags
  259. tt_body,
  260. tt_flagOpa,                     // Opacity support: 1=IE, 2=Khtml, 3=KHTML, 4=Moz, 5=W3C
  261. tt_maxPosX, tt_maxPosY,
  262. tt_iState = 0,                  // Tooltip active |= 1, shown |= 2, move with mouse |= 4
  263. tt_opa,                                 // Currently applied opacity
  264. tt_bJmpVert,                    // Tip above mouse (or ABOVE tip below mouse)
  265. tt_t2t, tt_t2tDad,              // Tag converted to tip, and its parent element in the document
  266. tt_elDeHref,                    // The tag from which Opera has removed the href attribute
  267. // Timer
  268. tt_tShow = new Number(0), tt_tHide = new Number(0), tt_tDurt = new Number(0),
  269. tt_tFade = new Number(0), tt_tWaitMov = new Number(0),
  270. tt_bWait = false,
  271. tt_u = "undefined";
  272.  
  273.  
  274. function tt_Init()
  275. {
  276.         tt_MkCmdEnum();
  277.         // Send old browsers instantly to hell
  278.         if(!tt_Browser() || !tt_MkMainDiv())
  279.                 return;
  280.         tt_IsW3cBox();
  281.         tt_OpaSupport();
  282.         tt_AddEvtFnc(document, "mousemove", tt_Move);
  283.         // In Debug mode we search for TagToTip() calls in order to notify
  284.         // the user if they've forgotten to set the TagsToTip config flag
  285.         if(TagsToTip || tt_Debug)
  286.                 tt_SetOnloadFnc();
  287.         tt_AddEvtFnc(window, "scroll",
  288.                 function()
  289.                 {
  290.                         tt_scrlX = tt_GetScrollX();
  291.                         tt_scrlY = tt_GetScrollY();
  292.                         if(tt_iState && !(tt_aV[STICKY] && (tt_iState & 2)))
  293.                                 tt_HideInit();
  294.                 } );
  295.         // Ensure the tip be hidden when the page unloads
  296.         tt_AddEvtFnc(window, "unload", tt_Hide);
  297.         tt_Hide();
  298. }
  299. // Creates command names by translating config variable names to upper case
  300. function tt_MkCmdEnum()
  301. {
  302.         var n = 0;
  303.         for(var i in config)
  304.                 eval("window." + i.toString().toUpperCase() + " = " + n++);
  305.         tt_aV.length = n;
  306. }
  307. function tt_Browser()
  308. {
  309.         var n, nv, n6, w3c;
  310.  
  311.         n = navigator.userAgent.toLowerCase(),
  312.         nv = navigator.appVersion;
  313.         tt_op = (document.defaultView && typeof(eval("w" + "indow" + "." + "o" + "p" + "er" + "a")) != tt_u);
  314.         tt_ie = n.indexOf("msie") != -1 && document.all && !tt_op;
  315.         if(tt_ie)
  316.         {
  317.                 var ieOld = (!document.compatMode || document.compatMode == "BackCompat");
  318.                 tt_db = !ieOld ? document.documentElement : (document.body || null);
  319.                 if(tt_db)
  320.                         tt_ie56 = parseFloat(nv.substring(nv.indexOf("MSIE") + 5)) >= 5.5
  321.                                         && typeof document.body.style.maxHeight == tt_u;
  322.         }
  323.         else
  324.         {
  325.                 tt_db = document.documentElement || document.body ||
  326.                                 (document.getElementsByTagName ? document.getElementsByTagName("body")[0]
  327.                                 : null);
  328.                 if(!tt_op)
  329.                 {
  330.                         n6 = document.defaultView && typeof document.defaultView.getComputedStyle != tt_u;
  331.                         w3c = !n6 && document.getElementById;
  332.                 }
  333.         }
  334.         tt_body = (document.getElementsByTagName ? document.getElementsByTagName("body")[0]
  335.                                 : (document.body || null));
  336.         if(tt_ie || n6 || tt_op || w3c)
  337.         {
  338.                 if(tt_body && tt_db)
  339.                 {
  340.                         if(document.attachEvent || document.addEventListener)
  341.                                 return true;
  342.                 }
  343.                 else
  344.                         tt_Err("wz_tooltip.js must be included INSIDE the body section,"
  345.                                         + " immediately after the opening <body> tag.");
  346.         }
  347.         tt_db = null;
  348.         return false;
  349. }
  350. function tt_MkMainDiv()
  351. {
  352.         // Create the tooltip DIV
  353.         if(tt_body.insertAdjacentHTML)
  354.                 tt_body.insertAdjacentHTML("afterBegin", tt_MkMainDivHtm());
  355.         else if(typeof tt_body.innerHTML != tt_u && document.createElement && tt_body.appendChild)
  356.                 tt_body.appendChild(tt_MkMainDivDom());
  357.         // FireFox Alzheimer bug
  358.         if(window.tt_GetMainDivRefs && tt_GetMainDivRefs())
  359.                 return true;
  360.         tt_db = null;
  361.         return false;
  362. }
  363. function tt_MkMainDivHtm()
  364. {
  365.         return('<div id="WzTtDiV"></div>' +
  366.                         (tt_ie56 ? ('<iframe id="WzTtIfRm" src="javascript:false" scrolling="no" frameborder="0" style="filter:Alpha(opacity=0);position:absolute;top:0px;left:0px;display:none;"></iframe>')
  367.                         : ''));
  368. }
  369. function tt_MkMainDivDom()
  370. {
  371.         var el = document.createElement("div");
  372.         if(el)
  373.                 el.id = "WzTtDiV";
  374.         return el;
  375. }
  376. function tt_GetMainDivRefs()
  377. {
  378.         tt_aElt[0] = tt_GetElt("WzTtDiV");
  379.         if(tt_ie56 && tt_aElt[0])
  380.         {
  381.                 tt_aElt[tt_aElt.length - 1] = tt_GetElt("WzTtIfRm");
  382.                 if(!tt_aElt[tt_aElt.length - 1])
  383.                         tt_aElt[0] = null;
  384.         }
  385.         if(tt_aElt[0])
  386.         {
  387.                 var css = tt_aElt[0].style;
  388.  
  389.                 css.visibility = "hidden";
  390.                 css.position = "absolute";
  391.                 css.overflow = "hidden";
  392.                 return true;
  393.         }
  394.         return false;
  395. }
  396. function tt_ResetMainDiv()
  397. {
  398.         var w = (window.screen && screen.width) ? screen.width : 10000;
  399.  
  400.         tt_SetTipPos(-w, 0);
  401.         tt_aElt[0].innerHTML = "";
  402.         tt_aElt[0].style.width = (w - 1) + "px";
  403. }
  404. function tt_IsW3cBox()
  405. {
  406.         var css = tt_aElt[0].style;
  407.  
  408.         css.padding = "10px";
  409.         css.width = "40px";
  410.         tt_bBoxOld = (tt_GetDivW(tt_aElt[0]) == 40);
  411.         css.padding = "0px";
  412.         tt_ResetMainDiv();
  413. }
  414. function tt_OpaSupport()
  415. {
  416.         var css = tt_body.style;
  417.  
  418.         tt_flagOpa = (typeof(css.filter) != tt_u) ? 1
  419.                                 : (typeof(css.KhtmlOpacity) != tt_u) ? 2
  420.                                 : (typeof(css.KHTMLOpacity) != tt_u) ? 3
  421.                                 : (typeof(css.MozOpacity) != tt_u) ? 4
  422.                                 : (typeof(css.opacity) != tt_u) ? 5
  423.                                 : 0;
  424. }
  425. // Ported from http://dean.edwards.name/weblog/2006/06/again/
  426. // (Dean Edwards et al.)
  427. function tt_SetOnloadFnc()
  428. {
  429.         tt_AddEvtFnc(document, "DOMContentLoaded", tt_HideSrcTags);
  430.         tt_AddEvtFnc(window, "load", tt_HideSrcTags);
  431.         if(tt_body.attachEvent)
  432.                 tt_body.attachEvent("onreadystatechange",
  433.                         function() {
  434.                                 if(tt_body.readyState == "complete")
  435.                                         tt_HideSrcTags();
  436.                         } );
  437.         if(/WebKit|KHTML/i.test(navigator.userAgent))
  438.         {
  439.                 var t = setInterval(function() {
  440.                                         if(/loaded|complete/.test(document.readyState))
  441.                                         {
  442.                                                 clearInterval(t);
  443.                                                 tt_HideSrcTags();
  444.                                         }
  445.                                 }, 10);
  446.         }
  447. }
  448. function tt_HideSrcTags()
  449. {
  450.         if(!window.tt_HideSrcTags || window.tt_HideSrcTags.done)
  451.                 return;
  452.         window.tt_HideSrcTags.done = true;
  453.         if(!tt_HideSrcTagsRecurs(tt_body))
  454.                 tt_Err("To enable the capability to convert HTML elements to tooltips,"
  455.                                 + " you must set TagsToTip in the global tooltip configuration"
  456.                                 + " to true.");
  457. }
  458. function tt_HideSrcTagsRecurs(dad)
  459. {
  460.         var a, ovr, asT2t;
  461.  
  462.         // Walk the DOM tree for tags that have an onmouseover attribute
  463.         // containing a TagToTip('...') call.
  464.         // (.childNodes first since .children is bugous in Safari)
  465.         a = dad.childNodes || dad.children || null;
  466.         for(var i = a ? a.length : 0; i;)
  467.         {--i;
  468.                 if(!tt_HideSrcTagsRecurs(a[i]))
  469.                         return false;
  470.                 ovr = a[i].getAttribute ? a[i].getAttribute("onmouseover")
  471.                                 : (typeof a[i].onmouseover == "function") ? a[i].onmouseover
  472.                                 : null;
  473.                 if(ovr)
  474.                 {
  475.                         asT2t = ovr.toString().match(/TagToTip\s*\(\s*'[^'.]+'\s*[\),]/);
  476.                         if(asT2t && asT2t.length)
  477.                         {
  478.                                 if(!tt_HideSrcTag(asT2t[0]))
  479.                                         return false;
  480.                         }
  481.                 }
  482.         }
  483.         return true;
  484. }
  485. function tt_HideSrcTag(sT2t)
  486. {
  487.         var id, el;
  488.  
  489.         // The ID passed to the found TagToTip() call identifies an HTML element
  490.         // to be converted to a tooltip, so hide that element
  491.         id = sT2t.replace(/.+'([^'.]+)'.+/, "$1");
  492.         el = tt_GetElt(id);
  493.         if(el)
  494.         {
  495.                 if(tt_Debug && !TagsToTip)
  496.                         return false;
  497.                 else
  498.                         el.style.display = "none";
  499.         }
  500.         else
  501.                 tt_Err("Invalid ID\n'" + id + "'\npassed to TagToTip()."
  502.                                 + " There exists no HTML element with that ID.");
  503.         return true;
  504. }
  505. function tt_Tip(arg, t2t)
  506. {
  507.         if(!tt_db)
  508.                 return;
  509.         if(tt_iState)
  510.                 tt_Hide();
  511.         if(!tt_Enabled)
  512.                 return;
  513.         tt_t2t = t2t;
  514.         if(!tt_ReadCmds(arg))
  515.                 return;
  516.         tt_iState = 0x1 | 0x4;
  517.         tt_AdaptConfig1();
  518.         tt_MkTipContent(arg);
  519.         tt_MkTipSubDivs();
  520.         tt_FormatTip();
  521.         tt_bJmpVert = false;
  522.         tt_maxPosX = tt_GetClientW() + tt_scrlX - tt_w - 1;
  523.         tt_maxPosY = tt_GetClientH() + tt_scrlY - tt_h - 1;
  524.         tt_AdaptConfig2();
  525.         // We must fake the first mousemove in order to ensure the tip
  526.         // be immediately shown and positioned
  527.         tt_Move();
  528.         tt_ShowInit();
  529. }
  530. function tt_ReadCmds(a)
  531. {
  532.         var i;
  533.  
  534.         // First load the global config values, to initialize also values
  535.         // for which no command has been passed
  536.         i = 0;
  537.         for(var j in config)
  538.                 tt_aV[i++] = config[j];
  539.         // Then replace each cached config value for which a command has been
  540.         // passed (ensure the # of command args plus value args be even)
  541.         if(a.length & 1)
  542.         {
  543.                 for(i = a.length - 1; i > 0; i -= 2)
  544.                         tt_aV[a[i - 1]] = a[i];
  545.                 return true;
  546.         }
  547.         tt_Err("Incorrect call of Tip() or TagToTip().\n"
  548.                         + "Each command must be followed by a value.");
  549.         return false;
  550. }
  551. function tt_AdaptConfig1()
  552. {
  553.         tt_ExtCallFncs(0, "LoadConfig");
  554.         // Inherit unspecified title formattings from body
  555.         if(!tt_aV[TITLEBGCOLOR].length)
  556.                 tt_aV[TITLEBGCOLOR] = tt_aV[BORDERCOLOR];
  557.         if(!tt_aV[TITLEFONTCOLOR].length)
  558.                 tt_aV[TITLEFONTCOLOR] = tt_aV[BGCOLOR];
  559.         if(!tt_aV[TITLEFONTFACE].length)
  560.                 tt_aV[TITLEFONTFACE] = tt_aV[FONTFACE];
  561.         if(!tt_aV[TITLEFONTSIZE].length)
  562.                 tt_aV[TITLEFONTSIZE] = tt_aV[FONTSIZE];
  563.         if(tt_aV[CLOSEBTN])
  564.         {
  565.                 // Use title colors for non-specified closebutton colors
  566.                 if(!tt_aV[CLOSEBTNCOLORS])
  567.                         tt_aV[CLOSEBTNCOLORS] = new Array("", "", "", "");
  568.                 for(var i = 4; i;)
  569.                 {--i;
  570.                         if(!tt_aV[CLOSEBTNCOLORS][i].length)
  571.                                 tt_aV[CLOSEBTNCOLORS][i] = (i & 1) ? tt_aV[TITLEFONTCOLOR] : tt_aV[TITLEBGCOLOR];
  572.                 }
  573.                 // Enforce titlebar be shown
  574.                 if(!tt_aV[TITLE].length)
  575.                         tt_aV[TITLE] = " ";
  576.         }
  577.         // Circumvents broken display of images and fade-in flicker in Geckos < 1.8
  578.         if(tt_aV[OPACITY] == 100 && typeof tt_aElt[0].style.MozOpacity != tt_u && !Array.every)
  579.                 tt_aV[OPACITY] = 99;
  580.         // Smartly shorten the delay for fade-in tooltips
  581.         if(tt_aV[FADEIN] && tt_flagOpa && tt_aV[DELAY] > 100)
  582.                 tt_aV[DELAY] = Math.max(tt_aV[DELAY] - tt_aV[FADEIN], 100);
  583. }
  584. function tt_AdaptConfig2()
  585. {
  586.         if(tt_aV[CENTERMOUSE])
  587.                 tt_aV[OFFSETX] -= ((tt_w - (tt_aV[SHADOW] ? tt_aV[SHADOWWIDTH] : 0)) >> 1);
  588. }
  589. // Expose content globally so extensions can modify it
  590. function tt_MkTipContent(a)
  591. {
  592.         if(tt_t2t)
  593.         {
  594.                 if(tt_aV[COPYCONTENT])
  595.                         tt_sContent = tt_t2t.innerHTML;
  596.                 else
  597.                         tt_sContent = "";
  598.         }
  599.         else
  600.                 tt_sContent = a[0];
  601.         tt_ExtCallFncs(0, "CreateContentString");
  602. }
  603. function tt_MkTipSubDivs()
  604. {
  605.         var sCss = 'position:relative;margin:0px;padding:0px;border-width:0px;left:0px;top:0px;line-height:normal;width:auto;',
  606.         sTbTrTd = ' cellspacing=0 cellpadding=0 border=0 style="' + sCss + '"><tbody style="' + sCss + '"><tr><td ';
  607.  
  608.         tt_aElt[0].innerHTML =
  609.                 (''
  610.                 + (tt_aV[TITLE].length ?
  611.                         ('<div id="WzTiTl" style="position:relative;z-index:1;">'
  612.                         + '<table id="WzTiTlTb"' + sTbTrTd + 'id="WzTiTlI" style="' + sCss + '">'
  613.                         + tt_aV[TITLE]
  614.                         + '</td>'
  615.                         + (tt_aV[CLOSEBTN] ?
  616.                                 ('<td align="right" style="' + sCss
  617.                                 + 'text-align:right;">'
  618.                                 + '<span id="WzClOsE" style="padding-left:2px;padding-right:2px;'
  619.                                 + 'cursor:' + (tt_ie ? 'hand' : 'pointer')
  620.                                 + ';" onmouseover="tt_OnCloseBtnOver(1)" onmouseout="tt_OnCloseBtnOver(0)" onclick="tt_HideInit()">'
  621.                                 + tt_aV[CLOSEBTNTEXT]
  622.                                 + '</span></td>')
  623.                                 : '')
  624.                         + '</tr></tbody></table></div>')
  625.                         : '')
  626.                 + '<div id="WzBoDy" style="position:relative;z-index:0;">'
  627.                 + '<table' + sTbTrTd + 'id="WzBoDyI" style="' + sCss + '">'
  628.                 + tt_sContent
  629.                 + '</td></tr></tbody></table></div>'
  630.                 + (tt_aV[SHADOW]
  631.                         ? ('<div id="WzTtShDwR" style="position:absolute;overflow:hidden;"></div>'
  632.                                 + '<div id="WzTtShDwB" style="position:relative;overflow:hidden;"></div>')
  633.                         : '')
  634.                 );
  635.         tt_GetSubDivRefs();
  636.         // Convert DOM node to tip
  637.         if(tt_t2t && !tt_aV[COPYCONTENT])
  638.         {
  639.                 // Store the tag's parent element so we can restore that DOM branch
  640.                 // once the tooltip is hidden
  641.                 tt_t2tDad = tt_t2t.parentNode || tt_t2t.parentElement || tt_t2t.offsetParent || null;
  642.                 if(tt_t2tDad)
  643.                 {
  644.                         tt_MovDomNode(tt_t2t, tt_t2tDad, tt_aElt[6]);
  645.                         tt_t2t.style.display = "block";
  646.                 }
  647.         }
  648.         tt_ExtCallFncs(0, "SubDivsCreated");
  649. }
  650. function tt_GetSubDivRefs()
  651. {
  652.         var aId = new Array("WzTiTl", "WzTiTlTb", "WzTiTlI", "WzClOsE", "WzBoDy", "WzBoDyI", "WzTtShDwB", "WzTtShDwR");
  653.  
  654.         for(var i = aId.length; i; --i)
  655.                 tt_aElt[i] = tt_GetElt(aId[i - 1]);
  656. }
  657. function tt_FormatTip()
  658. {
  659.         var css, w, iOffY, iOffSh;
  660.  
  661.         //--------- Title DIV ----------
  662.         if(tt_aV[TITLE].length)
  663.         {
  664.                 css = tt_aElt[1].style;
  665.                 css.background = tt_aV[TITLEBGCOLOR];
  666.                 css.paddingTop = (tt_aV[CLOSEBTN] ? 2 : 0) + "px";
  667.                 css.paddingBottom = "1px";
  668.                 css.paddingLeft = css.paddingRight = tt_aV[PADDING] + "px";
  669.                 css = tt_aElt[3].style;
  670.                 css.color = tt_aV[TITLEFONTCOLOR];
  671.                 css.fontFamily = tt_aV[TITLEFONTFACE];
  672.                 css.fontSize = tt_aV[TITLEFONTSIZE];
  673.                 css.fontWeight = "bold";
  674.                 css.textAlign = tt_aV[TITLEALIGN];
  675.                 // Close button DIV
  676.                 if(tt_aElt[4])
  677.                 {
  678.                         css.paddingRight = (tt_aV[PADDING] << 1) + "px";
  679.                         css = tt_aElt[4].style;
  680.                         css.background = tt_aV[CLOSEBTNCOLORS][0];
  681.                         css.color = tt_aV[CLOSEBTNCOLORS][1];
  682.                         css.fontFamily = tt_aV[TITLEFONTFACE];
  683.                         css.fontSize = tt_aV[TITLEFONTSIZE];
  684.                         css.fontWeight = "bold";
  685.                 }
  686.                 if(tt_aV[WIDTH] > 0)
  687.                         tt_w = tt_aV[WIDTH] + ((tt_aV[PADDING] + tt_aV[BORDERWIDTH]) << 1);
  688.                 else
  689.                 {
  690.                         tt_w = tt_GetDivW(tt_aElt[3]) + tt_GetDivW(tt_aElt[4]);
  691.                         // Some spacing between title DIV and closebutton
  692.                         if(tt_aElt[4])
  693.                                 tt_w += tt_aV[PADDING];
  694.                 }
  695.                 // Ensure the top border of the body DIV be covered by the title DIV
  696.                 iOffY = -tt_aV[BORDERWIDTH];
  697.         }
  698.         else
  699.         {
  700.                 tt_w = 0;
  701.                 iOffY = 0;
  702.         }
  703.  
  704.         //-------- Body DIV ------------
  705.         css = tt_aElt[5].style;
  706.         css.top = iOffY + "px";
  707.         if(tt_aV[BORDERWIDTH])
  708.         {
  709.                 css.borderColor = tt_aV[BORDERCOLOR];
  710.                 css.borderStyle = tt_aV[BORDERSTYLE];
  711.                 css.borderWidth = tt_aV[BORDERWIDTH] + "px";
  712.         }
  713.         if(tt_aV[BGCOLOR].length)
  714.                 css.background = tt_aV[BGCOLOR];
  715.         if(tt_aV[BGIMG].length)
  716.                 css.backgroundImage = "url(" + tt_aV[BGIMG] + ")";
  717.         css.padding = tt_aV[PADDING] + "px";
  718.         css.textAlign = tt_aV[TEXTALIGN];
  719.         // TD inside body DIV
  720.         css = tt_aElt[6].style;
  721.         css.color = tt_aV[FONTCOLOR];
  722.         css.fontFamily = tt_aV[FONTFACE];
  723.         css.fontSize = tt_aV[FONTSIZE];
  724.         css.fontWeight = tt_aV[FONTWEIGHT];
  725.         css.background = "";
  726.         css.textAlign = tt_aV[TEXTALIGN];
  727.         if(tt_aV[WIDTH] > 0)
  728.                 w = tt_aV[WIDTH] + ((tt_aV[PADDING] + tt_aV[BORDERWIDTH]) << 1);
  729.         else
  730.                 // We measure the width of the body's inner TD, because some browsers
  731.                 // expand the width of the container and outer body DIV to 100%
  732.                 w = tt_GetDivW(tt_aElt[6]) + ((tt_aV[PADDING] + tt_aV[BORDERWIDTH]) << 1);
  733.         if(w > tt_w)
  734.                 tt_w = w;
  735.  
  736.         //--------- Shadow DIVs ------------
  737.         if(tt_aV[SHADOW])
  738.         {
  739.                 tt_w += tt_aV[SHADOWWIDTH];
  740.                 iOffSh = Math.floor((tt_aV[SHADOWWIDTH] * 4) / 3);
  741.                 // Bottom shadow
  742.                 css = tt_aElt[7].style;
  743.                 css.top = iOffY + "px";
  744.                 css.left = iOffSh + "px";
  745.                 css.width = (tt_w - iOffSh - tt_aV[SHADOWWIDTH]) + "px";
  746.                 css.height = tt_aV[SHADOWWIDTH] + "px";
  747.                 css.background = tt_aV[SHADOWCOLOR];
  748.                 // Right shadow
  749.                 css = tt_aElt[8].style;
  750.                 css.top = iOffSh + "px";
  751.                 css.left = (tt_w - tt_aV[SHADOWWIDTH]) + "px";
  752.                 css.width = tt_aV[SHADOWWIDTH] + "px";
  753.                 css.background = tt_aV[SHADOWCOLOR];
  754.         }
  755.         else
  756.                 iOffSh = 0;
  757.  
  758.         //-------- Container DIV -------
  759.         tt_SetTipOpa(tt_aV[FADEIN] ? 0 : tt_aV[OPACITY]);
  760.         tt_FixSize(iOffY, iOffSh);
  761. }
  762. // Fixate the size so it can't dynamically change while the tooltip is moving.
  763. function tt_FixSize(iOffY, iOffSh)
  764. {
  765.         var wIn, wOut, i;
  766.  
  767.         tt_aElt[0].style.width = tt_w + "px";
  768.         tt_aElt[0].style.pixelWidth = tt_w;
  769.         wOut = tt_w - ((tt_aV[SHADOW]) ? tt_aV[SHADOWWIDTH] : 0);
  770.         // Body
  771.         wIn = wOut;
  772.         if(!tt_bBoxOld)
  773.                 wIn -= ((tt_aV[PADDING] + tt_aV[BORDERWIDTH]) << 1);
  774.         tt_aElt[5].style.width = wIn + "px";
  775.         // Title
  776.         if(tt_aElt[1])
  777.         {
  778.                 wIn = wOut - (tt_aV[PADDING] << 1);
  779.                 if(!tt_bBoxOld)
  780.                         wOut = wIn;
  781.                 tt_aElt[1].style.width = wOut + "px";
  782.                 tt_aElt[2].style.width = wIn + "px";
  783.         }
  784.         tt_h = tt_GetDivH(tt_aElt[0]) + iOffY;
  785.         // Right shadow
  786.         if(tt_aElt[8])
  787.                 tt_aElt[8].style.height = (tt_h - iOffSh) + "px";
  788.         i = tt_aElt.length - 1;
  789.         if(tt_aElt[i])
  790.         {
  791.                 tt_aElt[i].style.width = tt_w + "px";
  792.                 tt_aElt[i].style.height = tt_h + "px";
  793.         }
  794. }
  795. function tt_DeAlt(el)
  796. {
  797.         var aKid;
  798.  
  799.         if(el.alt)
  800.                 el.alt = "";
  801.         if(el.title)
  802.                 el.title = "";
  803.         aKid = el.childNodes || el.children || null;
  804.         if(aKid)
  805.         {
  806.                 for(var i = aKid.length; i;)
  807.                         tt_DeAlt(aKid[--i]);
  808.         }
  809. }
  810. // This hack removes the annoying native tooltips over links in Opera
  811. function tt_OpDeHref(el)
  812. {
  813.         if(!tt_op)
  814.                 return;
  815.         if(tt_elDeHref)
  816.                 tt_OpReHref();
  817.         while(el)
  818.         {
  819.                 if(el.hasAttribute("href"))
  820.                 {
  821.                         el.t_href = el.getAttribute("href");
  822.                         el.t_stats = window.status;
  823.                         el.removeAttribute("href");
  824.                         el.style.cursor = "hand";
  825.                         tt_AddEvtFnc(el, "mousedown", tt_OpReHref);
  826.                         window.status = el.t_href;
  827.                         tt_elDeHref = el;
  828.                         break;
  829.                 }
  830.                 el = el.parentElement;
  831.         }
  832. }
  833. function tt_ShowInit()
  834. {
  835.         tt_tShow.Timer("tt_Show()", tt_aV[DELAY], true);
  836.         if(tt_aV[CLICKCLOSE])
  837.                 tt_AddEvtFnc(document, "mouseup", tt_HideInit);
  838. }
  839. function tt_OverInit(e)
  840. {
  841.         tt_over = e.target || e.srcElement;
  842.         tt_DeAlt(tt_over);
  843.         tt_OpDeHref(tt_over);
  844.         tt_AddRemOutFnc(true);
  845. }
  846. function tt_Show()
  847. {
  848.         var css = tt_aElt[0].style;
  849.  
  850.         // Override the z-index of the topmost wz_dragdrop.js D&D item
  851.         css.zIndex = Math.max((window.dd && dd.z) ? (dd.z + 2) : 0, 1010);
  852.         if(tt_aV[STICKY] || !tt_aV[FOLLOWMOUSE])
  853.                 tt_iState &= ~0x4;
  854.         if(tt_aV[DURATION] > 0)
  855.                 tt_tDurt.Timer("tt_HideInit()", tt_aV[DURATION], true);
  856.         tt_ExtCallFncs(0, "Show")
  857.         css.visibility = "visible";
  858.         tt_iState |= 0x2;
  859.         if(tt_aV[FADEIN])
  860.                 tt_Fade(0, 0, tt_aV[OPACITY], Math.round(tt_aV[FADEIN] / tt_aV[FADEINTERVAL]));
  861.         tt_ShowIfrm();
  862. }
  863. function tt_ShowIfrm()
  864. {
  865.         if(tt_ie56)
  866.         {
  867.                 var ifrm = tt_aElt[tt_aElt.length - 1];
  868.                 if(ifrm)
  869.                 {
  870.                         var css = ifrm.style;
  871.                         css.zIndex = tt_aElt[0].style.zIndex - 1;
  872.                         css.display = "block";
  873.                 }
  874.         }
  875. }
  876. function tt_Move(e)
  877. {
  878.         e = window.event || e;
  879.         if(e)
  880.         {
  881.                 tt_musX = tt_GetEvtX(e);
  882.                 tt_musY = tt_GetEvtY(e);
  883.         }
  884.         if(tt_iState)
  885.         {
  886.                 if(!tt_over && e)
  887.                         tt_OverInit(e);
  888.                 if(tt_iState & 0x4)
  889.                 {
  890.                         // Protect some browsers against jam of mousemove events
  891.                         if(!tt_op && !tt_ie)
  892.                         {
  893.                                 if(tt_bWait)
  894.                                         return;
  895.                                 tt_bWait = true;
  896.                                 tt_tWaitMov.Timer("tt_bWait = false;", 1, true);
  897.                         }
  898.                         if(tt_aV[FIX])
  899.                         {
  900.                                 tt_iState &= ~0x4;
  901.                                 tt_SetTipPos(tt_aV[FIX][0], tt_aV[FIX][1]);
  902.                         }
  903.                         else if(!tt_ExtCallFncs(e, "MoveBefore"))
  904.                                 tt_SetTipPos(tt_PosX(), tt_PosY());
  905.                         tt_ExtCallFncs([tt_musX, tt_musY], "MoveAfter")
  906.                 }
  907.         }
  908. }
  909. function tt_PosX()
  910. {
  911.         var x;
  912.  
  913.         x = tt_musX;
  914.         if(tt_aV[LEFT])
  915.                 x -= tt_w + tt_aV[OFFSETX] - (tt_aV[SHADOW] ? tt_aV[SHADOWWIDTH] : 0);
  916.         else
  917.                 x += tt_aV[OFFSETX];
  918.         // Prevent tip from extending past right/left clientarea boundary
  919.         if(x > tt_maxPosX)
  920.                 x = tt_maxPosX;
  921.         return((x < tt_scrlX) ? tt_scrlX : x);
  922. }
  923. function tt_PosY()
  924. {
  925.         var y;
  926.  
  927.         // Apply some hysteresis after the tip has snapped to the other side of the
  928.         // mouse. In case of insufficient space above and below the mouse, we place
  929.         // the tip below.
  930.         if(tt_aV[ABOVE] && (!tt_bJmpVert || tt_CalcPosYAbove() >= tt_scrlY + 16))
  931.                 y = tt_DoPosYAbove();
  932.         else if(!tt_aV[ABOVE] && tt_bJmpVert && tt_CalcPosYBelow() > tt_maxPosY - 16)
  933.                 y = tt_DoPosYAbove();
  934.         else
  935.                 y = tt_DoPosYBelow();
  936.         // Snap to other side of mouse if tip would extend past window boundary
  937.         if(y > tt_maxPosY)
  938.                 y = tt_DoPosYAbove();
  939.         if(y < tt_scrlY)
  940.                 y = tt_DoPosYBelow();
  941.         return y;
  942. }
  943. function tt_DoPosYBelow()
  944. {
  945.         tt_bJmpVert = tt_aV[ABOVE];
  946.         return tt_CalcPosYBelow();
  947. }
  948. function tt_DoPosYAbove()
  949. {
  950.         tt_bJmpVert = !tt_aV[ABOVE];
  951.         return tt_CalcPosYAbove();
  952. }
  953. function tt_CalcPosYBelow()
  954. {
  955.         return(tt_musY + tt_aV[OFFSETY]);
  956. }
  957. function tt_CalcPosYAbove()
  958. {
  959.         var dy = tt_aV[OFFSETY] - (tt_aV[SHADOW] ? tt_aV[SHADOWWIDTH] : 0);
  960.         if(tt_aV[OFFSETY] > 0 && dy <= 0)
  961.                 dy = 1;
  962.         return(tt_musY - tt_h - dy);
  963. }
  964. function tt_OnOut()
  965. {
  966.         tt_AddRemOutFnc(false);
  967.         if(!(tt_aV[STICKY] && (tt_iState & 0x2)))
  968.                 tt_HideInit();
  969. }
  970. function tt_HideInit()
  971. {
  972.         tt_ExtCallFncs(0, "HideInit");
  973.         tt_iState &= ~0x4;
  974.         if(tt_flagOpa && tt_aV[FADEOUT])
  975.         {
  976.                 tt_tFade.EndTimer();
  977.                 if(tt_opa)
  978.                 {
  979.                         var n = Math.round(tt_aV[FADEOUT] / (tt_aV[FADEINTERVAL] * (tt_aV[OPACITY] / tt_opa)));
  980.                         tt_Fade(tt_opa, tt_opa, 0, n);
  981.                         return;
  982.                 }
  983.         }
  984.         tt_tHide.Timer("tt_Hide();", 1, false);
  985. }
  986. function tt_OpReHref()
  987. {
  988.         if(tt_elDeHref)
  989.         {
  990.                 tt_elDeHref.setAttribute("href", tt_elDeHref.t_href);
  991.                 tt_RemEvtFnc(tt_elDeHref, "mousedown", tt_OpReHref);
  992.                 window.status = tt_elDeHref.t_stats;
  993.                 tt_elDeHref = null;
  994.         }
  995. }
  996. function tt_Fade(a, now, z, n)
  997. {
  998.         if(n)
  999.         {
  1000.                 now += Math.round((z - now) / n);
  1001.                 if((z > a) ? (now >= z) : (now <= z))
  1002.                         now = z;
  1003.                 else
  1004.                         tt_tFade.Timer("tt_Fade("
  1005.                                                         + a + "," + now + "," + z + "," + (n - 1)
  1006.                                                         + ")",
  1007.                                                         tt_aV[FADEINTERVAL],
  1008.                                                         true);
  1009.         }
  1010.         now ? tt_SetTipOpa(now) : tt_Hide();
  1011. }
  1012. // To circumvent the opacity nesting flaws of IE, we set the opacity
  1013. // for each sub-DIV separately, rather than for the container DIV.
  1014. function tt_SetTipOpa(opa)
  1015. {
  1016.         tt_SetOpa(tt_aElt[5].style, opa);
  1017.         if(tt_aElt[1])
  1018.                 tt_SetOpa(tt_aElt[1].style, opa);
  1019.         if(tt_aV[SHADOW])
  1020.         {
  1021.                 opa = Math.round(opa * 0.8);
  1022.                 tt_SetOpa(tt_aElt[7].style, opa);
  1023.                 tt_SetOpa(tt_aElt[8].style, opa);
  1024.         }
  1025. }
  1026. function tt_OnCloseBtnOver(iOver)
  1027. {
  1028.         var css = tt_aElt[4].style;
  1029.  
  1030.         iOver <<= 1;
  1031.         css.background = tt_aV[CLOSEBTNCOLORS][iOver];
  1032.         css.color = tt_aV[CLOSEBTNCOLORS][iOver + 1];
  1033. }
  1034. function tt_Int(x)
  1035. {
  1036.         var y;
  1037.  
  1038.         return(isNaN(y = parseInt(x)) ? 0 : y);
  1039. }
  1040. // Adds or removes the document.mousemove or HoveredElem.mouseout handler
  1041. // conveniently. Keeps track of those handlers to prevent them from being
  1042. // set or removed redundantly.
  1043. function tt_AddRemOutFnc(bAdd)
  1044. {
  1045.         var PSet = bAdd ? tt_AddEvtFnc : tt_RemEvtFnc;
  1046.  
  1047.         if(bAdd != tt_AddRemOutFnc.bOn)
  1048.         {
  1049.                 PSet(tt_over, "mouseout", tt_OnOut);
  1050.                 tt_AddRemOutFnc.bOn = bAdd;
  1051.                 if(!bAdd)
  1052.                         tt_OpReHref();
  1053.         }
  1054. }
  1055. tt_AddRemOutFnc.bOn = false;
  1056. Number.prototype.Timer = function(s, iT, bUrge)
  1057. {
  1058.         if(!this.value || bUrge)
  1059.                 this.value = window.setTimeout(s, iT);
  1060. }
  1061. Number.prototype.EndTimer = function()
  1062. {
  1063.         if(this.value)
  1064.         {
  1065.                 window.clearTimeout(this.value);
  1066.                 this.value = 0;
  1067.         }
  1068. }
  1069. function tt_SetOpa(css, opa)
  1070. {
  1071.         tt_opa = opa;
  1072.         if(tt_flagOpa == 1)
  1073.         {
  1074.                 // Hack for bugs of IE:
  1075.                 // A DIV cannot be made visible in a single step if an opacity < 100
  1076.                 // has been applied while the DIV was hidden.
  1077.                 // Moreover, in IE6, applying an opacity < 100 has no effect if the
  1078.                 // concerned element has no layout (position, size, zoom, ...).
  1079.                 if(opa < 100)
  1080.                 {
  1081.                         var bVis = css.visibility != "hidden";
  1082.                         css.zoom = "100%";
  1083.                         if(!bVis)
  1084.                                 css.visibility = "visible";
  1085.                         css.filter = "alpha(opacity=" + opa + ")";
  1086.                         if(!bVis)
  1087.                                 css.visibility = "hidden";
  1088.                 }
  1089.                 else
  1090.                         css.filter = "";
  1091.         }
  1092.         else
  1093.         {
  1094.                 opa /= 100.0;
  1095.                 switch(tt_flagOpa)
  1096.                 {
  1097.                 case 2:
  1098.                         css.KhtmlOpacity = opa; break;
  1099.                 case 3:
  1100.                         css.KHTMLOpacity = opa; break;
  1101.                 case 4:
  1102.                         css.MozOpacity = opa; break;
  1103.                 case 5:
  1104.                         css.opacity = opa; break;
  1105.                 }
  1106.         }
  1107. }
  1108. function tt_MovDomNode(el, dadFrom, dadTo)
  1109. {
  1110.         if(dadFrom)
  1111.                 dadFrom.removeChild(el);
  1112.         if(dadTo)
  1113.                 dadTo.appendChild(el);
  1114. }
  1115. function tt_Err(sErr)
  1116. {
  1117.         if(tt_Debug)
  1118.                 alert("Tooltip Script Error Message:\n\n" + sErr);
  1119. }
  1120.  
  1121. //===========  DEALING WITH EXTENSIONS  ==============//
  1122. function tt_ExtCmdEnum()
  1123. {
  1124.         var s;
  1125.  
  1126.         // Add new command(s) to the commands enum
  1127.         for(var i in config)
  1128.         {
  1129.                 s = "window." + i.toString().toUpperCase();
  1130.                 if(eval("typeof(" + s + ") == tt_u"))
  1131.                 {
  1132.                         eval(s + " = " + tt_aV.length);
  1133.                         tt_aV[tt_aV.length] = null;
  1134.                 }
  1135.         }
  1136. }
  1137. function tt_ExtCallFncs(arg, sFnc)
  1138. {
  1139.         var b = false;
  1140.         for(var i = tt_aExt.length; i;)
  1141.         {--i;
  1142.                 var fnc = tt_aExt[i]["On" + sFnc];
  1143.                 // Call the method the extension has defined for this event
  1144.                 if(fnc && fnc(arg))
  1145.                         b = true;
  1146.         }
  1147.         return b;
  1148. }
  1149.  
  1150. tt_Init();
  1151.