home *** CD-ROM | disk | FTP | other *** search
/ BUG 14 / BUGCD1998_05.ISO / _internt / _ie4 / win31 / iecore.cab / tabs.js < prev    next >
Text File  |  1997-11-25  |  2KB  |  82 lines

  1. // Copyright (c) 1997 Microsoft Corporation. All rights reserved.
  2.  
  3. // tabs.js
  4.  
  5. var indexLocation = null;
  6. var tocLocation = null;
  7.  
  8. function GetIndexLocation(){
  9.     return indexLocation;
  10. }
  11.  
  12. function GetTocLocation(){
  13.     return tocLocation;
  14. }
  15.  
  16. function SetIndexLocation(callerWindow, location){
  17.     
  18.     indexLocation = GetDirectory(callerWindow.location.href) +
  19.                     "/" + location;
  20. }
  21.  
  22. function SetTocLocation(callerWindow, location){
  23.     tocLocation = GetDirectory(callerWindow.location.href) +
  24.                     "/" + location;
  25. }
  26.  
  27. function GetDirectory(pathname){
  28.  
  29.     // given a full url to a document,
  30.     // return the directory the document lives in
  31.     
  32.     var backPos = pathname.lastIndexOf("\\");
  33.     var forwardPos = pathname.lastIndexOf("/");
  34.     var sepPos = Math.max(backPos,forwardPos);
  35.     
  36.     if (sepPos != -1) { // a seperator was found
  37.         return pathname.substring(0,sepPos);
  38.     }
  39.     else {
  40.         return pathname;
  41.     }
  42. }
  43.  
  44. function SelectIndexTab(document){
  45.  
  46.     var tabContentsDocument = document.parentWindow.parent.frames("index_bot").document;
  47.         
  48.     SetActiveTabStyleSheet(document, "tab-index");
  49.     
  50.     if (tabContentsDocument)
  51.         tabContentsDocument.location.replace(top.GetIndexLocation());    
  52. }
  53.  
  54. function SelectContentsTab(document){
  55.  
  56.     var tabContentsDocument = document.parentWindow.parent.frames("index_bot").document;
  57.         
  58.     SetActiveTabStyleSheet(document, "tab-contents");
  59.     
  60.     if (tabContentsDocument)
  61.         tabContentsDocument.location.replace(top.GetTocLocation());
  62. }
  63.  
  64. function SetActiveTabStyleSheet(document, styleSheet){
  65.  
  66.     // disable all of the tab stylesheets
  67.     // (those that start with tab-) except for the one
  68.     // passed in
  69.     
  70.     for (var i=0; i<document.styleSheets.length; i++)
  71.         
  72.         // if the stylesheet has an id starting with options- (if it is one of ours)
  73.         if (document.styleSheets[i].id.indexOf("tab-") == 0) {
  74.             if (document.styleSheets[i].id == styleSheet){
  75.                 document.styleSheets[i].disabled = false;
  76.             }
  77.             else {
  78.                 document.styleSheets[i].disabled = true;
  79.             }
  80.         }
  81. }
  82.