
var jme = function() {

// --- public functions
return {

saveMolecule: function() {
  var jme = document.JME.jmeFile();
  document.cookie = "jme="+jme+";expires=Thu, 31 Dec 2020 00:00:00 GMT; path=/";
},

loadMolecule: function() {
  var editor = document.JME;
  if (editor.smiles().length > 0) return; // editing already started
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==" ") c = c.substring(1,c.length);
    if (c.indexOf("jme=") == 0) {
      var jme = c.substring(4,c.length);
      //alert("jme="+jme);
      editor.readMolecule(jme);
      return;
    }
  }
},

openJMEHelp: function() {
window.open("http://www.molinspiration.com/jme/help/jme2008hints.html","jmehelp","toolbar=no,menubar=no,scrollbars=yes,resizable=yes,width=510,height=675,left=400,top=20");
},

jme: function() {

var s = "\
<script>function substituent(r) {document.JME.setSubstituent(r);}</script>\
<table><tr><td valign='top'>\
<form>\
<table cellpadding=0 cellspacing=0 border=0 width=370><tr>\
<td align=left><b>NEW</b> <a href='http://molinspiration.com/jme/substituents.html' target='_new'>substituent menu in JME</a></td>\
<td align=right>\
<select onChange='substituent(options[selectedIndex].text)'>\
<option>Select substituent\
<option>-C(=O)OH\
<option>-C(=O)OMe\
<option>-OC(=O)Me\
<option>-CMe3\
<option>-CF3\
<option>-CCl3\
<option>-NO2\
<option>-SO2-NH2\
<option>-NH-SO2-Me\
<option>-PO3H2\
<option>-NMe2\
<option>-C#N\
<option>-C#C-Me\
<option>-C#CH\
</select></td></tr></table>\
<applet name='JME' code='JME.class' codebase='/classes' archive='JME.jar' width=370 height=312>\
You have to enable Java in your browser.</applet>\
<font face='helvetica,arial,sans-serif'>\
<table width=370 cellpadding=0 cellspacing=0 border=0><tr>\
<td align='left'>\
<a href='http://www.molinspiration.com/jme/'><small>JME Editor</a> courtesy of Peter Ertl, Novartis</small>\
<td>\
<td align='right'>\
<small><a href='javascript:jme.openJMEHelp();' onMouseOver=\"window.status='Show basic JME editor help'; return true;\" onMouseOut=\"window.status=''; return true;\">JME help</a></small>\
</td>\
</tr></table>\
</font>\
</form> </td><td>&nbsp;&nbsp</td><td valign='top'></td></tr></table>\
";
document.write(s);
}

};
}();

