home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 2001 July / VPR0107A.BIN / dxdiaswe.chm / langref.js < prev    next >
Text File  |  2000-11-07  |  19KB  |  806 lines

  1. //
  2. // Common code
  3. //
  4. var ie4 = false;
  5. var advanced = false;
  6. var curLang = null;
  7. var showAll = true;
  8. var cook = null;
  9. var baseUrl = document.scripts[document.scripts.length - 1].src.replace(/[^\/]+.js/, "");
  10.  
  11. if (navigator.appName == "Microsoft Internet Explorer") {
  12.     var ver = navigator.appVersion;
  13.     var v = new Number(ver.substring(0,ver.indexOf(".", 0)));
  14.     if (v >= 4) {
  15.         advanced = true;
  16.         ie4 = true;
  17.  
  18.         // Look for 5.x buried somewhere in the version string.
  19.         var toks = ver.split(/[^0-9.]/);
  20.         if (toks) {
  21.             for (var i = 0; i < toks.length; i++) {
  22.                 var tok = toks[i];
  23.                 if (tok.indexOf(".", 0) > 0) {
  24.                     if (tok >= 5)
  25.                         ie4 = false;
  26.                 }
  27.             }
  28.         }
  29.     }
  30. }
  31.  
  32. if (advanced)
  33.     window.onload = bodyOnLoad;
  34.  
  35. function bodyOnClick()
  36. {
  37.     if (advanced) {
  38.         var elem = window.event.srcElement;
  39.         for (; elem; elem = elem.parentElement) {
  40.             if (elem.id == "reftip")
  41.                 return;
  42.         }
  43.  
  44.         hideTip();
  45.         closeMenu();
  46.         hideSeeAlso();
  47.     }
  48. }
  49.  
  50. function bodyOnLoad()
  51. {
  52.     if (advanced) {
  53.         initLangs();
  54.         initReftips();
  55.         initSeeAlso();
  56.         document.body.onclick = bodyOnClick;
  57.     }
  58. }
  59.  
  60. //
  61. // Language filtering
  62. //
  63. function initLangs()
  64. {
  65.     var hdr = document.all.hdr;
  66.     if (!hdr)
  67.         return;
  68.  
  69.     var langs = new Array;
  70.     var spans = document.all.tags("SPAN");
  71.     if (spans) {
  72.         var iElem = spans.length;
  73.         for (iElem = 0; iElem < spans.length; iElem++) {
  74.             var elem = spans[iElem];
  75.             if (elem.className == "lang") {
  76.  
  77.                 // Update the array of unique language names.
  78.                 var a = elem.innerText.split(",");
  79.                 for (var iTok = 0; iTok < a.length; iTok++) {
  80.                     var m = a[iTok].match(/([A-Za-z].*[A-Za-z+])/);
  81.                     if (m) {
  82.                         var iLang = 0;
  83.                         while (iLang < langs.length && langs[iLang] < m[1])
  84.                             iLang++;
  85.                         if (iLang == langs.length || langs[iLang] != m[1]) {
  86.                             var before = langs.slice(0,iLang);
  87.                             var after = langs.slice(iLang);
  88.                             langs = before.concat(m[1]).concat(after);
  89.                         }
  90.                     }
  91.                 }
  92.             }
  93.         }
  94.     }
  95.  
  96.     if (langs.length > 0) {
  97.         var pres = document.all.tags("PRE");
  98.         if (pres) {
  99.             for (var iPre = 0; iPre < pres.length; iPre++)
  100.                 initPreElem(pres[iPre]);
  101.         }
  102.  
  103.         var obj = document.all.obj_cook;
  104.         if (obj && obj.object) {
  105.             cook = obj;
  106.             var lang = obj.getValue("lang");
  107.             var iLang = langs.length - 1;
  108.             while (iLang && langs[iLang] != lang)
  109.                 iLang--;
  110.             curLang = langs[iLang];
  111.             if (obj.getValue("lang.all") != "1")
  112.                 showAll = false;
  113.         }
  114.  
  115.         var iLim = document.body.children.length;
  116.         var head = null;
  117.         for (var i = 0; i < iLim; i++) {
  118.             var elem = document.body.children[i];
  119.             if (elem.tagName.match(/^(P)|(PRE)|([DOU]L)$/))
  120.                 break;
  121.             if (elem.tagName.match(/^H[1-6]$/)) {
  122.                 head = elem;
  123.                 head.insertAdjacentHTML('BeforeEnd', '<SPAN CLASS=ilang></SPAN>');
  124.             }
  125.         }
  126.  
  127.         var td = hdr.insertCell(0);
  128.         if (td) {
  129.             // Localizable strings.
  130.             var L_Filter_Tip = "Språkfilter";    // tooltip for language button
  131.             var L_Language = "Språk";                // heading for menu of programming languages
  132.             var L_Show_All = "Visa alla";                // label for 'show all languages' menu item
  133.  
  134.             // Add the language button to the button bar.
  135.             td.className = "button1";
  136.             td.style.width = "19px";
  137.             td.onclick = langMenu;
  138.             td.innerHTML = '<IMG SRC="' + baseUrl + 'Filter.gif' + '" ALT="' +
  139.                 L_Filter_Tip + '" BORDER=0>';
  140.  
  141.             // Add the menu.
  142.             var div = '<DIV ID="lang_menu" CLASS=langMenu><B>' + L_Language + '</B><UL>';
  143.             for (var i = 0; i < langs.length; i++)
  144.                 div += '<LI><A HREF="" ONCLICK="chooseLang(this)">' + langs[i] + '</A><BR>';
  145.             div += '<LI><A HREF="" ONCLICK="chooseAll()">' + L_Show_All + '</A></UL></DIV>';
  146.             document.body.insertAdjacentHTML('BeforeEnd', div);
  147.         }
  148.  
  149.         if (!showAll)
  150.             filterLang();
  151.     }
  152. }
  153.  
  154. function initPreElem(pre)
  155. {
  156.     var htm0 = pre.outerHTML;
  157.  
  158.     var reLang = /<span\b[^>]*class="?lang"?[^>]*>/i;
  159.     var iFirst = -1;
  160.     var iSecond = -1;
  161.  
  162.     iFirst = htm0.search(reLang);
  163.     if (iFirst >= 0) {
  164.         iPos = iFirst + 17;
  165.         iMatch = htm0.substr(iPos).search(reLang);
  166.         if (iMatch >= 0)
  167.             iSecond = iPos + iMatch;
  168.     }
  169.  
  170.     if (iSecond < 0) {
  171.         var htm1 = trimPreElem(htm0);
  172.         if (htm1 != htm0) {
  173.             pre.insertAdjacentHTML('AfterEnd', htm1);
  174.             pre.outerHTML = "";
  175.         }
  176.     }
  177.     else {
  178.         var rePairs = /<(\w+)\b[^>]*><\/\1>/gi;
  179.  
  180.         var substr1 = htm0.substring(0,iSecond);
  181.         var tags1 = substr1.replace(/>[^<>]+(<|$)/g, ">$1");
  182.         var open1 = tags1.replace(rePairs, "");
  183.         open1 = open1.replace(rePairs, "");
  184.  
  185.         var substr2 = htm0.substring(iSecond);
  186.         var tags2 = substr2.replace(/>[^<>]+</g, "><");
  187.         var open2 = tags2.replace(rePairs, "");
  188.         open2 = open2.replace(rePairs, "");
  189.  
  190.         pre.insertAdjacentHTML('AfterEnd', open1 + substr2);
  191.         pre.insertAdjacentHTML('AfterEnd', trimPreElem(substr1 + open2));
  192.         pre.outerHTML = "";
  193.     }    
  194. }
  195.  
  196. function trimPreElem(htm)
  197. {
  198.     return htm.replace(/[ \r\n]*((<\/[BI]>)*)[ \r\n]*<\/PRE>/g, "$1</PRE>").replace(
  199.         /\w*<\/SPAN>\w*((<[BI]>)*)\w*\r\n/g, "\r\n</SPAN>$1"
  200.         );
  201. }
  202.  
  203. function getBlock(elem)
  204. {
  205.     while (elem && elem.tagName.match(/^[BIUA]|(SPAN)|(CODE)|(TD)$/))
  206.         elem = elem.parentElement;
  207.     return elem;
  208. }
  209.  
  210. function langMenu()
  211. {
  212.     bodyOnClick();
  213.  
  214.     window.event.returnValue = false;
  215.     window.event.cancelBubble = true;
  216.  
  217.     var div = document.all.lang_menu;
  218.     var lnk = window.event.srcElement;
  219.     if (div && lnk) {
  220.         var x = lnk.offsetLeft + lnk.offsetWidth - div.offsetWidth;
  221.         div.style.pixelLeft = (x < 0) ? 0 : x;
  222.         div.style.pixelTop = lnk.offsetTop + lnk.offsetHeight;
  223.         div.style.visibility = "visible";
  224.     }
  225. }
  226.  
  227. function chooseLang(item)
  228. {
  229.     window.event.returnValue = false;
  230.     window.event.cancelBubble = true;
  231.  
  232.     if (item) {
  233.         closeMenu();
  234.         curLang = item.innerText;
  235.         showAll = false;
  236.     }
  237.  
  238.     if (cook) {
  239.         cook.putValue('lang', curLang);
  240.         cook.putValue('lang.all', '');
  241.     }
  242.  
  243.     filterLang();
  244. }
  245.  
  246. function chooseAll()
  247. {
  248.     window.event.returnValue = false;
  249.     window.event.cancelBubble = true;
  250.  
  251.     closeMenu();
  252.  
  253.     showAll = true;
  254.     if (cook)
  255.         cook.putValue('lang.all', '1');
  256.  
  257.     unfilterLang();
  258. }
  259.  
  260. function closeMenu()
  261. {
  262.     var div = document.all.lang_menu;
  263.     if (div && div.style.visibility != "hidden") {
  264.         var lnk = document.activeElement;
  265.         if (lnk && lnk.tagName == "A")
  266.             lnk.blur();
  267.  
  268.         div.style.visibility = "hidden";
  269.     }
  270. }
  271.  
  272. function getNext(elem)
  273. {
  274.     for (var i = elem.sourceIndex + 1; i < document.all.length; i++) {
  275.         var next = document.all[i];
  276.         if (!elem.contains(next))
  277.             return next;
  278.     }
  279.     return null;
  280. }
  281.  
  282. function filterMatch(text, name)
  283. {
  284.     var a = text.split(",");
  285.     for (var iTok = 0; iTok < a.length; iTok++) {
  286.         var m = a[iTok].match(/([A-Za-z].*[A-Za-z+])/);
  287.         if (m && m[1] == name)
  288.             return true;
  289.     }
  290.     return false;
  291. }
  292.  
  293. function topicHeading(head)
  294. {
  295.     var iLim = document.body.children.length;
  296.     var idxLim = head.sourceIndex;
  297.  
  298.     for (var i = 0; i < iLim; i++) {
  299.         var elem = document.body.children[i];
  300.         if (elem.sourceIndex < idxLim) {
  301.             if (elem.tagName.match(/^(P)|(PRE)|([DOU]L)$/))
  302.                 return false;
  303.         }
  304.         else
  305.             break;
  306.     }
  307.     return true;
  308. }
  309.  
  310. function filterLang()
  311. {
  312.     var spans = document.all.tags("SPAN");
  313.     for (var i = 0; i < spans.length; i++) {
  314.         var elem = spans[i];
  315.         if (elem.className == "lang") {
  316.             var newVal = filterMatch(elem.innerText, curLang) ? "block" : "none";
  317.             var block = getBlock(elem);
  318.             block.style.display = newVal;
  319.             elem.style.display = "none";
  320.  
  321.             if (block.tagName == "DT") {
  322.                 var next = getNext(block);
  323.                 if (next && next.tagName == "DD")
  324.                     next.style.display = newVal;
  325.             }
  326.             else if (block.tagName == "DIV") {
  327.                 block.className = "filtered2";
  328.             }
  329.             else if (block.tagName.match(/^H[1-6]$/)) {
  330.                 if (topicHeading(block)) {
  331.                     if (newVal != "none") {
  332.                         var tag = null;
  333.                         if (block.children && block.children.length) {
  334.                             tag = block.children[block.children.length - 1];
  335.                             if (tag.className == "ilang") {
  336.                                 tag.innerHTML = (newVal == "block") ?
  337.                                     '  [Language: ' + curLang + ']' : "";
  338.                             }
  339.                         }
  340.                     }
  341.                 }
  342.                 else {
  343.                     var next = getNext(block);
  344.                     while (next && !next.tagName.match(/^(H[1-6])|(DIV)$/)) {
  345.                         next.style.display = newVal;
  346.                         next = getNext(next);
  347.                     }
  348.                 }
  349.             }
  350.         }
  351.         else if (elem.className == "ilang") {
  352.             elem.innerHTML = '  [Language: ' + curLang + ']';
  353.         }
  354.     }
  355.  
  356.     if (ie4) {
  357.         document.body.style.display = "none";
  358.         document.body.style.display = "block";
  359.     }
  360. }
  361.  
  362. function unfilterLang(name)
  363. {
  364.     var spans = document.all.tags("SPAN");
  365.     for (var i = 0; i < spans.length; i++) {
  366.         var elem = spans[i];
  367.         if (elem.className == "lang") {
  368.             var block = getBlock(elem);
  369.             block.style.display = "block";
  370.             elem.style.display = "inline";
  371.  
  372.             if (block.tagName == "DT") {
  373.                 var next = getNext(block);
  374.                 if (next && next.tagName == "DD")
  375.                     next.style.display = "block";
  376.             }
  377.             else if (block.tagName == "DIV") {
  378.                 block.className = "filtered";
  379.             }
  380.             else if (block.tagName.match(/^H[1-6]$/)) {
  381.                 if (topicHeading(block)) {
  382.                     var tag = null;
  383.                     if (block.children && block.children.length) {
  384.                         tag = block.children[block.children.length - 1];
  385.                         if (tag && tag.className == "ilang")
  386.                             tag.innerHTML = "";
  387.                     }
  388.                 }
  389.                 else {
  390.                     var next = getNext(block);
  391.                     while (next && !next.tagName.match(/^(H[1-6])|(DIV)$/)) {
  392.                         next.style.display = "block";
  393.                         next = getNext(next);
  394.                     }
  395.                 }
  396.             }
  397.         }
  398.         else if (elem.className == "ilang") {
  399.             elem.innerHTML = "";
  400.         }
  401.     }
  402. }
  403.  
  404.  
  405. //
  406. // Reftips (parameter popups)
  407. //
  408. function initReftips()
  409. {
  410.     var DLs = document.all.tags("DL");
  411.     var PREs = document.all.tags("PRE");
  412.     if (DLs && PREs) {
  413.         var iDL = 0;
  414.         var iPRE = 0;
  415.         var iSyntax = -1;
  416.         for (var iPRE = 0; iPRE < PREs.length; iPRE++) {
  417.             if (PREs[iPRE].className == "syntax") {
  418.                 while (iDL < DLs.length && DLs[iDL].sourceIndex < PREs[iPRE].sourceIndex)
  419.                     iDL++;            
  420.                 if (iDL < DLs.length) {
  421.                     initSyntax(PREs[iPRE], DLs[iDL]);
  422.                     iSyntax = iPRE;
  423.                 }
  424.                 else
  425.                     break;
  426.             }
  427.         }
  428.  
  429.         if (iSyntax >= 0) {
  430.             var last = PREs[iSyntax];
  431.             last.insertAdjacentHTML(
  432.                 'AfterEnd',
  433.                 '<DIV ID=reftip CLASS=reftip STYLE="position:absolute;visibility:hidden;overflow:visible;"></DIV>'
  434.                 );
  435.         }
  436.     }
  437. }
  438.  
  439. function initSyntax(pre, dl)
  440. {
  441.     var strSyn = pre.outerHTML;
  442.     var ichStart = strSyn.indexOf('>', 0) + 1;
  443.     var terms = dl.children.tags("DT");
  444.     if (terms) {
  445.         for (var iTerm = 0; iTerm < terms.length; iTerm++) {
  446.             var words = terms[iTerm].innerText.replace(/\[.+\]/g, " ").replace(/,/g, " ").split(" ");
  447.             var htm = terms[iTerm].innerHTML;
  448.             for (var iWord = 0; iWord < words.length; iWord++) {
  449.                 var word = words[iWord];
  450.  
  451.                 if (word.length > 0 && htm.indexOf(word, 0) < 0)
  452.                     word = word.replace(/:.+/, "");
  453.  
  454.                 if (word.length > 0) {
  455.                     var ichMatch = findTerm(strSyn, ichStart, word);
  456.                     while (ichMatch > 0) {
  457.                         var strTag = '<A HREF="" ONCLICK="showTip(this)" CLASS="synParam">' + word + '</A>';
  458.  
  459.                         strSyn =
  460.                             strSyn.slice(0, ichMatch) +
  461.                             strTag +
  462.                             strSyn.slice(ichMatch + word.length);
  463.  
  464.                         ichMatch = findTerm(strSyn, ichMatch + strTag.length, word);
  465.                     }
  466.                 }
  467.             }
  468.         }
  469.     }
  470.  
  471.     // Replace the syntax block with our modified version.
  472.     pre.outerHTML = strSyn;
  473. }
  474.  
  475. function findTerm(strSyn, ichPos, strTerm)
  476. {
  477.     var ichMatch = strSyn.indexOf(strTerm, ichPos);
  478.     while (ichMatch >= 0) {
  479.         var prev = (ichMatch == 0) ? '\0' : strSyn.charAt(ichMatch - 1);
  480.         var next = strSyn.charAt(ichMatch + strTerm.length);
  481.         if (prev != '<' && !isalnum(prev) && !isalnum(next)) {
  482.             var ichComment = strSyn.indexOf("/*", ichPos);
  483.             while (ichComment >= 0) {
  484.                 if (ichComment > ichMatch) { 
  485.                     ichComment = -1;
  486.                     break; 
  487.                 }
  488.                 var ichEnd = strSyn.indexOf("*/", ichComment);
  489.                 if (ichEnd < 0 || ichEnd > ichMatch)
  490.                     break;
  491.                 ichComment = strSyn.indexOf("/*", ichEnd);
  492.             }
  493.             if (ichComment < 0) {
  494.                 ichComment = strSyn.indexOf("//", ichPos);
  495.                 while (ichComment >= 0) {
  496.                     if (ichComment > ichMatch) {
  497.                         ichComment = -1;
  498.                         break; 
  499.                     }
  500.                     var ichEnd = strSyn.indexOf("\n", ichComment);
  501.                     if (ichEnd < 0 || ichEnd > ichMatch)
  502.                         break;
  503.                     ichComment = strSyn.indexOf("//", ichEnd);
  504.                 }
  505.             }
  506.             if (ichComment < 0)
  507.                 break;
  508.         }
  509.         ichMatch = strSyn.indexOf(strTerm, ichMatch + strTerm.length);
  510.     }
  511.     return ichMatch;
  512. }
  513.  
  514. function isalnum(ch)
  515. {
  516.     return ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9') || (ch == '_'));
  517. }
  518.  
  519. function showTip(link)
  520. {
  521.     bodyOnClick();
  522.  
  523.     var tip = document.all.reftip;
  524.     if (!tip || !link)
  525.         return;
  526.  
  527.     window.event.returnValue = false;
  528.     window.event.cancelBubble = true;
  529.  
  530.     // Hide the tip if necessary and initialize its size.
  531.     tip.style.visibility = "hidden";
  532.     tip.style.pixelWidth = 260;
  533.     tip.style.pixelHeight = 24;
  534.  
  535.     // Find the link target.
  536.     var term = null;
  537.     var def = null;
  538.     var DLs = document.all.tags("DL");
  539.     for (var iDL = 0; iDL < DLs.length; iDL++) {
  540.         if (DLs[iDL].sourceIndex > link.sourceIndex) {
  541.             var dl = DLs[iDL];
  542.             var iMax = dl.children.length - 1;
  543.             for (var iElem = 0; iElem < iMax; iElem++) {
  544.                 var dt = dl.children[iElem];
  545.                 if (dt.tagName == "DT" && dt.style.display != "none") {
  546.                     if (findTerm(dt.innerText, 0, link.innerText) >= 0) {
  547.                         var dd = dl.children[iElem + 1];
  548.                         if (dd.tagName == "DD") {
  549.                             term = dt;
  550.                             def = dd;
  551.                         }
  552.                         break;
  553.                     }
  554.                 }
  555.             }
  556.             break;
  557.         }
  558.     }
  559.  
  560.     if (def) {
  561.         window.linkElement = link;
  562.         window.linkTarget = term;
  563.         tip.innerHTML = '<DL><DT>' + term.innerHTML + '</DT><DD>' + def.innerHTML + '</DD></DL>';
  564.         window.setTimeout("moveTip()", 0);
  565.     }
  566. }
  567.  
  568. function jumpParam()
  569. {
  570.     hideTip();
  571.  
  572.     window.linkTarget.scrollIntoView();
  573.     document.body.scrollLeft = 0;
  574.  
  575.     flash(3);
  576. }
  577.  
  578. function flash(c)
  579. {
  580.     window.linkTarget.style.background = (c & 1) ? "#FFFF80" : "";
  581.     if (c)
  582.         window.setTimeout("flash(" + (c-1) + ")", 200);
  583. }
  584.  
  585. function moveTip()
  586. {
  587.     var tip = document.all.reftip;
  588.     var link = window.linkElement;
  589.     if (!tip || !link)
  590.         return; //error
  591.  
  592.     var w = tip.offsetWidth;
  593.     var h = tip.offsetHeight;
  594.  
  595.     if (w > tip.style.pixelWidth) {
  596.         tip.style.pixelWidth = w;
  597.         window.setTimeout("moveTip()", 0);
  598.         return;
  599.     }
  600.  
  601.     var maxw = document.body.clientWidth;
  602.     var maxh = document.body.clientHeight;
  603.  
  604.     if (h > maxh) {
  605.         if (w < maxw) {
  606.             w = w * 3 / 2;
  607.             tip.style.pixelWidth = (w < maxw) ? w : maxw;
  608.             window.setTimeout("moveTip()", 0);
  609.             return;
  610.         }
  611.     }
  612.  
  613.     var x,y;
  614.  
  615.     var linkLeft = link.offsetLeft - document.body.scrollLeft;
  616.     var linkRight = linkLeft + link.offsetWidth;
  617.  
  618.     var linkTop = link.offsetTop - document.body.scrollTop;
  619.     var linkBottom = linkTop + link.offsetHeight;
  620.  
  621.     var cxMin = link.offsetWidth - 24;
  622.     if (cxMin < 16)
  623.         cxMin = 16;
  624.  
  625.     if (linkLeft + cxMin + w <= maxw) {
  626.         x = maxw - w;
  627.         if (x > linkRight + 8)
  628.             x = linkRight + 8;
  629.         y = maxh - h;
  630.         if (y > linkTop)
  631.             y = linkTop;
  632.     }
  633.     else if (linkBottom + h <= maxh) {
  634.         x = maxw - w;
  635.         if (x < 0)
  636.             x = 0;
  637.         y = linkBottom;
  638.     }
  639.     else if (w <= linkRight - cxMin) {
  640.         x = linkLeft - w - 8;
  641.         if (x < 0)
  642.             x = 0;
  643.         y = maxh - h;
  644.         if (y > linkTop)
  645.             y = linkTop;
  646.     }
  647.     else if (h <= linkTop) {
  648.         x = maxw - w;
  649.         if (x < 0)
  650.             x = 0;
  651.         y = linkTop - h;
  652.     }
  653.     else if (w >= maxw) {
  654.         x = 0;
  655.         y = linkBottom;
  656.     }
  657.     else {
  658.         w = w * 3 / 2;
  659.         tip.style.pixelWidth = (w < maxw) ? w : maxw;
  660.         window.setTimeout("moveTip()", 0);
  661.         return;
  662.     }
  663.     
  664.     link.style.background = "#FFFF80";
  665.     tip.style.pixelLeft = x + document.body.scrollLeft;
  666.     tip.style.pixelTop = y + document.body.scrollTop;
  667.     tip.style.visibility = "visible";
  668. }
  669.  
  670. function hideTip()
  671. {
  672.     if (window.linkElement) {
  673.         window.linkElement.style.background = "";
  674.         window.linkElement = null;
  675.     }
  676.  
  677.     var tip = document.all.reftip;
  678.     if (tip) {
  679.         tip.style.visibility = "hidden";
  680.         tip.innerHTML = "";
  681.     }
  682. }
  683.  
  684. function beginsWith(s1, s2)
  685. {
  686.     // Does s1 begin with s2?
  687.     return s1.substring(0, s2.length) == s2;
  688. }
  689.  
  690. //
  691. // See Also popups
  692. //
  693. function initSeeAlso()
  694. {
  695.     // Localizable strings.
  696.     var L_See_Also = "Se Även";
  697.     var L_Requirements = "Krav";
  698.     var L_QuickInfo = "QuickInfo";
  699.  
  700.     var hdr = document.all.hdr;
  701.     if (!hdr)
  702.         return;
  703.  
  704.     var divS = new String;
  705.     var divR = new String;
  706.  
  707.     var heads = document.all.tags("H4");
  708.     if (heads) {
  709.         for (var i = 0; i < heads.length; i++) {
  710.             var head = heads[i];
  711.             var txt = head.innerText;
  712.             if (beginsWith(txt, L_See_Also)) {
  713.                 divS += head.outerHTML;
  714.                 var next = getNext(head);
  715.                 while (next && !next.tagName.match(/^(H[1-4])|(DIV)$/)) {
  716.                     divS += next.outerHTML;
  717.                     next = getNext(next);
  718.                 }
  719.             }
  720.             else if (beginsWith(txt, L_Requirements) || beginsWith(txt, L_QuickInfo)) {
  721.                 divR += head.outerHTML;
  722.                 var next = getNext(head);
  723.                 while (next && !next.tagName.match(/^(H[1-4])|(DIV)$/)) {
  724.                     divR += next.outerHTML;
  725.                     next = getNext(next);
  726.                 }
  727.             }
  728.         }
  729.     }
  730.  
  731.     var pos = getNext(hdr.parentElement);
  732.     if (pos) {
  733.         if (divR != "") {
  734.             divR = '<DIV ID=rpop CLASS=sapop>' + divR + '</DIV>';
  735.             var td = hdr.insertCell(0);
  736.             if (td) {
  737.                 td.className = "button1";
  738.                 td.style.width = "19px";
  739.                 td.onclick = showRequirements;
  740.                 td.innerHTML = '<IMG SRC="' + baseUrl + 'Requirements.gif' + '" ALT="' + L_Requirements + '" BORDER=0>';
  741.                 if (ie4)
  742.                     document.body.insertAdjacentHTML('AfterBegin', divR);
  743.                 else
  744.                     document.body.insertAdjacentHTML('BeforeEnd', divR);
  745.             }
  746.         }
  747.         if (divS != "") {
  748.             divS = '<DIV ID=sapop CLASS=sapop>' + divS + '</DIV>';
  749.             var td = hdr.insertCell(0);
  750.             if (td) {
  751.                 td.className = "button1";
  752.                 td.style.width = "19px";
  753.                 td.onclick = showSeeAlso;
  754.                 td.innerHTML = '<IMG SRC="' + baseUrl + 'SeeAlso.gif' + '" ALT="' + L_See_Also + '" BORDER=0>';
  755.                 if (ie4)
  756.                     document.body.insertAdjacentHTML('AfterBegin', divS);
  757.                 else
  758.                     document.body.insertAdjacentHTML('BeforeEnd', divS);
  759.             }
  760.         }
  761.     }
  762. }
  763.  
  764. function showSeeAlso()
  765. {
  766.     bodyOnClick();
  767.  
  768.     window.event.returnValue = false;
  769.     window.event.cancelBubble = true;
  770.  
  771.     var div = document.all.sapop;
  772.     var lnk = window.event.srcElement;
  773.  
  774.     if (div && lnk) {
  775.         div.style.pixelTop = lnk.offsetTop + lnk.offsetHeight;
  776.         div.style.visibility = "visible";
  777.     }
  778. }
  779.  
  780. function showRequirements()
  781. {
  782.     bodyOnClick();
  783.  
  784.     window.event.returnValue = false;
  785.     window.event.cancelBubble = true;
  786.  
  787.     var div = document.all.rpop;
  788.     var lnk = window.event.srcElement;
  789.  
  790.     if (div && lnk) {
  791.         div.style.pixelTop = lnk.offsetTop + lnk.offsetHeight;
  792.         div.style.visibility = "visible";
  793.     }
  794. }
  795.  
  796. function hideSeeAlso()
  797. {
  798.     var div = document.all.sapop;
  799.     if (div)
  800.         div.style.visibility = "hidden";
  801.  
  802.     var div = document.all.rpop;
  803.     if (div)
  804.         div.style.visibility = "hidden";
  805. }
  806.