home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 August / 08_02.iso / software / cb5 / files / Bryce5TrialVersion.exe / data1.cab / HelpFiles / wwhelp / common / scripts / switchf.js < prev   
Encoding:
JavaScript  |  2001-07-16  |  3.4 KB  |  141 lines

  1. function  WWHelpSwitch_Object()
  2. {
  3.   var  Agent = "";
  4.   var  MajorVersion = 0;
  5.  
  6.  
  7.   // Determine browser
  8.   //
  9.   this.mBrowser = 0;  // Shorthand for Unknown
  10.  
  11.   Agent = navigator.userAgent.toLowerCase();
  12.   if ((Agent.indexOf("mozilla") != -1) &&
  13.       (Agent.indexOf("spoofer") == -1) &&
  14.       (Agent.indexOf("compatible") == -1))
  15.   {
  16.     MajorVersion = parseInt(navigator.appVersion)
  17.     if (MajorVersion >= 4)
  18.     {
  19.       this.mBrowser = 1;  // Shorthand for Netscape
  20.     }
  21.   }
  22.   else if (Agent.indexOf("msie") != -1)
  23.   {
  24.     MajorVersion = parseInt(navigator.appVersion)
  25.     if (MajorVersion >= 4)
  26.     {
  27.       this.mBrowser = 2;  // Shorthand for IE
  28.     }
  29.   }
  30.   else if (Agent.indexOf("icab") != -1)
  31.   {
  32.     this.mBrowser = 3;  // Shorthand for iCab
  33.   }
  34.  
  35.   // Determine platform
  36.   //
  37.   this.mPlatform = 0;  // Shorthand for Unknown
  38.  
  39.   if ((Agent.indexOf("win") != -1) ||
  40.       (Agent.indexOf("16bit") != -1))
  41.   {
  42.     this.mPlatform = 1;  // Shorthand for Windows
  43.   }
  44.   else if (Agent.indexOf("mac") != -1)
  45.   {
  46.     this.mPlatform = 2;  // Shorthand for Macintosh
  47.   }
  48.  
  49.   this.mbJavaEnabled = false;
  50.  
  51.   this.fForceJavaScript  = WWHelpSwitch_ForceJavaScript;
  52.   this.fCheckJavaEnabled = WWHelpSwitch_CheckJavaEnabled;
  53.   this.fGetFrameSet      = WWHelpSwitch_GetFrameSet;
  54.   this.fSwitchFrameSet   = WWHelpSwitch_SwitchFrameSet;
  55. }
  56.  
  57. function  WWHelpSwitch_CheckJavaEnabled()
  58. {
  59.   if (navigator != null)
  60.   {
  61.     this.mbJavaEnabled = navigator.javaEnabled();
  62.   }
  63.   else
  64.   {
  65.     this.mbJavaEnabled = false;
  66.   }
  67. }
  68.  
  69. function  WWHelpSwitch_GetFrameSet()
  70. {
  71.   var  WhichFrameSet = "wwhelp/js/html/frames.htm";
  72.  
  73.  
  74.   // Detect current environment and use appropriate frameset
  75.   // if JavaScript isn't forced on.
  76.   //
  77.   if (this.fForceJavaScript() == false)
  78.   {
  79.     // Check to see if Java is enabled
  80.     //
  81.     if (this.mbJavaEnabled)
  82.     {
  83.       // We'll try to run the Java version unless
  84.       // a particular platform doesn't support it.
  85.       //
  86.       if (this.mBrowser == 1)  // Shorthand for Netscape
  87.       {
  88.         if (this.mPlatform == 1)  // Shorthand for Windows
  89.         {
  90.           WhichFrameSet = "wwhelp/java/html/wwhnsfs.htm";  // Java works on NS for Windows
  91.         }
  92.         else if (this.mPlatform == 2)  // Shorthand for Macintosh
  93.         {
  94.           WhichFrameSet = "wwhelp/js/html/frames.htm";  // Java doesn't work on NS for Macintosh
  95.         }
  96.         else
  97.         {
  98.           WhichFrameSet = "wwhelp/java/html/wwhnsfs.htm";  // Java works on NS for UNIX
  99.         }
  100.       }
  101.       else  // Assume IE
  102.       {
  103.         if (this.mPlatform == 1)  // Shorthand for Windows
  104.         {
  105.           WhichFrameSet = "wwhelp/java/html/wwhiefs.htm";  // Java works on IE for Windows
  106.         }
  107.         else if (this.mPlatform == 2)  // Shorthand for Macintosh
  108.         {
  109.           WhichFrameSet = "wwhelp/java/html/wwhmacfs.htm";  // Java works on IE and iCab for Macintosh (no favorites)
  110.         }
  111.         else
  112.         {
  113.           WhichFrameSet = "wwhelp/js/html/frames.htm";  // Java doesn't work on IE for UNIX
  114.         }
  115.       }
  116.     }
  117.   }
  118.  
  119.   return WhichFrameSet;
  120. }
  121.  
  122. function  WWHelpSwitch_SwitchFrameSet()
  123. {
  124.   var  NewLocation;
  125.  
  126.  
  127.   NewLocation = this.fGetFrameSet();
  128.  
  129.   if (location.href.indexOf("?") != -1)
  130.   {
  131.     var  Parts;
  132.  
  133.  
  134.     Parts = location.href.split("?");
  135.  
  136.     NewLocation += "?" + Parts[1];
  137.   }
  138.  
  139.   location.href = NewLocation;
  140. }
  141.