/*************************************************************/
/*  Switcher JavaScript.  This script is used in conjunction */
/*  with JDK1.1+ Java Applets.  The script checks to see if  */
/*  the browser is either Netscape Navigator 4+ or Internet  */
/*  Explorer 4+.  If the browser is neither, the user is     */
/*  informed that they need one of those two browsers.  If   */
/*  they have Internet Explorer4+, it writes a standard Java */
/*  applet line that uses the default VM (the standard VM in */
/*  IE has proven to be valid).  If they are running on a    */
/*  Macintosh computer with Netscape 4.x, the script writes  */
/*  out HTML that utilizes the MRJ Plug-in.  If the Plug-in  */
/*  does not exist, it displays instructions for installing  */
/*  the plug-in.  A special case is also considered in this  */
/*  script - if they are using Netscape of a higher version  */
/*  than 4.x, it is currently assumed that those versions of */
/*  Netscape will implement JDK1.1+ as promised.             */
/*                                                           */
/*  Addendum:  A new case has been added.  If IE4.x is being */
/*  used on a Mac, a link is displayed that points the user  */
/*  to a page designed to verify that they are running MRJ.  */
/*  Also, the script checks to see if Java is enabled.       */
/*                                                           */
/*  To make use of this script, you need to call it from the */
/*  appropriate index.html page.  View the other 1.1 applets */
/*  for the template.  You need to change five values inside */
/*  of the HTML file:                                        */
/*                                                           */
/*    AppClass - this specifies the name of the class        */
/*       var AppClass = "Conversions.class";                 */
/*    AppWidth - this specifies the applet's width           */
/*       var AppWidth = "400";                               */
/*    AppHeight - this specifies the applet's height         */
/*       var AppHeight = "145";                              */
/*    Version1Dir - this specifies the directory name of     */
/*     the 1.0 verison of this applet.  For example, if the  */
/*     1.0 version of the applet is stored in the directory  */
/*     interactivate/activities/conversions, you would use   */
/*       var Version1Dir = "conversions";                    */
/*************************************************************/

  var browser = navigator.appName
  var platform= navigator.platform
  var version = parseInt(navigator.appVersion)
  var ParamLen = ParamTags.length
  
  var Nav4 = (browser=="Netscape" && version >= 4)
  var IE4  = (browser=="Microsoft Internet Explorer" && version >= 4)

  // Verify that Java is enabled.
  if ((Nav4 || IE4) && !navigator.javaEnabled())
    document.writeln("</CENTER>Java is disabled in your browser.  Please "+
	               "re-enable it in your browser's options.<P><CENTER>");

  // Check for Netscape 4.x on a Mac
  if (Nav4 && (platform=="MacPPC" || platform=="Mac68k") && version < 5)
  {
    // Determine if they have the plugin installed.
    var vmInstalled = navigator.mimeTypes["application/x-java-vm"]
    
    if (vmInstalled)
    {
	    document.writeln("<EMBED " + 
           "TYPE=\"application/x-java-vm\" " + 
           "NAME=\"Java Applet\" " +
           "PLUGINSPAGE=\"../plugin.html\" " +
           "BORDER=\"5\" " +
           "WIDTH=\""+AppWidth+"\" " +
           "HEIGHT=\""+AppHeight+"\" " + 
           "CODEBASE='.' CODE=\""+AppClass+"\" "+OtherTags)
         for (var i = 0; i < ParamLen; i += 2) {
         	document.writeln(" "+ParamTags[i]+"='"+ParamTags[i+1]+"'");
         }
         document.writeln(">");
    }
    else
    {
      document.writeln("To correctly display this activity, <BR>you need to install some software.<p>");
      document.writeln("Click <A href=\"plugin.html\">here</a> to learn how."); 

      if (Version1Dir != "") 
      	document.writeln("Or click <a href=\"../../../interactivate/activities/"+Version1Dir+"\">here</a> "+
                     "to use an older version of the activity.<p>");
    }
  }
  else if (Nav4 || IE4)
  {
    // Navigator 4+ or Internet Explorer 4+, not on a Macintosh.  Assume the
    // virtual machine works (no indication that any others do not work)
    document.writeln("<APPLET CODEBASE='.' CODE='"+AppClass+"' width="+AppWidth+" height="+
	                AppHeight+" "+OtherTags+">");
	for (var i = 0; i < ParamLen; i += 2) {
		document.writeln("<PARAM NAME="+ParamTags[i]+" VALUE=\'"+ParamTags[i+1]+"\'>");
	}
	document.writeln("</APPLET>");

    // If they are using Internet Explorer 4.x on a Macintosh, remind them
	// that they need to be using MRJ 2.x.
    if (IE4 && version < 5 && (platform=="MacPPC" || platform=="Mac68k"))
	  document.writeln("<P><BLOCKQUOTE><BLOCKQUOTE>If you experience difficulties running "+
	                 "this activity in your browser, see the Illuminations Website for advice.");
  }
  else
  {
    document.writeln("You need to have Netscape 4.0 or higher or Internet Explorer 4.0 or higher ")
  }


