################################################################################
##  DU_JAVA - Java-related functions for Daylight users.
##
################################################################################
### PRINT_JAVAGRINSSCRIPT
################################################################################

package DU_JAVA;

#############################################################################
### PRINT_JAVAGRINSSCRIPT - Invokes the JavaGRINS applet which can
### submit a SMILES to the "insmi" form element of the named form.
#############################################################################
sub main'PRINT_JAVAGRINSSCRIPT
{
  local($formname, $formelement) = @_;

print <<__EOF__;
<SCRIPT LANGUAGE="JavaScript">
var newWindow = null
function makeNewWindow() {
  if ((navigator.appName == "Netscape" ) && (
    navigator.appVersion.substr(0,4) > 4.01 )) {
    if (navigator.javaEnabled()) {
      newWindow = window.open("","StartingJava", "HEIGHT=330,WIDTH=350")
      var newContent="<HTML><HEAD><TITLE>JavaGrins</TITLE></HEAD>"
      newContent += "<BODY>"
      newContent += "<H3>Starting JavaGrins. Please wait.</H3>"
      newContent += "<UL><LI>Use File->GrinsToSmiles to xfr SMILES to document"
      newContent += "<LI>Use File->SmilesToGrins to xfr SMILES from document"
      newContent += "<LI>Use File->Exit this window to exit JavaGrins</UL>"
      newContent += "<APPLET CODE=\\"NetscapeApplet\\" " 
      newContent += "CODEBASE=\\"/dayhtml/java\\""
      newContent += "NAME=\\"Grins\\""
      newContent += "ARCHIVE=\\"/dayhtml/java/grins.jar\\" " 
      newContent += "ALT=\\"There is a Java Applet here."
      newContent += "To view it you need a Java1.1 enabled browser\\" " 
      newContent += "ALIGN=\\"CENTER\\" HEIGHT=104  WIDTH=104 MAYSCRIPT NAME=\\"Grins\\">"
      newContent += "<PARAM NAME=\\"ApplicationClass\\" value=\\"daylight.services.AppLoader\\">"
      newContent += "<PARAM NAME=\\"LiveConnectElement\\" value=\\"$formname.$formelement\\">"
      newContent += "<h4>There is a Java applet here."
      newContent += "To view it you need a Java1.1-enabled browser</H4>"
      newContent += "</APPLET></BODY></HTML>"
      newWindow.document.write(newContent)
      newWindow.document.close()
    }
    else {
     alert("You need to enable Java in Netscape to run JavaGrins!");
    }
  }
  else {
    alert("You need Netscape version 4.02 or higher to run JavaGrins!")
  }
}
</SCRIPT>
__EOF__
}

################################################################################

1;  ## package return value
