home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 September / PCWorld_2008-09_cd.bin / system / diskche / diskcheckup.exe / HELP / diskcheckup_navigation.js < prev    next >
Text File  |  2007-10-30  |  7KB  |  167 lines

  1. /* ---------------- Script ⌐ 2005-2007 EC Software -----------------
  2.    This script was created by Help & Manual and is part of the      
  3.    "Browser-based Help" export format. This script is designed for  
  4.    use in combination with the output of Help & Manual and must not 
  5.    be used outside this context.     http://www.helpandmanual.com   
  6.                                                                     
  7.    Do not modify this file! It will be overwritten by Help & Manual.
  8. ----------------------------------------------------------------- */
  9.  
  10. var usecookie = false;
  11. var tocselecting = false;
  12. var currentselection;
  13. var autocollapse = false;
  14. var treestate = "";  
  15.  
  16. function fullexpand() { switchall(true); }
  17. function fullcollapse() { switchall(false); }
  18.  
  19. function levelexpand(divID) {
  20.     var div = hmnavigation.document.getElementById(divID).firstChild;
  21.     while (div) {
  22.        switchdiv(div, div.id, true);
  23.        div = div.nextSibling;
  24.     }
  25. }
  26.  
  27. function switchall(divvisible) {
  28.     var tree = hmnavigation.document.getElementById("tree");
  29.     if (tree) {
  30.        var items = tree.getElementsByTagName("div");
  31.        for(var i = 0; i < items.length; i++) if (divvisible != ((items[i].style.display=="block")?true:false)) switchdiv(items[i], items[i].id, divvisible);
  32.        if ((divvisible) && (currentselection)) intoview(currentselection, tree, false);
  33.     }
  34. }
  35.  
  36. function loadstate(tree) {
  37.     var divID;
  38.     if ((treestate=="") && (usecookie)) treestate = document.cookie;
  39.     
  40.     while (treestate != "") {
  41.        divID = treestate.substring(0,treestate.indexOf(","));
  42.        treestate = treestate.substring(divID.length+1,treestate.length);
  43.        toggle(divID);
  44.     }
  45.     var topicID = hmcontent.location.href.substring(hmcontent.location.href.lastIndexOf("/")+1,hmcontent.location.href.length);
  46.     if (topicID.lastIndexOf("#") != -1) topicID = topicID.substring(0,topicID.lastIndexOf("#"));
  47.     if (topicID.lastIndexOf("?") != -1) topicID = topicID.substring(0,topicID.lastIndexOf("?"));
  48.     tocselecting = false;
  49.     currentselection = null;
  50.     lazysync(topicID);
  51. }
  52.  
  53. function savestate(tree) {
  54.     treestate = "";
  55.     var items = tree.getElementsByTagName("div");
  56.     for(var i = 0; i < items.length; i++) if (items[i].style.display=="block") treestate = treestate.concat(items[i].id + ",");
  57.     if (usecookie) document.cookie = treestate;
  58. }
  59.  
  60. function toggle(divID) {
  61.     var thisdiv = hmnavigation.document.getElementById(divID);
  62.     if (thisdiv) switchdiv(thisdiv, divID, ((thisdiv.style.display=="none")?true:false));
  63. }
  64.  
  65. function switchdiv(thisdiv, divID, divvisible) {
  66.     var thisicon = hmnavigation.document.getElementById("i"+divID.substring(3,divID.length));
  67.     var icons = "";
  68.     if (thisicon) icons = thisicon.getAttribute("name");
  69.     if (divvisible) {
  70.        thisdiv.style.display="block";
  71.        if (thisicon) thisicon.src = icons.substring(icons.lastIndexOf(":")+1, icons.length);
  72.     }
  73.     else {
  74.        thisdiv.style.display="none";
  75.        if (thisicon) thisicon.src = icons.substring(0, icons.lastIndexOf(":"));
  76.     }
  77. }
  78.  
  79. function hilightexpand(spanID, divID) {
  80.     hilight(spanID);
  81.     var thisdiv = hmnavigation.document.getElementById(divID);
  82.     if (thisdiv) switchdiv(thisdiv, divID, true);
  83. }
  84.  
  85. function hilight(spanID) {
  86.     tocselecting = true;
  87.     var thisnode = null;
  88.     var selectionchanged = false;
  89.     thisnode = hmnavigation.document.getElementById(spanID);
  90.     if (thisnode) {
  91.        try {
  92.           if ((currentselection) && (currentselection != thisnode)) currentselection.className = "heading" + currentselection.className.substr(7,1);
  93.        }
  94.        catch(e){}
  95.        thisnode.className = "hilight"+thisnode.className.substr(7,1);
  96.        selectionchanged = (currentselection != thisnode);
  97.        currentselection = thisnode;
  98.     }
  99.     return selectionchanged;
  100. }
  101.  
  102. function intoview(thisnode, tree, selectionchanged) {
  103.     var thisparent = thisnode;
  104.     while (thisparent != tree) {
  105.        if ((selectionchanged) && (thisparent.nodeName.toLowerCase()=="div")) switchdiv(thisparent,thisparent.id,true);
  106.        thisparent = thisparent.parentNode;
  107.     }
  108.     thisparent = thisnode;
  109.     for (var t=0; thisparent!=null; t+=thisparent.offsetTop, thisparent=thisparent.offsetParent);
  110.     var bt = (hmnavigation.window.pageYOffset)?hmnavigation.window.pageYOffset:hmnavigation.document.body.scrollTop;
  111.     var bh = (hmnavigation.window.innerHeight)?hmnavigation.window.innerHeight:hmnavigation.document.body.offsetHeight;
  112.     if ((t+thisnode.offsetHeight-bt) > bh) hmnavigation.window.scrollTo(0,(t+24-bh))
  113.     else if (t < bt) hmnavigation.window.scrollTo(0,t);              
  114. }
  115.  
  116. function collapseunfocused(tree, selectedID) {
  117.     if (tree) {
  118.        var nodepath = "div"+selectedID.substring(1,selectedID.length);
  119.        var items = tree.getElementsByTagName("div");
  120.        for (var i = 0; i < items.length; i++) {
  121.           if (nodepath.lastIndexOf(items[i].id)<0) { switchdiv(items[i], items[i].id, false); }
  122.        }
  123.     }
  124. }
  125.  
  126. function quicksync(aID) {
  127.     if (aID != "") {
  128.        var tree = hmnavigation.document.getElementById("tree");
  129.        if ((tree) && (!tocselecting)) {
  130.           var thisspan = hmnavigation.document.getElementById(aID);
  131.           if (thisspan) {
  132.              var selectionchanged = hilight("s"+aID.substring(1,aID.length));
  133.              intoview(thisspan, tree, selectionchanged);
  134.           }
  135.        }
  136.        if (autocollapse) collapseunfocused(tree, aID);
  137.     }
  138.     tocselecting = false;
  139. }
  140.  
  141. function lazysync(topicID) {
  142.     if (topicID != "") {
  143.        var tree = hmnavigation.document.getElementById("tree");
  144.        if ((tree) && (!tocselecting)) {
  145.           var array = new Array(0);
  146.           var items = tree.getElementsByTagName("a");
  147.           for(var i = 0; i < items.length; i++) {
  148.              if (items[i].href.substring(items[i].href.lastIndexOf("/")+1,items[i].href.length)==topicID) {
  149.                 var selectionchanged = hilight("s"+items[i].id.substring(1,items[i].id.length));
  150.                 intoview(items[i], tree, selectionchanged);
  151.                 break;
  152.              }
  153.           }
  154.        }
  155.        if (autocollapse) collapseunfocused(tree, currentselection.id);
  156.     }
  157.     tocselecting = false;
  158. }
  159.  
  160. function preloadicons() {
  161.     var icons = new Array();
  162.     for (i=0; i<preloadicons.arguments.length; i++) {
  163.        icons[i] = new Image();
  164.        icons[i].src = preloadicons.arguments[i];
  165.     }
  166. }
  167.