<!--
// Webstart launching
// Detects if running on IE or if JAWS is installed on Netscape
// Source: http://java.sun.com/j2se/1.5.0/docs/guide/javaws/developersguide/launch.html
var javawsInstalled = 0;  
var javaws142Installed=0;
var javaws150Installed=0;
isIE = "false"; 
if (navigator.mimeTypes && navigator.mimeTypes.length) {
      x = navigator.mimeTypes['application/x-java-jnlp-file'];
      if (x) { 
          javawsInstalled = 1;
          javaws142Installed=1;
          javaws150Installed=1;
      } 
} 
else {
      isIE = "true";
} 


// Attempt to detect if JRE is installed for non-IE browsers
// NOTE: At least Mozilla 4, Firefox 1.0.6&1.5 register the x-java-jnlp-file mime type
//       so that this function may not be necessary
// NOTE: J2SE 6 will finally provide a way to do this the right way
// Source: http://developer.mozilla.org/en/docs/Gecko_Plugin_API_Reference:Plug-in_Basics#Plug-in_Detection
function checkJavaPlugin() {
  /* Displays a list of mime types registered related to java
  list="";
  for (i=0; i < navigator.mimeTypes.length; i++) {
      //if (navigator.plugins[j].type == "application/x-java-applet;version=1.3") {
      //  alert("You are running Netscape with Java Plugin 1.3.0 - OK");
      //  return;
      //};
      mime = navigator.mimeTypes[i].type;
      if (mime.indexOf("java")!=-1) list += "\n"+mime;
  }
  alert("Plugins:\n"+list);
  */

  var mimetype = navigator.mimeTypes["application/x-java-applet"];

  if (mimetype) {
   // Yes, so can we display with a plug-in?
   var plugin = mimetype.enabledPlugin;
   if (plugin) {
      // Yes, so show the data in-line
      alert("enabled");
   } else {
      // No, so provide a link to the data
      alert("disabled");
   }
  } else {
   // No, so tell them so
   alert("no plugin");
  }

}

 
// If JAWS is installed then writes link to the given JNLP URL.
// Otherwise writes a link to install a JRE first
// If JAWS is installed then returns true else returns false.
//
// appLink example: "<a href=http://www.yyy.zzz/app.jnlp>Launch the application</a>"
// (Partial) Source: http://java.sun.com/j2se/1.5.0/docs/guide/javaws/developersguide/launch.html//
function writeLink (appLink) {
    /* Note that the logic below always launches the JNLP application 
     * if the browser is Gecko based (e.g. Firefox). This is because it is not possible 
     * to detect MIME type application/x-java-jnlp-file on Gecko-based browsers.  
     */

/*
window.alert("isIE="+isIE+"\n"
  +"javawsInstalled="+javawsInstalled+"\n"
  +"javaws142Installed="+javaws142Installed+"\n"
  +"javaws150Installed="+javaws150Installed+"\n");
*/   

    /*
    :NOTE: The check for Gecko isn't necessary for Mozilla 4, Firefox 1.0.6+
    */
    if (javawsInstalled) { 
        document.write(appLink);
        return true;
    } else { // JAWS is not installed
    /* PluginBrowserCheck checks whether the client uses Internet Explorer on a Microsoft Windows 
     * platform. If so, PluginBrowserCheck sends the user to the auto-install page. 
     * If PluginBrowserCheck determines the user is not using Internet Explorer on 
     * Microsoft Windows, the user is redirected to the JRE general download 
     * page at java.sun.com.
     */
     	document.write("Web Start - click ");
        document.write("<a href=http://java.sun.com/PluginBrowserCheck?pass=http://www.anycpu.com/projects/toh/jre_auto_download.html&fail=http://java.sun.com/j2se/1.5.0/download.html>here</a> ");
        document.write("to download and install JRE 5.0 and the application.");
        return false;
    }
}
//-->
