home *** CD-ROM | disk | FTP | other *** search
/ Microsoft DirectX SDK 7.0 / Dx7.bin / DXF / doc / directx6.1 / directx.chm / dxmedia / foundation / dplay / tip2.js < prev    next >
Encoding:
Text File  |  1999-03-03  |  3.4 KB  |  104 lines

  1. var sFileName = '';         // File Name to load in Buffer
  2. var sAnchor ='';        // Glossary entry to select from Buffer;
  3. var eSrc = new Object;        // Event source object.
  4.  
  5. window.self.document.write('<DIV ID="idToolTip" STYLE="position:absolute; visibility:hidden ; border:1 solid black; width:400px; padding:3px; background-color:lemonchiffon; font:8pt Tahoma; line-height:8pt;"></DIV>');
  6. for (var i=0 ; i < document.all.length; i++) {
  7.     eTarget = document.all[i];
  8.     if (eTarget.tagName == "A" && eTarget.getAttribute("href")) {
  9.     if (eTarget.className == "Glossary") {
  10.         eTarget.onmouseover = TrapEvent;
  11.         eTarget.onblur = lnkOut;
  12.     }
  13.     }
  14. }
  15.  
  16. // Get the event from the <A> link
  17. function TrapEvent(){ eSrc = window.event.srcElement }
  18.  
  19. // Extract the file name from the string passed to Glossary() function
  20. function getFileName(str){
  21. sFileName = '';
  22.     if (str.indexOf("#") > 0){
  23.         for (var i = 0 ; i < str.indexOf("#"); i++){
  24.         sFileName += str.charAt(i);
  25.     }
  26.     }
  27.     else{
  28.         sFileName = str;
  29.     }
  30. }
  31.  
  32.  
  33. // Extract the anchor from the string passed to Glossary() function
  34. function getAnchor(str){
  35. sAnchor = '';
  36.     if (str.indexOf("#") > 0){
  37.         for (var i = (str.indexOf("#") + 1 ) ; i < str.length; i++){
  38.                sAnchor += str.charAt(i);
  39.        }
  40.     sAnchor = 'GLS_' + sAnchor
  41.     }
  42. }
  43.  
  44. // Get the word definition from the file in the buffer
  45. function GetFromBuffer(){ 
  46.     // Anchor is valid, get the word definition
  47.     //alert(sAnchor);
  48.     if (sAnchor != '') {
  49.         if (typeof(eval('document.frames.G_L_S.document.all.' + sAnchor)) != 'undefined') { // Get word definition
  50.                 var wordDefinition = eval('document.frames.G_L_S.document.all.' + sAnchor + '.innerText');
  51.             SetDiv(wordDefinition);
  52.         }
  53.     else { ShowHelp(sFileName); }
  54.     }
  55.     // Anchor not present
  56.     //else { if (sFileName != '') ShowHelp(sFileName)}
  57.     // NOTE: ShowHelp function is defined in gloss.js
  58. }
  59.  
  60. // Position the DIV
  61. function SetDiv(str){
  62.     var parent = eSrc;
  63.     var OffSetTop = 0;
  64.     var OffSetLeft = 0;
  65.     // Get the cumulative value for the offset position 
  66.     while (parent.tagName != 'BODY'){
  67.            if (parent.tagName == 'TBODY') {parent = parent.parentElement; continue; };    // for whatever weird reason  this return a value that needs to be killed.
  68.     OffSetTop += parent.offsetParent.offsetTop;
  69.     OffSetLeft += parent.offsetParent.offsetLeft;
  70.     parent = parent.parentElement;
  71.     }
  72.     OffSetTop += eSrc.offsetTop;
  73.     OffSetLeft += eSrc.offsetLeft;
  74.     
  75.     // If position runs off the screen to the right
  76.     if (((OffSetLeft + 420) > document.body.offsetWidth) && (document.body.offsetWidth > 420 )) {
  77.         OffSetLeft = document.body.offsetWidth - 420;
  78.     }
  79.     
  80.     with (idToolTip){
  81.     style.visibility = "hidden";
  82.           innerHTML = '<B>' + eSrc.innerText + '</B><P>' + str;
  83.           style.left = OffSetLeft;
  84.           style.top = (OffSetTop + 16);
  85.     style.visibility = "visible"; 
  86.     }
  87. }
  88.  
  89. // Load glossary file if not loaded or if new file is requested
  90. function lnkOver(path){
  91.     getFileName(path); getAnchor(path);
  92.     if ((document.all.G_L_S.src != sFileName) && (sAnchor != '')) {
  93.     document.all.G_L_S.src = sFileName;
  94.     }
  95.     else {
  96.         GetFromBuffer();
  97.     }
  98. }
  99.  
  100. // Display the DIV
  101. function showTip() { with (idToolTip) { style.visibility = "visible";}}
  102.  
  103. // Hide the DIV
  104. function lnkOut() {with (idToolTip) { style.visibility = "hidden"; style.left = 0; style.bottom = 0; }}