Diff for /loncom/html/adm/jmol/Jmol.js between versions 1.2 and 1.3

version 1.2, 2005/07/05 14:11:47 version 1.3, 2007/10/11 00:42:00
Line 1 Line 1
 /* $RCSfile$  
  * $Author$  /* Jmol 11.0 script library Jmol.js (aka Jmol-11.js) 1:34 AM 3/19/2007
  * $Date$  
  * $Revision$   checkbox heirarchy -- see http://www.stolaf.edu/academics/jmol/docs/examples-11/check.htm
  *  
  * Copyright (C) 2004  The Jmol Development Team      based on:
  *   *
  * Contact: jmol-developers@lists.sf.net   * Copyright (C) 2004-2005  Miguel, Jmol Development, www.jmol.org
  *   *
  *  This library is free software; you can redistribute it and/or   * Contact: hansonr@stolaf.edu
  *  modify it under the terms of the GNU Lesser General Public   *
  *  License as published by the Free Software Foundation; either   *  This library is free software; you can redistribute it and/or
  *  version 2.1 of the License, or (at your option) any later version.   *  modify it under the terms of the GNU Lesser General Public
  *   *  License as published by the Free Software Foundation; either
  *  This library is distributed in the hope that it will be useful,   *  version 2.1 of the License, or (at your option) any later version.
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of   *
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU   *  This library is distributed in the hope that it will be useful,
  *  Lesser General Public License for more details.   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  *   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  *  You should have received a copy of the GNU Lesser General Public   *  Lesser General Public License for more details.
  *  License along with this library; if not, write to the Free Software   *
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA   *  You should have received a copy of the GNU Lesser General Public
  *  02111-1307  USA.   *  License along with this library; if not, write to the Free Software
  */   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    *  02111-1307  USA.
 // for documentation see www.jmol.org/jslibrary   */
   
 var undefined; // for IE 5 ... wherein undefined is undefined  // for documentation see www.jmol.org/jslibrary
   
 ////////////////////////////////////////////////////////////////  try{if(typeof(_jmol)!="undefined")exit()
 // Basic Scripting infrastruture  
 ////////////////////////////////////////////////////////////////  // place "?NOAPPLET" on your command line to check applet control action with a textarea
   
 function jmolInitialize(codebaseDirectory) {  // bob hanson -- jmolResize(w,h) -- resizes absolutely or by percent (w or h 0.5 means 50%)
   if (_jmol.initialized) {  // bob hanson -- jmolEvaluate -- evaluates molecular math 8:37 AM 2/23/2007
     alert("jmolInitialize() should only be called *ONCE* within a page");  // bob hanson -- jmolScriptMessage -- returns all "scriptStatus" messages 8:37 AM 2/23/2007
     return;  // bob hanson -- jmolScriptEcho -- returns all "scriptEcho" messages 8:37 AM 2/23/2007
   }  // bob hanson -- jmolScriptWait -- 11:31 AM 5/2/2006
   if (! codebaseDirectory) {  // bob hanson -- remove trailing separatorHTML in radio groups -- 12:18 PM 5/6/2006
     alert("codebaseDirectory is a required parameter to jmolInitialize");  // bob hanson -- adds support for dynamic DOM script nodes 7:04 AM 5/19/2006
     codebaseDirectory = ".";  // bob hanson -- adds try/catch for wiki - multiple code passes 7:05 AM 5/19/2006
   }  // bob hanson -- auto-initiates to defaultdir/defaultjar -- change as desired.
   if (codebaseDirectory.indexOf("http://") == 0 ||  // bob hanson -- adding save/restore orientation w/ and w/o delay 11:49 AM 5/25/2006
       codebaseDirectory.indexOf("https://") == 0)  // bob hanson -- adding AjaxJS service 11:16 AM 6/3/2006
     alert("codebaseDirectory should be directory relative,\n" +  // bob hanson -- fix for iframes not available for finding applet
   "not be an absolute URL : " + codebaseDirectory);  // bob hanson -- added applet fake ?NOAPPLET URL flag
 //  else if (codebaseDirectory.charAt(0) == '/')  // bob hanson -- added jmolSetCallback(calbackName, funcName) 3:32 PM 6/13/2006
 //    alert("codebaseDirectory should be directory relative,\n" +  // used PRIOR to jmolApplet() or jmolAppletInline()
 //  "not relative to the root of the web server : " + codebaseDirectory);  //               added 4th array element in jmolRadioGroup -- title
   _jmolSetCodebase(codebaseDirectory);  //               added <span> and id around link, checkbox, radio, menu
   _jmolOnloadResetForms();  //               fixing AJAX loads for MSIE/Opera-Mozilla incompatibility
   _jmol.initialized = true;  //            -- renamed Jmol-11.js from Jmol-new.js; JmolApplet.jar from JmolAppletProto.jar
 }  // renamed Jmol.js for Jmol 11 distribution
   //            -- modified jmolRestoreOrientation() to be immediate, no 1-second delay
 function jmolSetAppletColor(boxbgcolor, boxfgcolor, progresscolor) {  // bob hanson -- jmolScriptWait always returns a string -- 11:23 AM 9/16/2006
   _jmolInitCheck();  // bh         -- jmolCommandInput()
   _jmol.boxbgcolor = boxbgcolor;  // bh         -- jmolSetTranslation(TF) -- forces translation even if there might be message callback issues
   if (boxfgcolor)  // bh         -- minor fixes suggested by Angel
     _jmol.boxfgcolor = boxfgcolor    
   else if (boxbgcolor == "white" || boxbgcolor == "#FFFFFF")  var defaultdir = "."
     _jmol.boxfgcolor = "black";  var defaultjar = "JmolApplet.jar"
   else  
     _jmol.boxfgcolor = "white";  var undefined; // for IE 5 ... wherein undefined is undefined
   if (progresscolor)  
     _jmol.progresscolor = progresscolor;  ////////////////////////////////////////////////////////////////
   if (_jmol.debugAlert)  // Basic Scripting infrastruture
     alert(" boxbgcolor=" + _jmol.boxbgcolor +  ////////////////////////////////////////////////////////////////
           " boxfgcolor=" + _jmol.boxfgcolor +  
           " progresscolor=" + _jmol.progresscolor);  function jmolInitialize(codebaseDirectory, fileNameOrUseSignedApplet) {
 }    if (_jmol.initialized) {
       //alert("jmolInitialize() should only be called *ONCE* within a page");
 function jmolApplet(size, script, nameSuffix) {      return;
   _jmolInitCheck();    }
   _jmolApplet(size, null, script, nameSuffix);    if (! codebaseDirectory) {
 }      alert("codebaseDirectory is a required parameter to jmolInitialize");
       codebaseDirectory = ".";
 ////////////////////////////////////////////////////////////////    }
 // Basic controls  
 ////////////////////////////////////////////////////////////////    if (codebaseDirectory.indexOf("http://") == 0 ||
         codebaseDirectory.indexOf("https://") == 0)
 function jmolButton(script, label, id) {      alert("In general, an absolute URL is not recommended for codebaseDirectory.\n" +
   _jmolInitCheck();    "A directory- or docroot-relative reference is recommended.\n\n" +
   var scriptIndex = _jmolAddScript(script);    "If you need to use an absolute URL (because, for example, the JAR and data\n" +
   if (label == undefined || label == null)    "files are on another server), then insert a space before\n" +
     label = script.substring(0, 32);    "\"http\" in your URL to avoid this warning message.");
   if (id == undefined || id == null)  
     id = "jmolButton" + _jmol.buttonCount;    _jmolSetCodebase(codebaseDirectory);
   ++_jmol.buttonCount;    _jmolGetJarFilename(fileNameOrUseSignedApplet);
   var t = "<input type='button' name='" + id + "' id='" + id +    _jmolOnloadResetForms();
           "' value='" + label +    _jmol.initialized = true;
           "' onClick='_jmolClick(" + scriptIndex + _jmol.targetText +  }
           ")' onMouseover='_jmolMouseOver(" + scriptIndex +  
           ");return true' onMouseout='_jmolMouseOut()' " +  function jmolSetTranslation(TF) {
           _jmol.buttonCssText + "/>";    _jmol.params.doTranslate = ''+TF;
   if (_jmol.debugAlert)  }
     alert(t);  
   document.write(t);  function _jmolGetJarFilename(fileNameOrFlag) {
 }    _jmol.archivePath =
       (typeof(fileNameOrFlag) == "string"  ? fileNameOrFlag : (fileNameOrFlag ?  "JmolAppletSigned" : "JmolApplet") + "0.jar");
 function jmolCheckbox(scriptWhenChecked, scriptWhenUnchecked,  }
                       labelHtml, isChecked, id) {  
   _jmolInitCheck();  function jmolSetDocument(doc) {
   if (id == undefined || id == null)    _jmol.currentDocument = doc;
     id = "jmolCheckbox" + _jmol.checkboxCount;  }
   ++_jmol.checkboxCount;  
   if (scriptWhenChecked == undefined || scriptWhenChecked == null ||  function jmolSetAppletColor(boxbgcolor, boxfgcolor, progresscolor) {
       scriptWhenUnchecked == undefined || scriptWhenUnchecked == null) {    _jmolInitCheck();
     alert("jmolCheckbox requires two scripts");    _jmol.params.boxbgcolor = boxbgcolor;
     return;    if (boxfgcolor)
   }      _jmol.params.boxfgcolor = boxfgcolor
   if (labelHtml == undefined || labelHtml == null) {    else if (boxbgcolor == "white" || boxbgcolor == "#FFFFFF")
     alert("jmolCheckbox requires a label");      _jmol.params.boxfgcolor = "black";
     return;    else
   }      _jmol.params.boxfgcolor = "white";
   var indexChecked = _jmolAddScript(scriptWhenChecked);    if (progresscolor)
   var indexUnchecked = _jmolAddScript(scriptWhenUnchecked);      _jmol.params.progresscolor = progresscolor;
   var t = "<input type='checkbox' name='" + id + "' id='" + id +    if (_jmol.debugAlert)
           "' onClick='_jmolCbClick(this," +      alert(" boxbgcolor=" + _jmol.params.boxbgcolor +
           indexChecked + "," + indexUnchecked + _jmol.targetText +            " boxfgcolor=" + _jmol.params.boxfgcolor +
           ")' onMouseover='_jmolCbOver(this," + indexChecked + "," +            " progresscolor=" + _jmol.params.progresscolor);
           indexUnchecked +  }
           ");return true' onMouseout='_jmolMouseOut()' " +  
   (isChecked ? "checked " : "") + _jmol.checkboxCssText + "/>" +  function jmolApplet(size, script, nameSuffix) {
           labelHtml;    _jmolInitCheck();
   if (_jmol.debugAlert)    return _jmolApplet(size, null, script, nameSuffix);
     alert(t);  }
   document.write(t);  
 }  ////////////////////////////////////////////////////////////////
   // Basic controls
 function jmolRadioGroup(arrayOfRadioButtons, separatorHtml, groupName) {  ////////////////////////////////////////////////////////////////
   _jmolInitCheck();  
   var type = typeof arrayOfRadioButtons;  function jmolButton(script, label, id, title) {
   if (type != "object" || type == null || ! arrayOfRadioButtons.length) {    _jmolInitCheck();
     alert("invalid arrayOfRadioButtons");    if (id == undefined || id == null)
     return;      id = "jmolButton" + _jmol.buttonCount;
   }    if (label == undefined || label == null)
   if (separatorHtml == undefined || separatorHtml == null)      label = script.substring(0, 32);
     separatorHtml = "&nbsp; ";    ++_jmol.buttonCount;
   var length = arrayOfRadioButtons.length;    var scriptIndex = _jmolAddScript(script);
   var t = "";    var t = "<span id=\"span_"+id+"\""+(title ? " title =\"" + title + "\"":"")+"><input type='button' name='" + id + "' id='" + id +
   jmolStartNewRadioGroup();            "' value='" + label +
   for (var i = 0; i < length; ++i) {            "' onClick='_jmolClick(" + scriptIndex + _jmol.targetText +
     var radio = arrayOfRadioButtons[i];            ")' onMouseover='_jmolMouseOver(" + scriptIndex +
     type = typeof radio;            ");return true' onMouseout='_jmolMouseOut()' " +
     if (type == "object") {            _jmol.buttonCssText + "/></span>";
       t += _jmolRadio(radio[0], radio[1], radio[2], separatorHtml, groupName);    if (_jmol.debugAlert)
     } else {      alert(t);
       t += _jmolRadio(radio, null, null, separatorHtml, groupName);    return _jmolDocumentWrite(t);
     }  }
   }  
   if (_jmol.debugAlert)  function jmolCheckbox(scriptWhenChecked, scriptWhenUnchecked,
     alert(t);                        labelHtml, isChecked, id, title) {
   document.write(t);    _jmolInitCheck();
 }    if (id == undefined || id == null)
       id = "jmolCheckbox" + _jmol.checkboxCount;
 function jmolLink(script, text, id) {    ++_jmol.checkboxCount;
   _jmolInitCheck();    if (scriptWhenChecked == undefined || scriptWhenChecked == null ||
   if (id == undefined || id == null)        scriptWhenUnchecked == undefined || scriptWhenUnchecked == null) {
     id = "jmolLink" + _jmol.linkCount;      alert("jmolCheckbox requires two scripts");
   ++_jmol.linkCount;      return;
   var scriptIndex = _jmolAddScript(script);    }
   var t = "<a name='" + id + "' id='" + id +     if (labelHtml == undefined || labelHtml == null) {
           "' href='javascript:_jmolClick(" + scriptIndex +      alert("jmolCheckbox requires a label");
           _jmol.targetText +      return;
           ");' onMouseover='_jmolMouseOver(" + scriptIndex +    }
           ");return true;' onMouseout='_jmolMouseOut()' " +    var indexChecked = _jmolAddScript(scriptWhenChecked);
           _jmol.linkCssText + ">" + text + "</a>";    var indexUnchecked = _jmolAddScript(scriptWhenUnchecked);
   if (_jmol.debugAlert)    var eospan = "</span>"
     alert(t);    var t = "<span id=\"span_"+id+"\""+(title ? " title =\"" + title + "\"":"")+"><input type='checkbox' name='" + id + "' id='" + id +
   document.write(t);            "' onClick='_jmolCbClick(this," +
 }            indexChecked + "," + indexUnchecked + _jmol.targetText +
             ")' onMouseover='_jmolCbOver(this," + indexChecked + "," +
 function jmolMenu(arrayOfMenuItems, size, id) {            indexUnchecked +
   _jmolInitCheck();            ");return true' onMouseout='_jmolMouseOut()' " +
   if (id == undefined || id == null)    (isChecked ? "checked " : "") + _jmol.checkboxCssText + "/>"
     id = "jmolMenu" + _jmol.menuCount;    if (labelHtml.toLowerCase().indexOf("<td>")>=0) {
   ++_jmol.menuCount;   t += eospan
   var type = typeof arrayOfMenuItems;   eospan = "";
   if (type != null && type == "object" && arrayOfMenuItems.length) {    }
     var length = arrayOfMenuItems.length;    t += labelHtml +eospan;
     if (typeof size != "number" || size == 1)    if (_jmol.debugAlert)
       size = null;      alert(t);
     else if (size < 0)    return _jmolDocumentWrite(t);
       size = length;  }
     var sizeText = size ? " size='" + size + "' " : "";  
     var t = "<select name='" + id + "' id='" + id +  function jmolStartNewRadioGroup() {
             "' onChange='_jmolMenuSelected(this" +    ++_jmol.radioGroupCount;
             _jmol.targetText + ")'" +  }
             sizeText + _jmol.menuCssText + ">";  
     for (var i = 0; i < length; ++i) {  function jmolRadioGroup(arrayOfRadioButtons, separatorHtml, groupName, id, title) {
       var menuItem = arrayOfMenuItems[i];    /*
       type = typeof menuItem;  
       var script, text;      array: [radio1,radio2,radio3...]
       var isSelected = undefined;      where radioN = ["script","label",isSelected,"id","title"]
       if (type == "object" && menuItem != null) {  
         script = menuItem[0];    */
         text = menuItem[1];  
         isSelected = menuItem[2];    _jmolInitCheck();
       } else {    var type = typeof arrayOfRadioButtons;
         script = text = menuItem;    if (type != "object" || type == null || ! arrayOfRadioButtons.length) {
       }      alert("invalid arrayOfRadioButtons");
       if (text == undefined || text == null)      return;
         text = script;    }
       var scriptIndex = _jmolAddScript(script);    if (separatorHtml == undefined || separatorHtml == null)
       var selectedText = isSelected ? "' selected>" : "'>";      separatorHtml = "&nbsp; ";
       t += "<option value='" + scriptIndex + selectedText + text + "</option>";    var len = arrayOfRadioButtons.length;
     }    jmolStartNewRadioGroup();
     t += "</select>";    if (!groupName)
     if (_jmol.debugAlert)      groupName = "jmolRadioGroup" + (_jmol.radioGroupCount - 1);
       alert(t);    var t = "<span id='"+(id ? id : groupName)+"'>";
     document.write(t);    for (var i = 0; i < len; ++i) {
   }      if (i == len - 1)
 }        separatorHtml = "";
       var radio = arrayOfRadioButtons[i];
 function jmolHtml(html) {      type = typeof radio;
   document.write(html);      if (type == "object") {
 }        t += _jmolRadio(radio[0], radio[1], radio[2], separatorHtml, groupName, (radio.length > 3 ? radio[3]: (id ? id : groupName)+"_"+i), (radio.length > 4 ? radio[4] : 0), title);
       } else {
 function jmolBr() {        t += _jmolRadio(radio, null, null, separatorHtml, groupName, (id ? id : groupName)+"_"+i, title);
   document.write("<br />");      }
 }    }
     t+="</span>"
 ////////////////////////////////////////////////////////////////    if (_jmol.debugAlert)
 // advanced scripting functions      alert(t);
 ////////////////////////////////////////////////////////////////    return _jmolDocumentWrite(t);
   }
 function jmolDebugAlert(enableAlerts) {  
   _jmol.debugAlert = (enableAlerts == undefined || enableAlerts)  
 }  function jmolRadio(script, labelHtml, isChecked, separatorHtml, groupName, id, title) {
     _jmolInitCheck();
 function jmolAppletInline(size, inlineModel, script, nameSuffix) {    if (_jmol.radioGroupCount == 0)
   _jmolApplet(size, _jmolConvertInline(inlineModel), script, nameSuffix);      ++_jmol.radioGroupCount;
 }    var t = _jmolRadio(script, labelHtml, isChecked, separatorHtml, groupName, (id ? id : groupName + "_" + _jmol.radioCount), title ? title : 0);
     if (_jmol.debugAlert)
 function jmolSetTarget(targetSuffix) {      alert(t);
   _jmol.targetSuffix = targetSuffix;    return _jmolDocumentWrite(t);
   _jmol.targetText = targetSuffix ? ",\"" + targetSuffix + "\"" : "";  }
 }  
   function jmolLink(script, label, id, title) {
 function jmolScript(script, targetSuffix) {    _jmolInitCheck();
   if (script) {    if (id == undefined || id == null)
     _jmolCheckBrowser();      id = "jmolLink" + _jmol.linkCount;
     var target = "jmolApplet" + (targetSuffix ? targetSuffix : "0");    if (label == undefined || label == null)
     var applet = _jmolFindApplet(target);      label = script.substring(0, 32);
     if (applet)    ++_jmol.linkCount;
       return applet.script(script);    var scriptIndex = _jmolAddScript(script);
     else    var t = "<span id=\"span_"+id+"\""+(title ? " title =\"" + title + "\"":"")+"><a name='" + id + "' id='" + id +
       alert("could not find applet " + target);            "' href='javascript:_jmolClick(" + scriptIndex + _jmol.targetText + ");' onMouseover='_jmolMouseOver(" + scriptIndex +
   }            ");return true;' onMouseout='_jmolMouseOut()' " +
 }            _jmol.linkCssText + ">" + label + "</a></span>";
     if (_jmol.debugAlert)
 function jmolLoadInline(model, targetSuffix) {      alert(t);
   if (model) {    return _jmolDocumentWrite(t);
     var target = "jmolApplet" + (targetSuffix ? targetSuffix : "0");  }
 //    while (! _jmol.ready[target])  
 //      alert("The Jmol applet " + target + " is not loaded yet");  function jmolCommandInput(label, size, id, title) {
 //    if (! _jmol.ready[target])    _jmolInitCheck();
 //      alert("The Jmol applet " + target + " is not loaded yet");    if (id == undefined || id == null)
 //    if (document.applets[target] && ! document.applets[target].isActive())      id = "jmolCmd" + _jmol.cmdCount;
 //       alert("The Jmol applet " + target + " is not yet active");    if (label == undefined || label == null)
 //    else {      label = "Execute";
       var applet = _jmolFindApplet(target);    if (size == undefined || isNaN(size))
       if (applet)      size = 60;
         return applet.loadInline(model);    ++_jmol.cmdCount;
       else    var t = "<span id=\"span_"+id+"\""+(title ? " title =\"" + title + "\"":"")+"><input name='" + id + "' id='" + id +
         alert("could not find applet " + target);            "' size='"+size+"'><input type=button value = '"+label+"' onClick='jmolScript(document.getElementById(\""+id+"\").value" + _jmol.targetText + ")'/></span>";
 //    }    if (_jmol.debugAlert)
   }      alert(t);
 }    return _jmolDocumentWrite(t);
   }
 function jmolStartNewRadioGroup() {  
   ++_jmol.radioGroupCount;  function jmolMenu(arrayOfMenuItems, size, id, title) {
 }    _jmolInitCheck();
     if (id == undefined || id == null)
 function jmolRadio(script, labelHtml, isChecked, separatorHtml, groupName) {      id = "jmolMenu" + _jmol.menuCount;
   _jmolInitCheck();    ++_jmol.menuCount;
   if (_jmol.radioGroupCount == 0)    var type = typeof arrayOfMenuItems;
     ++_jmol.radioGroupCount;    if (type != null && type == "object" && arrayOfMenuItems.length) {
   var t = _jmolRadio(script, labelHtml, isChecked, separatorHtml, groupName);      var len = arrayOfMenuItems.length;
   if (_jmol.debugAlert)      if (typeof size != "number" || size == 1)
     alert(t);        size = null;
   document.write(t);      else if (size < 0)
 }        size = len;
       var sizeText = size ? " size='" + size + "' " : "";
 function jmolCheckBrowser(action, urlOrMessage, nowOrLater) {      var t = "<span id=\"span_"+id+"\""+(title ? " title =\"" + title + "\"":"")+"><select name='" + id + "' id='" + id +
   if (typeof action == "string") {              "' onChange='_jmolMenuSelected(this" + _jmol.targetText + ")'" +
     action = action.toLowerCase();              sizeText + _jmol.menuCssText + ">";
     if (action != "alert" && action != "redirect" && action != "popup")      for (var i = 0; i < len; ++i) {
       action = null;        var menuItem = arrayOfMenuItems[i];
   }        type = typeof menuItem;
   if (typeof action != "string")        var script, text;
     alert("jmolCheckBrowser(action, urlOrMessage, nowOrLater)\n\n" +        var isSelected = undefined;
           "action must be 'alert', 'redirect', or 'popup'");        if (type == "object" && menuItem != null) {
   else {          script = menuItem[0];
     if (typeof urlOrMessage != "string")          text = menuItem[1];
       alert("jmolCheckBrowser(action, urlOrMessage, nowOrLater)\n\n" +          isSelected = menuItem[2];
             "urlOrMessage must be a string");        } else {
     else {          script = text = menuItem;
       _jmol.checkBrowserAction = action;        }
       _jmol.checkBrowserUrlOrMessage = urlOrMessage;        if (text == undefined || text == null)
     }          text = script;
   }    if (script=="#optgroup") {
   if (typeof nowOrLater == "string" && nowOrLater.toLowerCase() == "now")          t += "<optgroup label='" + text + "'>";  
     _jmolCheckBrowser();    } else if (script=="#optgroupEnd") {
 }          t += "</optgroup>";  
     } else {
 ////////////////////////////////////////////////////////////////          var scriptIndex = _jmolAddScript(script);
 // Cascading Style Sheet Class support          var selectedText = isSelected ? "' selected>" : "'>";
 ////////////////////////////////////////////////////////////////          t += "<option value='" + scriptIndex + selectedText + text + "</option>";
     }
 function jmolSetAppletCssClass(appletCssClass) {      }
   if (_jmol.hasGetElementById) {      t += "</select></span>";
     _jmol.appletCssClass = appletCssClass;      if (_jmol.debugAlert)
     _jmol.appletCssText = appletCssClass ? "class='" + appletCssClass + "' " : "";        alert(t);
   }      return _jmolDocumentWrite(t);
 }    }
   }
 function jmolSetButtonCssClass(buttonCssClass) {  
   if (_jmol.hasGetElementById) {  function jmolHtml(html) {
     _jmol.buttonCssClass = buttonCssClass;    return _jmolDocumentWrite(html);
     _jmol.buttonCssText = buttonCssClass ? "class='" + buttonCssClass + "' " : "";  }
   }  
 }  function jmolBr() {
     return _jmolDocumentWrite("<br />");
 function jmolSetCheckboxCssClass(checkboxCssClass) {  }
   if (_jmol.hasGetElementById) {  
     _jmol.checkboxCssClass = checkboxCssClass;  ////////////////////////////////////////////////////////////////
     _jmol.checkboxCssText = checkboxCssClass ? "class='" + checkboxCssClass + "' " : "";  // advanced scripting functions
   }  ////////////////////////////////////////////////////////////////
 }  
   function jmolDebugAlert(enableAlerts) {
 function jmolSetRadioCssClass(radioCssClass) {    _jmol.debugAlert = (enableAlerts == undefined || enableAlerts)
   if (_jmol.hasGetElementById) {  }
     _jmol.radioCssClass = radioCssClass;  
     _jmol.radioCssText = radioCssClass ? "class='" + radioCssClass + "' " : "";  function jmolAppletInline(size, inlineModel, script, nameSuffix) {
   }    _jmolInitCheck();
 }    return _jmolApplet(size, _jmolSterilizeInline(inlineModel),
                        script, nameSuffix);
 function jmolSetLinkCssClass(linkCssClass) {  }
   if (_jmol.hasGetElementById) {  
     _jmol.linkCssClass = linkCssClass;  function jmolSetTarget(targetSuffix) {
     _jmol.linkCssText = linkCssClass ? "class='" + linkCssClass + "' " : "";    _jmol.targetSuffix = targetSuffix;
   }    _jmol.targetText = targetSuffix ? ",\"" + targetSuffix + "\"" : "";
 }  }
   
 function jmolSetMenuCssClass(menuCssClass) {  function jmolScript(script, targetSuffix) {
   if (_jmol.hasGetElementById) {    if (script) {
     _jmol.menuCssClass = menuCssClass;      _jmolCheckBrowser();
     _jmol.menuCssText = menuCssClass ? "class='" + menuCssClass + "' " : "";      if (targetSuffix == "all") {
   }        with (_jmol) {
 }   for (var i = 0; i < appletSuffixes.length; ++i) {
     var applet = _jmolGetApplet(appletSuffixes[i]);
 ////////////////////////////////////////////////////////////////            if (applet) applet.script(script);
 // functions for INTERNAL USE ONLY which are subject to change          }
 // use at your own risk ... you have been WARNED!        }
 ////////////////////////////////////////////////////////////////      } else {
         var applet=_jmolGetApplet(targetSuffix);
 var _jmol = {        if (applet) applet.script(script);
       }
 debugAlert: false,    }
 bgcolor: "black",  }
 progresscolor: "blue",  
 boxbgcolor: "black",  function jmolLoadInline(model, targetSuffix) {
 boxfgcolor: "white",    if (!model)return
 boxmessage: "Downloading JmolApplet ...",    var applet=_jmolGetApplet(targetSuffix);
     if (applet)applet.loadInline(model);
 codebase: ".",  }
 modelbase: ".",  
   function jmolLoadInlineScript(model, script, targetSuffix) {
 appletCount: 0,    if (!model)return
     var applet=_jmolGetApplet(targetSuffix);
 buttonCount: 0,    if (applet)applet.loadInline(model, script);
 checkboxCount: 0,  }
 linkCount: 0,  
 menuCount: 0,  function jmolLoadInlineArray(ModelArray, script, targetSuffix) {
 radioCount: 0,    if (!model)return
 radioGroupCount: 0,    if (!script)script=""
     var applet=_jmolGetApplet(targetSuffix);
 appletCssClass: null,    if (applet)applet.loadInlineArray(ModelArray, script);
 appletCssText: "",  }
 buttonCssClass: null,  
 buttonCssText: "",  function jmolCheckBrowser(action, urlOrMessage, nowOrLater) {
 checkboxCssClass: null,    if (typeof action == "string") {
 checkboxCssText: "",      action = action.toLowerCase();
 radioCssClass: null,      if (action != "alert" && action != "redirect" && action != "popup")
 radioCssText: "",        action = null;
 linkCssClass: null,    }
 linkCssText: "",    if (typeof action != "string")
 menuCssClass: null,      alert("jmolCheckBrowser(action, urlOrMessage, nowOrLater)\n\n" +
 menuCssText: "",            "action must be 'alert', 'redirect', or 'popup'");
     else {
 targetSuffix: 0,      if (typeof urlOrMessage != "string")
 targetText: "",        alert("jmolCheckBrowser(action, urlOrMessage, nowOrLater)\n\n" +
 scripts: [""],              "urlOrMessage must be a string");
       else {
 ua: navigator.userAgent.toLowerCase(),        _jmol.checkBrowserAction = action;
 uaVersion: parseFloat(navigator.appVersion),        _jmol.checkBrowserUrlOrMessage = urlOrMessage;
       }
 os: "unknown",    }
 browser: "unknown",    if (typeof nowOrLater == "string" && nowOrLater.toLowerCase() == "now")
 browserVersion: 0,      _jmolCheckBrowser();
 hasGetElementById: !!document.getElementById,  }
 isJavaEnabled: navigator.javaEnabled(),  
 isNetscape47Win: false,  ////////////////////////////////////////////////////////////////
   // Cascading Style Sheet Class support
 isBrowserCompliant: false,  ////////////////////////////////////////////////////////////////
 isJavaCompliant: false,  
 isFullyCompliant: false,  function jmolSetAppletCssClass(appletCssClass) {
     if (_jmol.hasGetElementById) {
 initialized: false,      _jmol.appletCssClass = appletCssClass;
 initChecked: false,      _jmol.appletCssText = appletCssClass ? "class='" + appletCssClass + "' " : "";
     }
 browserChecked: false,  }
 checkBrowserAction: "alert",  
 checkBrowserUrlOrMessage: null,  function jmolSetButtonCssClass(buttonCssClass) {
     if (_jmol.hasGetElementById) {
 previousOnloadHandler: null,      _jmol.buttonCssClass = buttonCssClass;
 ready: {}      _jmol.buttonCssText = buttonCssClass ? "class='" + buttonCssClass + "' " : "";
 }    }
   }
 with (_jmol) {  
   function _jmolTestUA(candidate) {  function jmolSetCheckboxCssClass(checkboxCssClass) {
     var ua = _jmol.ua;    if (_jmol.hasGetElementById) {
     var index = ua.indexOf(candidate);      _jmol.checkboxCssClass = checkboxCssClass;
     if (index < 0)      _jmol.checkboxCssText = checkboxCssClass ? "class='" + checkboxCssClass + "' " : "";
       return false;    }
     _jmol.browser = candidate;  }
     _jmol.browserVersion = parseFloat(ua.substring(index + candidate.length+1));  
     return true;  function jmolSetRadioCssClass(radioCssClass) {
   }    if (_jmol.hasGetElementById) {
         _jmol.radioCssClass = radioCssClass;
   function _jmolTestOS(candidate) {      _jmol.radioCssText = radioCssClass ? "class='" + radioCssClass + "' " : "";
     if (_jmol.ua.indexOf(candidate) < 0)    }
       return false;  }
     _jmol.os = candidate;  
     return true;  function jmolSetLinkCssClass(linkCssClass) {
   }    if (_jmol.hasGetElementById) {
         _jmol.linkCssClass = linkCssClass;
   _jmolTestUA("konqueror") ||      _jmol.linkCssText = linkCssClass ? "class='" + linkCssClass + "' " : "";
   _jmolTestUA("safari") ||    }
   _jmolTestUA("omniweb") ||  }
   _jmolTestUA("opera") ||  
   _jmolTestUA("webtv") ||  function jmolSetMenuCssClass(menuCssClass) {
   _jmolTestUA("icab") ||    if (_jmol.hasGetElementById) {
   _jmolTestUA("msie") ||      _jmol.menuCssClass = menuCssClass;
   (_jmol.ua.indexOf("compatible") < 0 && _jmolTestUA("mozilla"));      _jmol.menuCssText = menuCssClass ? "class='" + menuCssClass + "' " : "";
       }
   _jmolTestOS("linux") ||  }
   _jmolTestOS("unix") ||  
   _jmolTestOS("mac") ||  ////////////////////////////////////////////////////////////////
   _jmolTestOS("win");  // functions for INTERNAL USE ONLY which are subject to change
   // use at your own risk ... you have been WARNED!
   isNetscape47Win = (os == "win" && browser == "mozilla" &&  ////////////////////////////////////////////////////////////////
                      browserVersion >= 4.78 && browserVersion <= 4.8);  var _jmol = {
     currentDocument: document,
   if (os == "win") {  
     isBrowserCompliant = hasGetElementById || isNetscape47Win;    debugAlert: false,
   } else if (os == "mac") { // mac is the problem child :-(   
     if (browser == "mozilla" && browserVersion >= 5) {    codebase: ".",
       // miguel 2004 11 17    modelbase: ".",
       // checking the plugins array does not work because   
       // Netscape 7.2 OS X still has Java 1.3.1 listed even though    appletCount: 0,
       // javaplugin.sf.net is installed to upgrade to 1.4.2    appletSuffixes: [],
       eval("try {var v = java.lang.System.getProperty('java.version');" +   
            " _jmol.isBrowserCompliant = v >= '1.4.2';" +    buttonCount: 0,
            " } catch (e) { }");    checkboxCount: 0,
     } else if (browser == "opera" && browserVersion <= 7.54) {    linkCount: 0,
       isBrowserCompliant = false;    cmdCount: 0,
     } else {    menuCount: 0,
       isBrowserCompliant = hasGetElementById &&    radioCount: 0,
         !((browser == "msie") ||    radioGroupCount: 0,
           (browser == "safari" && browserVersion < 125.1));   
     }    appletCssClass: null,
   } else if (os == "linux" || os == "unix") {    appletCssText: "",
     if (browser == "konqueror" && browserVersion <= 3.3)    buttonCssClass: null,
       isBrowserCompliant = false;    buttonCssText: "",
     else    checkboxCssClass: null,
       isBrowserCompliant = hasGetElementById;    checkboxCssText: "",
   } else { // other OS    radioCssClass: null,
     isBrowserCompliant = hasGetElementById;    radioCssText: "",
   }    linkCssClass: null,
     linkCssText: "",
   // possibly more checks in the future for this    menuCssClass: null,
   isJavaCompliant = isJavaEnabled;    menuCssText: "",
    
   isFullyCompliant = isBrowserCompliant && isJavaCompliant;    targetSuffix: 0,
 }    targetText: "",
     scripts: [""],
 function _jmolApplet(size, inlineModel, script, nameSuffix) {    params: {
   with (_jmol) {   progressbar: "true",
     if (! nameSuffix)   progresscolor: "blue",
       nameSuffix = appletCount;   boxbgcolor: "black",
     ++appletCount;   boxfgcolor: "white",
     if (! script)   boxmessage: "Downloading JmolApplet ..."
       script = "select *";    },
     var sz = _jmolGetAppletSize(size);    ua: navigator.userAgent.toLowerCase(),
     var t;    uaVersion: parseFloat(navigator.appVersion),
     t = "<applet name='jmolApplet" + nameSuffix + "' id='jmolApplet" + nameSuffix +   
         "' " + appletCssText +    os: "unknown",
         " code='JmolApplet' archive='JmolApplet.jar'\n" +    browser: "unknown",
         " codebase='" + codebase + "'\n" +    browserVersion: 0,
         " width='" + sz[0] + "' height='" + sz[1] +    hasGetElementById: !!document.getElementById,
         "' mayscript='true'>\n" +    isJavaEnabled: navigator.javaEnabled(),
         "  <param name='progressbar' value='true' />\n" +    isNetscape47Win: false,
         "  <param name='progresscolor' value='" +    isIEWin: false,
         progresscolor + "' />\n" +    useIEObject: false,
         "  <param name='boxmessage' value='" +    useHtml4Object: false,
         boxmessage + "' />\n" +   
         "  <param name='boxbgcolor' value='" +    windowsClassId: "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93",
         boxbgcolor + "' />\n" +    windowsCabUrl:
         "  <param name='boxfgcolor' value='" +     "http://java.sun.com/update/1.5.0/jinstall-1_5_0_05-windows-i586.cab",
         boxfgcolor + "' />\n" +  
         "  <param name='ReadyCallback' value='_jmolReadyCallback' />\n";    isBrowserCompliant: false,
     isJavaCompliant: false,
     if (inlineModel)    isFullyCompliant: false,
       t += "  <param name='loadInline' value='" + inlineModel + "' />\n";  
     if (script)    initialized: false,
       t += "  <param name='script' value='" + script + "' />\n";    initChecked: false,
     t += "</applet>";   
     jmolSetTarget(nameSuffix);    browserChecked: false,
     ready["jmolApplet" + nameSuffix] = false;    checkBrowserAction: "alert",
     if (_jmol.debugAlert)    checkBrowserUrlOrMessage: null,
       alert(t);  
     document.write(t);    archivePath: null, // JmolApplet0.jar OR JmolAppletSigned0.jar
   }  
 }    previousOnloadHandler: null,
     ready: {}
 function _jmolInitCheck() {  }
   if (_jmol.initChecked)  
     return;  with (_jmol) {
   _jmol.initChecked = true;  
   if (_jmol.initialized)    function _jmolTestUA(candidate) {
     return;      var ua = _jmol.ua;
   alert("jmolInitialize({codebase}, {badBrowseURL}, {badJavaURL})\n" +      var index = ua.indexOf(candidate);
         "  must be called before any other Jmol.js functions");      if (index < 0)
 }        return false;
       _jmol.browser = candidate;
 function _jmolCheckBrowser() {      _jmol.browserVersion = parseFloat(ua.substring(index+candidate.length+1));
   with (_jmol) {      return true;
     if (browserChecked)    }
       return;   
     browserChecked = true;    function _jmolTestOS(candidate) {
         if (_jmol.ua.indexOf(candidate) < 0)
     if (isFullyCompliant)        return false;
       return true;      _jmol.os = candidate;
       return true;
     if (checkBrowserAction == "redirect")    }
       location.href = checkBrowserUrlOrMessage;   
     else if (checkBrowserAction == "popup")    _jmolTestUA("konqueror") ||
       _jmolPopup(checkBrowserUrlOrMessage);    _jmolTestUA("safari") ||
     else {    _jmolTestUA("omniweb") ||
       var msg = checkBrowserUrlOrMessage;    _jmolTestUA("opera") ||
       if (msg == null)    _jmolTestUA("webtv") ||
         msg = "Your web browser is not fully compatible with Jmol\n\n" +    _jmolTestUA("icab") ||
               "brower: " + browser +    _jmolTestUA("msie") ||
               "   version: " + browserVersion +    (_jmol.ua.indexOf("compatible") < 0 && _jmolTestUA("mozilla"));
               "   os: " + os +   
               "\n\n" + ua;    _jmolTestOS("linux") ||
       alert(msg);    _jmolTestOS("unix") ||
     }    _jmolTestOS("mac") ||
   }    _jmolTestOS("win");
   return false;  
 }    isNetscape47Win = (os == "win" && browser == "mozilla" &&
                        browserVersion >= 4.78 && browserVersion <= 4.8);
 function _jmolPopup(url) {  
   var popup = window.open(url, "JmolPopup",    if (os == "win") {
                           "left=150,top=150,height=400,width=600," +      isBrowserCompliant = hasGetElementById;
                           "directories=yes,location=yes,menubar=yes," +    } else if (os == "mac") { // mac is the problem child :-(
                           "toolbar=yes," +      if (browser == "mozilla" && browserVersion >= 5) {
                           "resizable=yes,scrollbars=yes,status=yes");        // miguel 2004 11 17
   if (popup.focus)        // checking the plugins array does not work because
     poup.focus();        // Netscape 7.2 OS X still has Java 1.3.1 listed even though
 }        // javaplugin.sf.net is installed to upgrade to 1.4.2
         eval("try {var v = java.lang.System.getProperty('java.version');" +
 function _jmolReadyCallback(name) {             " _jmol.isBrowserCompliant = v >= '1.4.2';" +
   if (_jmol.debugAlert)             " } catch (e) { }");
     alert(name + " is ready");      } else if (browser == "opera" && browserVersion <= 7.54) {
   _jmol.ready["" + name] = true;        isBrowserCompliant = false;
 }      } else {
         isBrowserCompliant = hasGetElementById &&
 function _jmolConvertInline(model) {          !((browser == "msie") ||
   var inlineModel = model.replace(/\r|\n|\r\n/g, "|");            (browser == "safari" && browserVersion < 125.12));
   if (_jmol.debugAlert)      }
     alert("inline model:\n" + inlineModel);    } else if (os == "linux" || os == "unix") {
   return inlineModel;      if (browser == "konqueror" && browserVersion <= 3.3)
 }        isBrowserCompliant = false;
       else
 function _jmolGetAppletSize(size) {        isBrowserCompliant = hasGetElementById;
   var width, height;    } else { // other OS
   var type = typeof size;      isBrowserCompliant = hasGetElementById;
   if (type == "number")    }
     width = height = size;  
   else if (type == "object" && size != null) {    // possibly more checks in the future for this
     width = size[0]; height = size[1];    isJavaCompliant = isJavaEnabled;
   }  
   if (! (width >= 25 && width <= 2000))    isFullyCompliant = isBrowserCompliant && isJavaCompliant;
     width = 300;  
   if (! (height >= 25 && height <= 2000))    // IE5.5 works just fine ... but let's push them to Sun Java
     height = 300;    isIEWin = (os == "win" && browser == "msie" && browserVersion >= 5.5);
   return [width, height];    useIEObject = isIEWin;
 }    useHtml4Object =
      (os != "mac" && browser == "mozilla" && browserVersion >= 5) ||
 function _jmolRadio(script, labelHtml, isChecked, separatorHtml, groupName) {     (os == "win" && browser == "opera" && browserVersion >= 8) ||
   ++_jmol.radioCount;     (os == "mac" && browser == "safari" && browserVersion >= 412.2);
   if (groupName == undefined || groupName == null)  
     groupName = "jmolRadioGroup" + (_jmol.radioGroupCount - 1);   doTranslate = true;
   if (!script)   haveSetTranslate = false;
     return "";  }
   if (labelHtml == undefined || labelHtml == null)  
     labelHtml = script.substring(0, 32);  function jmolSetCallback(callbackName,funcName) {
   if (! separatorHtml)    _jmol.params[callbackName] = funcName
     separatorHtml = "";  }
   var scriptIndex = _jmolAddScript(script);  
   return "<input name='" + groupName +  function jmolSetLogLevel(n) {
          "' type='radio' onClick='_jmolClick(" +    _jmol.params.logLevel = ''+n;
          scriptIndex + _jmol.targetText +  }
          ");return true;' onMouseover='_jmolMouseOver(" +  
          scriptIndex +   /*  AngelH, mar2007:
          ");return true;' onMouseout='_jmolMouseOut()' " +   By (re)setting these variables in the webpage before calling jmolApplet(),
  (isChecked ? "checked " : "") + _jmol.radioCssText + "/>" +   a custom message can be provided (e.g. localized for user's language) when no Java is installed.
          labelHtml + separatorHtml;   */
 }  if (noJavaMsg==undefined) var noJavaMsg =
           "You do not have Java applets enabled in your web browser, or your browser is blocking this applet.<br />\n" +
 function _jmolFindApplet(target) {          "Check the warning message from your browser and/or enable Java applets in<br />\n" +
   // first look for the target in the current window          "your web browser preferences, or install the Java Runtime Environment from <a href='http://www.java.com'>www.java.com</a><br />";
   var applet = _jmolSearchFrames(window, target);  if (noJavaMsg2==undefined) var noJavaMsg2 =
   if (applet == undefined)          "You do not have the<br />\n" +
     applet = _jmolSearchFrames(top, target); // look starting in top frame          "Java Runtime Environment<br />\n" +
   return applet;          "installed for applet support.<br />\n" +
 }          "Visit <a href='http://www.java.com'>www.java.com</a>";
   function _jmolApplet(size, inlineModel, script, nameSuffix) {
 function _jmolSearchFrames(win, target) {   /*  AngelH, mar2007
   var applet;   Fixed percent / pixel business, to avoid browser errors:
   var frames = win.frames;   put "px" where needed, avoid where not.
   if (frames && frames.length) { // look in all the frames below this window   */
     for (var i = 0; i < frames.length; ++i) {    with (_jmol) {
       applet = _jmolSearchFrames(frames[i++], target);      if (! nameSuffix)
       if (applet)        nameSuffix = appletCount;
         break;      appletSuffixes.push(nameSuffix);
     }      ++appletCount;
   } else { // look for the applet in this window      if (! script)
     var doc = win.document;        script = "select *";
 // getElementById fails on MacOSX Safari & Mozilla      var sz = _jmolGetAppletSize(size);
     if (doc.applets)      var widthAndHeight = " width='" + sz[0] + "' height='" + sz[1] + "' ";
       applet = doc.applets[target];      var tHeader, tFooter;
     else  
       applet = doc[target];      if (useIEObject || useHtml4Object) {
   }        params.name = 'jmolApplet' + nameSuffix;
   return applet;        params.archive = archivePath;
 }        params.mayscript = 'true';
         params.codebase = codebase;
 function _jmolAddScript(script) {      }
   if (! script)      if (useIEObject) { // use MSFT IE6 object tag with .cab file reference
     return 0;        winCodebase = (windowsCabUrl ? " codebase='" + windowsCabUrl + "'\n" : "");
   var index = _jmol.scripts.length;        tHeader =
   _jmol.scripts[index] = script;          "<object name='jmolApplet" + nameSuffix +
   return index;          "' id='jmolApplet" + nameSuffix + "' " + appletCssText + "\n" +
 }   " classid='" + windowsClassId + "'\n" + winCodebase + widthAndHeight + ">\n";
           params.code = 'JmolApplet';
 function _jmolClick(scriptIndex, targetSuffix) {        tFooter = "</object>";
   jmolScript(_jmol.scripts[scriptIndex], targetSuffix);      } else if (useHtml4Object) { // use HTML4 object tag
 }        tHeader =
           "<object name='jmolApplet" + nameSuffix +
 function _jmolMenuSelected(menuObject, targetSuffix) {          "' id='jmolApplet" + nameSuffix + "' " + appletCssText + "\n" +
   var scriptIndex = menuObject.value;   " classid='java:JmolApplet'\n" +
   if (scriptIndex != undefined) {          " type='application/x-java-applet'\n" +
     jmolScript(_jmol.scripts[scriptIndex], targetSuffix);          widthAndHeight + ">\n";
     return;        tFooter = "</object>";
   }      } else { // use applet tag
   var length = menuObject.length;        tHeader =
   if (typeof length == "number") {          "<applet name='jmolApplet" + nameSuffix +
     for (var i = 0; i < length; ++i) {          "' id='jmolApplet" + nameSuffix +
       if (menuObject[i].selected) {          "' " + appletCssText +
         _jmolClick(menuObject[i].value, targetSuffix);          " code='JmolApplet'" +
  return;          " archive='" + archivePath + "' codebase='" + codebase + "'\n" +
       }   widthAndHeight +
     }          " mayscript='true'>\n";
   }        tFooter = "</applet>";
   alert("?Que? menu selected bug #8734");      }
 }      var visitJava;
       if (isIEWin || useHtml4Object) {
 function _jmolCbClick(ckbox, whenChecked, whenUnchecked, targetSuffix) {   var szX = "width:" + sz[0]
   _jmolClick(ckbox.checked ? whenChecked : whenUnchecked, targetSuffix);   if ( szX.indexOf("%")==-1 ) szX+="px"
 }   var szY = "height:" + sz[1]
    if ( szY.indexOf("%")==-1 ) szY+="px"
 function _jmolCbOver(ckbox, whenChecked, whenUnchecked) {        visitJava =
   window.status = _jmol.scripts[ckbox.checked ? whenUnchecked : whenChecked];          "<p style='background-color:yellow; color:black; " +
 }   szX + ";" + szY + ";" +
           // why doesn't this vertical-align work?
 function _jmolMouseOver(scriptIndex) {   "text-align:center;vertical-align:middle;'>\n" +
   window.status = _jmol.scripts[scriptIndex];   noJavaMsg +
 }          "</p>";
       } else {
 function _jmolMouseOut() {        visitJava =
   window.status = " ";          "<table bgcolor='yellow'><tr>" +
   return true;          "<td align='center' valign='middle' " + widthAndHeight + "><font color='black'>\n" +
 }   noJavaMsg2 +
           "</font></td></tr></table>";
 function _jmolSetCodebase(codebase) {      }
   _jmol.codebase = codebase ? codebase : ".";      params.loadInline = (inlineModel ? inlineModel : "");
   if (_jmol.debugAlert)      params.script = (script ? _jmolSterilizeScript(script) : "");
     alert("jmolCodebase=" + _jmol.codebase);      var t = tHeader + _jmolParams() + visitJava + tFooter;
 }      jmolSetTarget(nameSuffix);
       ready["jmolApplet" + nameSuffix] = false;
 function _jmolOnloadResetForms() {      if (_jmol.debugAlert)
   _jmol.previousOnloadHandler = window.onload;        alert(t);
   window.onload =      return _jmolDocumentWrite(t);
   function() {    }
 //    alert("onloadResetForms");  }
     with (_jmol) {  
       if (buttonCount+checkboxCount+menuCount+radioCount+radioGroupCount > 0) {  function _jmolParams() {
         var forms = document.forms;   var t = "";
         if (!forms || forms.length == 0) {   for (i in _jmol.params)
           alert("<form> tags seem to be missing\n" +   if(_jmol.params[i]!="")
                 "Jmol/HTML input controls must be contained " +   t+="  <param name='"+i+"' value='"+_jmol.params[i]+"' />\n";
                 "within form tags"   return t
 //                + "\n\n" + forms + " forms.length=" + forms.length +  }
 //                " typeof=" + (typeof forms)  
                 );  function _jmolInitCheck() {
         } else {    if (_jmol.initChecked)
           for (var i = forms.length; --i >= 0; )      return;
             forms[i].reset();    _jmol.initChecked = true;
         }    if (_jmol.initialized)
       }      return;
       if (previousOnloadHandler)    jmolInitialize(defaultdir, defaultjar)
         previousOnloadHandler();  }
     }  
   }  function _jmolCheckBrowser() {
 }    with (_jmol) {
       if (browserChecked)
         return;
       browserChecked = true;
    
       if (isFullyCompliant)
         return true;
   
       if (checkBrowserAction == "redirect")
         location.href = checkBrowserUrlOrMessage;
       else if (checkBrowserAction == "popup")
         _jmolPopup(checkBrowserUrlOrMessage);
       else {
         var msg = checkBrowserUrlOrMessage;
         if (msg == null)
           msg = "Your web browser is not fully compatible with Jmol\n\n" +
                 "browser: " + browser +
                 "   version: " + browserVersion +
                 "   os: " + os +
                 "\n\n" + ua;
         alert(msg);
       }
     }
     return false;
   }
   
   function _jmolDocumentWrite(text) {
     if (_jmol.currentDocument)
       _jmol.currentDocument.write(text);
     return text;
   }
   
   function _jmolPopup(url) {
     var popup = window.open(url, "JmolPopup",
                             "left=150,top=150,height=400,width=600," +
                             "directories=yes,location=yes,menubar=yes," +
                             "toolbar=yes," +
                             "resizable=yes,scrollbars=yes,status=yes");
     if (popup.focus)
       poup.focus();
   }
   
   function _jmolReadyCallback(name) {
     if (_jmol.debugAlert)
       alert(name + " is ready");
     _jmol.ready["" + name] = true;
   }
   
   function _jmolSterilizeScript(script) {
     var inlineScript = script.replace(/'/g, "&#39;");
     if (_jmol.debugAlert)
       alert("script:\n" + inlineScript);
     return inlineScript;
   }
   
   function _jmolSterilizeInline(model) {
     var inlineModel =
       model.replace(/\r|\n|\r\n/g, "|").replace(/'/g, "&#39;");
     if (_jmol.debugAlert)
       alert("inline model:\n" + inlineModel);
     return inlineModel;
   }
   
    /*  AngelH, mar2007:
    By (re)setting this variable in the webpage before calling jmolApplet(), limits for applet size can be overriden.
    */
   
    /* hansonr, jun2007:
    2048 standard for GeoWall (http://geowall.geo.lsa.umich.edu/home.html)
    */
   
   if (allowedJmolSize==undefined) var allowedJmolSize = [25, 2048, 300]   // min, max, default (pixels)
   function _jmolGetAppletSize(size) {
    /*  AngelH, mar2007
    Accepts single number or 2-value array, each one can be either:
      percent (text string ending %), decimal 0 to 1 (percent/100), number, or text string (interpreted as nr.)
      Size is now returned as string or number, no "px".
    */
     var width, height;
     if ( (typeof size) == "object" && size != null ) {
       width = size[0]; height = size[1];
     } else {
       width = height = size;
     }
     // if percent, leave it as it is:
     if ( width.toString().charAt(width.toString().length-1) != "%" ) {
       width = parseFloat(width); // convert to nr., or strip text, or make zero
    if ( width <= 1 && width > 0 ) { width = (width*100)+"%" } // decimal: convert to percent and quit
    else if ( width >= allowedJmolSize[0] && width <= allowedJmolSize[1] ) { width = parseInt(width) } // accept only that range (pixels)
    else { width = allowedJmolSize[2] } // default size 300 pixels
     }
     if ( height.toString().charAt(height.toString().length-1) != "%" ) {
       height = parseFloat(height);
    if ( height <= 1 && height > 0 ) { height = (height*100)+"%" }
    else if ( height >= allowedJmolSize[0] && height <= allowedJmolSize[1] ) { height = parseInt(height) }
    else { height = allowedJmolSize[2] }
     }
     return [width, height];
   }
   
   function _jmolRadio(script, labelHtml, isChecked, separatorHtml, groupName, id, title) {
     ++_jmol.radioCount;
     if (groupName == undefined || groupName == null)
       groupName = "jmolRadioGroup" + (_jmol.radioGroupCount - 1);
     if (!script)
       return "";
     if (labelHtml == undefined || labelHtml == null)
       labelHtml = script.substring(0, 32);
     if (! separatorHtml)
       separatorHtml = "";
     var scriptIndex = _jmolAddScript(script);
     var eospan = "</span>"
     var t = "<span id=\"span_"+id+"\""+(title ? " title =\"" + title + "\"":"")+"><input name='"
    + groupName + "' id='"+id+"' type='radio' onClick='_jmolClick(" +
            scriptIndex + _jmol.targetText + ");return true;' onMouseover='_jmolMouseOver(" +
            scriptIndex + ");return true;' onMouseout='_jmolMouseOut()' " +
    (isChecked ? "checked " : "") + _jmol.radioCssText + "/>"
     if (labelHtml.toLowerCase().indexOf("<td>")>=0) {
    t += eospan
    eospan = "";
     }
     t += labelHtml +eospan + separatorHtml;
     return t;
   }
   
   function _jmolFindApplet(target) {
     // first look for the target in the current window
     var applet = _jmolFindAppletInWindow(window, target);
     // THEN look for the target in child frames
     if (applet == undefined)
       applet = _jmolSearchFrames(window, target);
     // FINALLY look for the target in sibling frames
     if (applet == undefined)
       applet = _jmolSearchFrames(top, target); // look starting in top frame
     return applet;
   }
   
   function _jmolGetApplet(targetSuffix){
    var target = "jmolApplet" + (targetSuffix ? targetSuffix : "0");
    var applet = _jmolFindApplet(target);
    if (applet) return applet
    if(!_jmol.alerted)alert("could not find applet " + target);
    _jmol.alerted = true;
    return null
   }
   
   function _jmolSearchFrames(win, target) {
     var applet;
     var frames = win.frames;
     if (frames && frames.length) { // look in all the frames below this window
       for (var i = 0; i < frames.length; ++i) {
         applet = _jmolSearchFrames(frames[i], target);
         if (applet)
           break;
       }
     } else { // look for the applet in this window
      applet = _jmolFindAppletInWindow(win, target)
     }
     return applet;
   }
   
   function _jmolFindAppletInWindow(win, target) {
       var doc = win.document;
       // getElementById fails on MacOSX Safari & Mozilla
       if (_jmol.useHtml4Object || _jmol.useIEObject)
         return doc.getElementById(target);
       else if (doc.applets)
         return doc.applets[target];
       else
         return doc[target];
   }
   
   function _jmolAddScript(script) {
     if (! script)
       return 0;
     var index = _jmol.scripts.length;
     _jmol.scripts[index] = script;
     return index;
   }
   
   function _jmolClick(scriptIndex, targetSuffix) {
     jmolScript(_jmol.scripts[scriptIndex], targetSuffix);
   }
   
   function _jmolMenuSelected(menuObject, targetSuffix) {
     var scriptIndex = menuObject.value;
     if (scriptIndex != undefined) {
       jmolScript(_jmol.scripts[scriptIndex], targetSuffix);
       return;
     }
     var len = menuObject.length;
     if (typeof len == "number") {
       for (var i = 0; i < len; ++i) {
         if (menuObject[i].selected) {
           _jmolClick(menuObject[i].value, targetSuffix);
    return;
         }
       }
     }
     alert("?Que? menu selected bug #8734");
   }
   
   
   _jmol.checkboxMasters = new Array();
   _jmol.checkboxItems = new Array();
   
   function jmolSetCheckboxGroup(chkMaster,chkBox) {
    var id = chkMaster;
    if(typeof(id)=="number")id = "jmolCheckbox" + id;
    chkMaster = document.getElementById(id);
    if (!chkMaster)alert("jmolSetCheckboxGroup: master checkbox not found: " + id);
    var m = _jmol.checkboxMasters[id] = new Array();
    m.chkMaster = chkMaster;
    m.chkGroup = new Array();
    for (var i = 1; i < arguments.length; i++){
    var id = arguments[i];
    if(typeof(id)=="number")id = "jmolCheckbox" + id;
    checkboxItem = document.getElementById(id);
    if (!checkboxItem)alert("jmolSetCheckboxGroup: group checkbox not found: " + id);
    m.chkGroup[id] = checkboxItem;
    _jmol.checkboxItems[id] = m;
    }
   }
   
   function _jmolNotifyMaster(m){
    //called when a group item is checked
    var allOn = true;
    var allOff = true;
    for (var chkBox in m.chkGroup){
    if(m.chkGroup[chkBox].checked)
    allOff = false;
    else
    allOn = false;
    }
    if (allOn)m.chkMaster.checked = true;
    if (allOff)m.chkMaster.checked = false;
    if ((allOn || allOff) && _jmol.checkboxItems[m.chkMaster.id])
    _jmolNotifyMaster(_jmol.checkboxItems[m.chkMaster.id])
   }
   
   function _jmolNotifyGroup(m, isOn){
    //called when a master item is checked
    for (var chkBox in m.chkGroup){
    var item = m.chkGroup[chkBox]
    item.checked = isOn;
    if (_jmol.checkboxMasters[item.id])
    _jmolNotifyGroup(_jmol.checkboxMasters[item.id], isOn)
    }
   }
   
   function _jmolCbClick(ckbox, whenChecked, whenUnchecked, targetSuffix) {
     _jmolClick(ckbox.checked ? whenChecked : whenUnchecked, targetSuffix);
     if(_jmol.checkboxMasters[ckbox.id])
    _jmolNotifyGroup(_jmol.checkboxMasters[ckbox.id], ckbox.checked)
     if(_jmol.checkboxItems[ckbox.id])
    _jmolNotifyMaster(_jmol.checkboxItems[ckbox.id])
   }
   
   function _jmolCbOver(ckbox, whenChecked, whenUnchecked) {
     window.status = _jmol.scripts[ckbox.checked ? whenUnchecked : whenChecked];
   }
   
   function _jmolMouseOver(scriptIndex) {
     window.status = _jmol.scripts[scriptIndex];
   }
   
   function _jmolMouseOut() {
     window.status = " ";
     return true;
   }
   
   function _jmolSetCodebase(codebase) {
     _jmol.codebase = codebase ? codebase : ".";
     if (_jmol.debugAlert)
       alert("jmolCodebase=" + _jmol.codebase);
   }
   
   function _jmolOnloadResetForms() {
     _jmol.previousOnloadHandler = window.onload;
     window.onload =
     function() {
       with (_jmol) {
         if (buttonCount+checkboxCount+menuCount+radioCount+radioGroupCount > 0) {
           var forms = document.forms;
           for (var i = forms.length; --i >= 0; )
             forms[i].reset();
         }
         if (previousOnloadHandler)
           previousOnloadHandler();
       }
     }
   }
   
   ////////////////////////////////////
   /////extensions for getProperty/////
   ////////////////////////////////////
   
   
   function _jmolEvalJSON(s,key){
    s=s+""
    if(!s)return []
    if(s.charAt(0)!="{"){
    if(s.indexOf(" | ")>=0)s=s.replace(/\ \|\ /g, "\n")
    return s
    }
    var A = eval("("+s+")")
    if(!A)return
    if(key && A[key])A=A[key]
    return A
   }
   
   function _jmolEnumerateObject(A,key){
    var sout=""
    if(typeof(A) == "string" && A!="null"){
    sout+="\n"+key+"=\""+A+"\""
    }else if(!isNaN(A)||A==null){
    sout+="\n"+key+"="+(A+""==""?"null":A)
    }else if(A.length){
       sout+=key+"=new Array()"
       for(var i=0;i<A.length;i++){
    sout+="\n"
    if(typeof(A[i]) == "object"||typeof(A[i]) == "array"){
    sout+=_jmolEnumerateObject(A[i],key+"["+i+"]")
    }else{
    sout+=key+"["+i+"]="+(typeof(A[i]) == "string" && A[i]!="null"?"\""+A[i].replace(/\"/g,"\\\"")+"\"":A[i])
    }
       }
    }else{
       if(key != ""){
    sout+=key+"=new Array()"
    key+="."
       }
      
       for(var i in A){
    sout+="\n"
    if(typeof(A[i]) == "object"||typeof(A[i]) == "array"){
    sout+=_jmolEnumerateObject(A[i],key+i)
    }else{
    sout+=key+i+"="+(typeof(A[i]) == "string" && A[i]!="null"?"\""+A[i].replace(/\"/g,"\\\"")+"\"":A[i])
    }
       }
    }
    return sout
   }
   
   
   function _jmolSortKey0(a,b){
    return (a[0]<b[0]?1:a[0]>b[0]?-1:0)
   }
   
   function _jmolSortMessages(A){
    if(!A || typeof(A)!="object")return []
    var B = new Array()
    for(var i=A.length-1;i>=0;i--)for(var j=0;j<A[i].length;j++)B[B.length]=A[i][j]
    if(B.length == 0) return
    B=B.sort(_jmolSortKey0)
    return B
   }
   
   /////////additional extensions //////////
   
   
   function _jmolDomScriptLoad(URL){
    //open(URL) //to debug
    _jmol.servercall=URL
    var node = document.getElementById("_jmolScriptNode")
    if (node && _jmol.browser!="msie"){
       document.getElementsByTagName("HEAD")[0].removeChild(node)
       node=null
    }
    if (node) {
      node.setAttribute("src",URL)
    } else {
      node=document.createElement("script")
      node.setAttribute("id","_jmolScriptNode")
      node.setAttribute("type","text/javascript")
      node.setAttribute("src",URL)
      document.getElementsByTagName("HEAD")[0].appendChild(node)
    }
   }
   
   
   function _jmolExtractPostData(url){
    S=url.split("&POST:")
    var s=""
    for(var i=1;i<S.length;i++){
    KV=S[i].split("=")
    s+="&POSTKEY"+i+"="+KV[0]
    s+="&POSTVALUE"+i+"="+KV[1]
    }
    return "&url="+escape(S[0])+s
   }
   
   function _jmolLoadModel(targetSuffix,remoteURL,array,isError,errorMessage){
    //called by server, but in client
    //overload this function to customize return
    _jmol.remoteURL=remoteURL
    if(isError)alert(errorMessage)
    jmolLoadInlineScript(array.join("\n"),_jmol.optionalscript,targetSuffix)
   }
   
   //////////user property/status functions/////////
   
   function jmolGetStatus(strStatus,targetSuffix){
    return _jmolSortMessages(jmolGetPropertyAsArray("jmolStatus",strStatus,targetSuffix))
   }
   
   function jmolGetPropertyAsArray(sKey,sValue,targetSuffix) {
    return _jmolEvalJSON(jmolGetPropertyAsJSON(sKey,sValue,targetSuffix),sKey)
   }
   
   function jmolGetPropertyAsString(sKey,sValue,targetSuffix) {
    var applet = _jmolGetApplet(targetSuffix);
    if(!sValue)sValue=""
    return (applet ? applet.getPropertyAsString(sKey,sValue) + "" : "")
   }
   
   function jmolGetPropertyAsJSON(sKey,sValue,targetSuffix) {
    if(!sValue)sValue = ""
    var applet = _jmolGetApplet(targetSuffix);
    try {
     return (applet ? applet.getPropertyAsJSON(sKey,sValue) + "" : "")
    } catch(e) {
     return ""
    }
   }
   
   function jmolGetPropertyAsJavaObject(sKey,sValue,targetSuffix) {
    if(!sValue)sValue = ""
    var applet = _jmolGetApplet(targetSuffix);
    return (applet ? applet.getProperty(sKey,sValue) : null)
   }
   
   
   function jmolDecodeJSON(s) {
    return _jmolEnumerateObject(_jmolEvalJSON(s),"")
   }
   
   
   ///////// synchronous scripting ////////
   
   function jmolScriptWait(script, targetSuffix) {
     if(!targetSuffix)targetSuffix="0"
     var Ret=jmolScriptWaitAsArray(script, targetSuffix)
     var s = ""
     for(i=Ret.length;--i>=0;)
     for(j=0;j< Ret[i].length;j++)
    s+=Ret[i][j]+"\n"
     return s
   }
   
   function jmolEvaluate(molecularMath, targetSuffix) {
   
     //carries out molecular math on a model
   
     if(!targetSuffix)targetSuffix="0"
     var result = "" + jmolGetPropertyAsJavaObject("evaluate", molecularMath, targetSuffix);
     var s = result.replace(/\-*\d+/,"")
     if (s == "" && !isNaN(parseInt(result)))return parseInt(result);
     var s = result.replace(/\-*\d*\.\d*/,"")
     if (s == "" && !isNaN(parseFloat(result)))return parseFloat(result);
     return result;
   }
   
   function jmolScriptEcho(script, targetSuffix) {
     // returns a newline-separated list of all echos from a script
     if(!targetSuffix)targetSuffix="0"
     var Ret=jmolScriptWaitAsArray(script, targetSuffix)
     var s = ""
     for(i=Ret.length;--i>=0;)
     for(j=Ret[i].length;--j>=0;)
           if (Ret[i][j][1] == "scriptEcho")s+=Ret[i][j][3]+"\n"
     return s.replace(/ \| /g, "\n")
   }
   
   
   function jmolScriptMessage(script, targetSuffix) {
     // returns a newline-separated list of all messages from a script, ending with "script completed\n"
     if(!targetSuffix)targetSuffix="0"
     var Ret=jmolScriptWaitAsArray(script, targetSuffix)
     var s = ""
     for(i=Ret.length;--i>=0;)
     for(j=Ret[i].length;--j>=0;)
           if (Ret[i][j][1] == "scriptStatus")s+=Ret[i][j][3]+"\n"
     return s.replace(/ \| /g, "\n")
   }
   
   
   function jmolScriptWaitAsArray(script, targetSuffix) {
    var ret = ""
    try{
     jmolGetStatus("scriptEcho,scriptMessage,scriptStatus,scriptError",targetSuffix)
     if (script) {
       _jmolCheckBrowser();
       var applet=_jmolGetApplet(targetSuffix);
       if (applet) ret += applet.scriptWait(script);
       ret = _jmolEvalJSON(ret,"jmolStatus")
       if(typeof ret == "object")
    return ret
     }
    }catch(e){
    }
     return [[ret]]
   }
   
   
   
   ////////////   save/restore orientation   /////////////
   
   function jmolSaveOrientation(id, targetSuffix) {  
    if(!targetSuffix)targetSuffix="0"
     return _jmol["savedOrientation"+id] = jmolGetPropertyAsArray("orientationInfo","info",targetSuffix).moveTo
   }
   
   function jmolRestoreOrientation(id, targetSuffix) {
    if(!targetSuffix)targetSuffix="0"
    var s=_jmol["savedOrientation"+id]
    if (!s || s == "")return
    s=s.replace(/1\.0/,"0")
    return jmolScriptWait(s,targetSuffix)
   }
   
   function jmolRestoreOrientationDelayed(id, delay, targetSuffix) {
    if(arguments.length < 2)delay=1;
    if(!targetSuffix)targetSuffix="0"
    var s=_jmol["savedOrientation"+id]
    if (!s || s == "")return
    s=s.replace(/1\.0/,delay)
    return jmolScriptWait(s,targetSuffix)
   }
   
   ////////////  add parameter /////////////
   /*
    * for adding callbacks or other parameters. Use:
   
      jmolSetDocument(0)
      var s= jmolApplet(....)
      s = jmolAppletAddParam(s,"messageCallback", "myFunctionName")
      document.write(s)
      jmolSetDocument(document) // if you want to then write buttons and such normally
    
    */
   
   function jmolAppletAddParam(appletCode,name,value){
     if(value == "")return appletCode
     return appletCode.replace(/\<param/,"\n<param name='"+name+"' value='"+value+"' />\n<param")
   }
   
   ///////////////auto load Research Consortium for Structural Biology (RCSB) data ///////////
   
   function jmolLoadAjax_STOLAF_RCSB(fileformat,pdbid,optionalscript,targetSuffix){
   
    if(!_jmol.thismodel)_jmol.thismodel = "1crn"
    if(!_jmol.serverURL)_jmol.serverURL="http://fusion.stolaf.edu/chemistry/jmol/getajaxjs.cfm"
    if(!_jmol.RCSBserver)_jmol.RCSBserver="http://www.rcsb.org"
    if(!_jmol.defaultURL_RCSB)_jmol.defaultURL_RCSB=_jmol.RCSBserver+"/pdb/files/1CRN.CIF"
    if(!fileformat)fileformat="PDB"
    if(!pdbid)pdbid=prompt("Enter a 4-digit PDB ID:",_jmol.thismodel)
    if(!pdbid || pdbid.length != 4)return ""
    if(!targetSuffix)targetSuffix="0"
    if(!optionalscript)optionalscript=""
    var url=_jmol.defaultURL_RCSB.replace(/1CRN/g,pdbid.toUpperCase())
    if(fileformat!="CIF")url=url.replace(/CIF/,fileformat)
    _jmol.optionalscript=optionalscript
    _jmol.thismodel=pdbid
    _jmol.thistargetsuffix=targetSuffix
    _jmol.thisurl=url
    _jmol.modelArray = new Array()
    url=_jmol.serverURL+"?returnfunction=_jmolLoadModel&returnArray=_jmol.modelArray&id="+targetSuffix+_jmolExtractPostData(url)
    _jmolDomScriptLoad(url)
    return url
   }
   
   /////////////// St. Olaf College AJAX server -- ANY URL ///////////
   
   function jmolLoadAjax_STOLAF_ANY(url, userid, optionalscript,targetSuffix){
    _jmol.serverURL="http://fusion.stolaf.edu/chemistry/jmol/getajaxjs.cfm"
    if(!_jmol.thisurlANY)_jmol.thisurlANY = "http://www.stolaf.edu/depts/chemistry/mo/struc/data/ycp3-1.mol"
    if(!url)url=prompt("Enter any (uncompressed file) URL:", _jmol.thisurlANY)
    if(!userid)userid="0"
    if(!targetSuffix)targetSuffix="0"
    if(!optionalscript)optionalscript=""
    _jmol.optionalscript=optionalscript
    _jmol.thistargetsuffix=targetSuffix
    _jmol.modelArray = new Array()
    _jmol.thisurl = url
    url=_jmol.serverURL+"?returnfunction=_jmolLoadModel&returnArray=_jmol.modelArray&id="+targetSuffix+_jmolExtractPostData(url)
    _jmolDomScriptLoad(url)
   }
   
   
   /////////////// Mineralogical Society of America (MSA) data /////////
   
   function jmolLoadAjax_MSA(key,value,optionalscript,targetSuffix){
   
    if(!_jmol.thiskeyMSA)_jmol.thiskeyMSA = "mineral"
    if(!_jmol.thismodelMSA)_jmol.thismodelMSA = "quartz"
    if(!_jmol.ajaxURL_MSA)_jmol.ajaxURL_MSA="http://rruff.geo.arizona.edu/AMS/result.php?mineral=quartz&viewing=ajaxjs"
    if(!key)key=prompt("Enter a field:", _jmol.thiskeyMSA)
    if(!key)return ""
    if(!value)value=prompt("Enter a "+key+":", _jmol.thismodelMSA)
    if(!value)return ""
    if(!targetSuffix)targetSuffix="0"
    if(!optionalscript)optionalscript=""
    if(optionalscript == 1)optionalscript='load "" {1 1 1}'
    var url=_jmol.ajaxURL_MSA.replace(/mineral/g,key).replace(/quartz/g,value)
    _jmol.optionalscript=optionalscript
    _jmol.thiskeyMSA=key
    _jmol.thismodelMSA=value
    _jmol.thistargetsuffix=targetSuffix
    _jmol.thisurl=url
    _jmol.modelArray = new Array()
    loadModel=_jmolLoadModel
    _jmolDomScriptLoad(url)
    return url
   }
   
   
   
   function jmolLoadAjaxJS(url, userid, optionalscript,targetSuffix){
    if(!userid)userid="0"
    if(!targetSuffix)targetSuffix="0"
    if(!optionalscript)optionalscript=""
    _jmol.optionalscript=optionalscript
    _jmol.thismodel=userid
    _jmol.thistargetsuffix=targetSuffix
    _jmol.modelArray = new Array()
    _jmol.thisurl = url
    url+="&returnFunction=_jmolLoadModel&returnArray=_jmol.modelArray&id="+targetSuffix
    _jmolDomScriptLoad(url)
   }
   
   
   //// in case Jmol library has already been loaded:
   
   }catch(e){}
   
   ///////////////moving atoms //////////////
   
   // HIGHLY experimental!!
   
   function jmolSetAtomCoord(i,x,y,z,targetSuffix){
       _jmolCheckBrowser();
         var applet=_jmolGetApplet(targetSuffix);
         if (applet) applet.getProperty('jmolViewer').setAtomCoord(i,x,y,z)
   }
   
   function jmolSetAtomCoordRelative(i,x,y,z,targetSuffix){
       _jmolCheckBrowser();
         var applet=_jmolGetApplet(targetSuffix);
         if (applet) applet.getProperty('jmolViewer').setAtomCoordRelative(i,x,y,z)
   }
   
   
   ///////////////applet fake for testing buttons/////////////
   
   
   if(document.location.search.indexOf("NOAPPLET")>=0){
    jmolApplet = function(w){
    var s="<table style='background-color:black' width="+w+"><tr height="+w+">"
    +"<td align=center valign=center style='background-color:white'>"
    +"Applet would be here"
    +"<p><textarea id=fakeApplet rows=5 cols=50></textarea>"
    +"</td></tr></table>"
    return _jmolDocumentWrite(s)
    }
   
    _jmolFindApplet = function(){return jmolApplet0}
   
    jmolApplet0 = {
    script: function(script){document.getElementById("fakeApplet").value="\njmolScript:\n"+script}
    ,scriptWait: function(script){document.getElementById("fakeApplet").value="\njmolScriptWait:\n"+script}
    ,loadInline: function(data,script){document.getElementById("fakeApplet").value="\njmolLoadInline data:\n"+data+"\n\nscript:\n"+script}
    }
   }
   
   
   ///////////////////////////////////////////
   
   //new 9:49 AM 3/6/2007:
   
   //both w and h are optional.
   //if either is between 0 and 1, then it is taken as percent/100.
   //if either is greater than 1, then it is taken as a size.
   function jmolResize(w,h) {
    _jmol.alerted = true;
    var percentW = (!w ? 100 : w <= 1  && w > 0 ? w * 100 : 0)
    var percentH = (!h ? percentW : h <= 1 && h > 0 ? h * 100 : 0)
    if (_jmol.browser=="msie") {
      var width=document.body.clientWidth;
      var height=document.body.clientHeight;
    } else {
      var netscapeScrollWidth=15;
      var width=window.innerWidth - netscapeScrollWidth;
      var height=window.innerHeight-netscapeScrollWidth;
    }
    var applet = _jmolGetApplet(0);
    if(!applet)return;
    applet.style.width = (percentW ? width * percentW/100 : w)+"px"
    applet.style.height = (percentH ? height * percentH/100 : h)+"px"
    title=width +  " " + height + " " + (new Date())
   }
   

Removed from v.1.2  
changed lines
  Added in v.1.3


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>