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

version 1.3, 2007/10/11 00:42:00 version 1.4, 2014/08/22 17:57:54
Line 1 Line 1
   /* Jmol 12.0 script library Jmol.js 5/20/2013 7:34:08 AM Bob Hanson
   
 /* Jmol 11.0 script library Jmol.js (aka Jmol-11.js) 1:34 AM 3/19/2007  
   
  checkbox heirarchy -- see http://www.stolaf.edu/academics/jmol/docs/examples-11/check.htm  NOTE: THIS LIBRARY IS DEPRECATED STARTING WITH Jmol 13.0.
         IT STILL WORKS (AND ALWAYS WILL, PROBABLY).
         PLEASE USE the set JmolCore.js/JmolApplet.js/JmolControls.js/JmolApi.js
         WITH OPTIONAL JmolCD.js (ChemDoodle Canvas and Canvas2D options) and JmolJSV.js (JSpecView)
   
         SEE http://chemapps.stolaf.edu/jmol/files/JmolCore.js for details
         SEE http://chemapps.stolaf.edu/jmol/examples-12/simple2.htm for an example
   
    checkbox heirarchy -- see http://chemapps.stolaf.edu/jmol/docs/examples-11/check.htm
   
     based on:      based on:
  *   *
Line 30 Line 38
 try{if(typeof(_jmol)!="undefined")exit()  try{if(typeof(_jmol)!="undefined")exit()
   
 // place "?NOAPPLET" on your command line to check applet control action with a textarea  // place "?NOAPPLET" on your command line to check applet control action with a textarea
   // place "?JMOLJAR=xxxxx" to use a specific jar file
   
 // bob hanson -- jmolResize(w,h) -- resizes absolutely or by percent (w or h 0.5 means 50%)  // bob hanson -- jmolResize(w,h) -- resizes absolutely or by percent (w or h 0.5 means 50%)
   //    angel herraez -- update of jmolResize(w,h,targetSuffix) so it is not tied to first applet
 // bob hanson -- jmolEvaluate -- evaluates molecular math 8:37 AM 2/23/2007  // bob hanson -- jmolEvaluate -- evaluates molecular math 8:37 AM 2/23/2007
 // bob hanson -- jmolScriptMessage -- returns all "scriptStatus" messages 8:37 AM 2/23/2007  // bob hanson -- jmolScriptMessage -- returns all "scriptStatus" messages 8:37 AM 2/23/2007
 // bob hanson -- jmolScriptEcho -- returns all "scriptEcho" messages 8:37 AM 2/23/2007  // bob hanson -- jmolScriptEcho -- returns all "scriptEcho" messages 8:37 AM 2/23/2007
Line 45  try{if(typeof(_jmol)!="undefined")exit() Line 55  try{if(typeof(_jmol)!="undefined")exit()
 // bob hanson -- fix for iframes not available for finding applet  // bob hanson -- fix for iframes not available for finding applet
 // bob hanson -- added applet fake ?NOAPPLET URL flag  // bob hanson -- added applet fake ?NOAPPLET URL flag
 // bob hanson -- added jmolSetCallback(calbackName, funcName) 3:32 PM 6/13/2006  // bob hanson -- added jmolSetCallback(calbackName, funcName) 3:32 PM 6/13/2006
 // used PRIOR to jmolApplet() or jmolAppletInline()  //      used PRIOR to jmolApplet() or jmolAppletInline()
 //               added 4th array element in jmolRadioGroup -- title  //               added 4th array element in jmolRadioGroup -- title
 //               added <span> and id around link, checkbox, radio, menu  //               added <span> and id around link, checkbox, radio, menu
 //               fixing AJAX loads for MSIE/Opera-Mozilla incompatibility  //               fixing AJAX loads for MSIE/Opera-Mozilla incompatibility
 //            -- renamed Jmol-11.js from Jmol-new.js; JmolApplet.jar from JmolAppletProto.jar  //            -- renamed Jmol-11.js from Jmol-new.js; JmolApplet.jar from JmolAppletProto.jar
 // renamed Jmol.js for Jmol 11 distribution  //      renamed Jmol.js for Jmol 11 distribution
 //            -- modified jmolRestoreOrientation() to be immediate, no 1-second delay  //            -- modified jmolRestoreOrientation() to be immediate, no 1-second delay
 // bob hanson -- jmolScriptWait always returns a string -- 11:23 AM 9/16/2006  // bob hanson -- jmolScriptWait always returns a string -- 11:23 AM 9/16/2006
 // bh         -- jmolCommandInput()  // bh         -- jmolCommandInput()
 // bh         -- jmolSetTranslation(TF) -- forces translation even if there might be message callback issues  // bh         -- jmolSetTranslation(TF) -- forces translation even if there might be message callback issues
 // bh         -- minor fixes suggested by Angel  // bh         -- minor fixes suggested by Angel
     // bh         -- adds jmolSetSyncId() and jmolGetSyncId()
   // bh 3/2008  -- adds jmolAppendInlineScript() and jmolAppendInlineArray()
   // bh 3/2008  -- fixes IE7 bug in relation to jmolLoadInlineArray()
   // bh 6/2008  -- adds jmolSetAppletWindow()
   // Angel H. 6/2008  -- added html <label> tags to checkboxes and radio buttons [in jmolCheckbox() and _jmolRadio() functions]
   // bh 7/2008  -- code fix "for(i..." not "for(var i..."
   // bh 12/2008 -- jmolLoadInline, jmolLoadInlineArray, jmolLoadInlineScript, jmolAppendInlineScript, jmolAppendInlineArray all return error message or null (Jmol 11.7.16)
   // bh 12/2008 -- jmolScriptWaitOutput() -- waits for script to complete and delivers output normally sent to console
   
   // bh 5/2009  -- Support for XHTML using jmolSetXHTML(id)
   // ah & bh 6/2009 -- New jmolResizeApplet() more flexible, similar to jmolApplet() size syntax
   // bh 11/2009 -- care in accessing top.document
   // bh 12/2009 -- added jmolSetParameter(name, value)
   // bh 12/2009 -- added PARAMS=name:value;name:value;name:value... for command line
   // bh 12/2009 -- overhaul of target checking
   // bh 1/2010  -- all _xxxx() methods ALWAYS have complete argument list
   // bh 1/2010  -- adds option to run a JavaScript function from any Jmol control.
   //               This is accomplished by passing an array rather than a script:
   //               jmolHref([myfunc,"my param 1", "my param 2"], "testing")
   //               function myfunc(jmolControlObject, [myfunc,"my param 1", "my param 2"], target){...}
   //               and allows much more flexibility with responding to controls
   // bh 4/2010  -- added jmolSetMemoryMb(nMb)
   // ah 1/2011  -- wider detection of browsers; more browsers now use the object tag instead of the applet tag;
   //               fix of object tag (removed classid) accounts for change of behavior in Chrome
   // bh 5/2013  -- fix for master checkbox click not actuating checkboxes
   
 var defaultdir = "."  var defaultdir = "."
 var defaultjar = "JmolApplet.jar"  var defaultjar = "JmolApplet.jar"
   
   
   // Note added 12:41 PM 9/21/2008 by Bob Hanson, hansonr@stolaf.edu:
   
   // JMOLJAR=xxxxx.jar on the URL for this page will override
   // the JAR file specified in the jmolInitialize() call.
   
   // The idea is that it can be very useful to test a web page with different JAR files
   // Or for an expert user to substitute a signed applet for an unsigned one
   // so as to use a broader range of models or to create JPEG files, for example.
   
   // If the JAR file is not in the current directory (has any sort of "/" in its name)
   // then the user is presented with a warning and asked whether it is OK to change Jar files.
   // The default action, if the user just presses "OK" is to NOT allow the change.
   // The user must type the word "yes" in the prompt box for the change to be approved.
   
   // If you don't want people to be able to switch in their own JAR file on your page,
   // simply set this next line to read "var allowJMOLJAR = false".
   
   
 var undefined; // for IE 5 ... wherein undefined is undefined  var undefined; // for IE 5 ... wherein undefined is undefined
   
 ////////////////////////////////////////////////////////////////  ////////////////////////////////////////////////////////////////
Line 67  var undefined; // for IE 5 ... wherein u Line 121  var undefined; // for IE 5 ... wherein u
 ////////////////////////////////////////////////////////////////  ////////////////////////////////////////////////////////////////
   
 function jmolInitialize(codebaseDirectory, fileNameOrUseSignedApplet) {  function jmolInitialize(codebaseDirectory, fileNameOrUseSignedApplet) {
   if (_jmol.initialized) {    if (_jmol.initialized)
     //alert("jmolInitialize() should only be called *ONCE* within a page");  
     return;      return;
     _jmol.initialized = true;
     if(_jmol.jmoljar) {
       var f = _jmol.jmoljar;
       if (f.indexOf("/") >= 0) {
         alert ("This web page URL is requesting that the applet used be " + f + ". This is a possible security risk, particularly if the applet is signed, because signed applets can read and write files on your local machine or network.")
         var ok = prompt("Do you want to use applet " + f + "? ","yes or no")
         if (ok == "yes") {
           codebaseDirectory = f.substring(0, f.lastIndexOf("/"));
           fileNameOrUseSignedApplet = f.substring(f.lastIndexOf("/") + 1);
         } else {
     _jmolGetJarFilename(fileNameOrUseSignedApplet);
           alert("The web page URL was ignored. Continuing using " + _jmol.archivePath + ' in directory "' + codebaseDirectory + '"');
         }
       } else {
         fileNameOrUseSignedApplet = f;
       }
   }    }
   if (! codebaseDirectory) {  
     alert("codebaseDirectory is a required parameter to jmolInitialize");  
     codebaseDirectory = ".";  
   }  
   
   if (codebaseDirectory.indexOf("http://") == 0 ||  
       codebaseDirectory.indexOf("https://") == 0)  
     alert("In general, an absolute URL is not recommended for codebaseDirectory.\n" +  
   "A directory- or docroot-relative reference is recommended.\n\n" +  
   "If you need to use an absolute URL (because, for example, the JAR and data\n" +  
   "files are on another server), then insert a space before\n" +  
   "\"http\" in your URL to avoid this warning message.");  
   
   _jmolSetCodebase(codebaseDirectory);    _jmolSetCodebase(codebaseDirectory);
   _jmolGetJarFilename(fileNameOrUseSignedApplet);    _jmolGetJarFilename(fileNameOrUseSignedApplet);
   _jmolOnloadResetForms();    _jmolOnloadResetForms();
   _jmol.initialized = true;  
 }  }
   
 function jmolSetTranslation(TF) {  function jmolSetTranslation(TF) {
Line 120  function jmolSetAppletColor(boxbgcolor, Line 175  function jmolSetAppletColor(boxbgcolor,
           " progresscolor=" + _jmol.params.progresscolor);            " progresscolor=" + _jmol.params.progresscolor);
 }  }
   
   function jmolSetAppletWindow(w) {
     _jmol.appletWindow = w;
   }
   
 function jmolApplet(size, script, nameSuffix) {  function jmolApplet(size, script, nameSuffix) {
   _jmolInitCheck();    _jmolInitCheck();
   return _jmolApplet(size, null, script, nameSuffix);    return _jmolApplet(size, null, script, nameSuffix);
Line 129  function jmolApplet(size, script, nameSu Line 188  function jmolApplet(size, script, nameSu
 // Basic controls  // Basic controls
 ////////////////////////////////////////////////////////////////  ////////////////////////////////////////////////////////////////
   
   // undefined means it wasn't there; null means it was explicitly listed as null (so as to skip it)
   
 function jmolButton(script, label, id, title) {  function jmolButton(script, label, id, title) {
   _jmolInitCheck();    _jmolInitCheck();
   if (id == undefined || id == null)    id != undefined && id != null || (id = "jmolButton" + _jmol.buttonCount);
     id = "jmolButton" + _jmol.buttonCount;    label != undefined && label != null || (label = script.substring(0, 32));
   if (label == undefined || label == null)  
     label = script.substring(0, 32);  
   ++_jmol.buttonCount;    ++_jmol.buttonCount;
   var scriptIndex = _jmolAddScript(script);    var scriptIndex = _jmolAddScript(script);
   var t = "<span id=\"span_"+id+"\""+(title ? " title =\"" + title + "\"":"")+"><input type='button' name='" + id + "' id='" + id +    var t = "<span id=\"span_"+id+"\""+(title ? " title=\"" + title + "\"":"")+"><input type='button' name='" + id + "' id='" + id +
           "' value='" + label +            "' value='" + label +
           "' onClick='_jmolClick(" + scriptIndex + _jmol.targetText +            "' onclick='_jmolClick(this," + scriptIndex + _jmol.targetText +
           ")' onMouseover='_jmolMouseOver(" + scriptIndex +            ")' onmouseover='_jmolMouseOver(" + scriptIndex +
           ");return true' onMouseout='_jmolMouseOut()' " +            ");return true' onmouseout='_jmolMouseOut()' " +
           _jmol.buttonCssText + "/></span>";            _jmol.buttonCssText + " /></span>";
   if (_jmol.debugAlert)    if (_jmol.debugAlert)
     alert(t);      alert(t);
   return _jmolDocumentWrite(t);    return _jmolDocumentWrite(t);
Line 151  function jmolButton(script, label, id, t Line 210  function jmolButton(script, label, id, t
 function jmolCheckbox(scriptWhenChecked, scriptWhenUnchecked,  function jmolCheckbox(scriptWhenChecked, scriptWhenUnchecked,
                       labelHtml, isChecked, id, title) {                        labelHtml, isChecked, id, title) {
   _jmolInitCheck();    _jmolInitCheck();
   if (id == undefined || id == null)    id != undefined && id != null || (id = "jmolCheckbox" + _jmol.checkboxCount);
     id = "jmolCheckbox" + _jmol.checkboxCount;  
   ++_jmol.checkboxCount;    ++_jmol.checkboxCount;
   if (scriptWhenChecked == undefined || scriptWhenChecked == null ||    if (scriptWhenChecked == undefined || scriptWhenChecked == null ||
       scriptWhenUnchecked == undefined || scriptWhenUnchecked == null) {        scriptWhenUnchecked == undefined || scriptWhenUnchecked == null) {
Line 166  function jmolCheckbox(scriptWhenChecked, Line 224  function jmolCheckbox(scriptWhenChecked,
   var indexChecked = _jmolAddScript(scriptWhenChecked);    var indexChecked = _jmolAddScript(scriptWhenChecked);
   var indexUnchecked = _jmolAddScript(scriptWhenUnchecked);    var indexUnchecked = _jmolAddScript(scriptWhenUnchecked);
   var eospan = "</span>"    var eospan = "</span>"
   var t = "<span id=\"span_"+id+"\""+(title ? " title =\"" + title + "\"":"")+"><input type='checkbox' name='" + id + "' id='" + id +    var t = "<span id=\"span_"+id+"\""+(title ? " title=\"" + title + "\"":"")+"><input type='checkbox' name='" + id + "' id='" + id +
           "' onClick='_jmolCbClick(this," +            "' onclick='_jmolCbClick(this," +
           indexChecked + "," + indexUnchecked + _jmol.targetText +            indexChecked + "," + indexUnchecked + _jmol.targetText +
           ")' onMouseover='_jmolCbOver(this," + indexChecked + "," +            ")' onmouseover='_jmolCbOver(this," + indexChecked + "," +
           indexUnchecked +            indexUnchecked +
           ");return true' onMouseout='_jmolMouseOut()' " +            ");return true' onmouseout='_jmolMouseOut()' " +
   (isChecked ? "checked " : "") + _jmol.checkboxCssText + "/>"      (isChecked ? "checked='true' " : "")+ _jmol.checkboxCssText + " />"
   if (labelHtml.toLowerCase().indexOf("<td>")>=0) {    if (labelHtml.toLowerCase().indexOf("<td>")>=0) {
  t += eospan    t += eospan
  eospan = "";    eospan = "";
   }    }
   t += labelHtml +eospan;    t += "<label for=\"" + id + "\">" + labelHtml + "</label>" +eospan;
   if (_jmol.debugAlert)    if (_jmol.debugAlert)
     alert(t);      alert(t);
   return _jmolDocumentWrite(t);    return _jmolDocumentWrite(t);
Line 201  function jmolRadioGroup(arrayOfRadioButt Line 259  function jmolRadioGroup(arrayOfRadioButt
     alert("invalid arrayOfRadioButtons");      alert("invalid arrayOfRadioButtons");
     return;      return;
   }    }
   if (separatorHtml == undefined || separatorHtml == null)    separatorHtml != undefined && separatorHtml != null || (separatorHtml = "&nbsp; ");
     separatorHtml = "&nbsp; ";  
   var len = arrayOfRadioButtons.length;    var len = arrayOfRadioButtons.length;
   jmolStartNewRadioGroup();    jmolStartNewRadioGroup();
   if (!groupName)    groupName || (groupName = "jmolRadioGroup" + (_jmol.radioGroupCount - 1));
     groupName = "jmolRadioGroup" + (_jmol.radioGroupCount - 1);  
   var t = "<span id='"+(id ? id : groupName)+"'>";    var t = "<span id='"+(id ? id : groupName)+"'>";
   for (var i = 0; i < len; ++i) {    for (var i = 0; i < len; ++i) {
     if (i == len - 1)      if (i == len - 1)
Line 238  function jmolRadio(script, labelHtml, is Line 294  function jmolRadio(script, labelHtml, is
   
 function jmolLink(script, label, id, title) {  function jmolLink(script, label, id, title) {
   _jmolInitCheck();    _jmolInitCheck();
   if (id == undefined || id == null)    id != undefined && id != null || (id = "jmolLink" + _jmol.linkCount);
     id = "jmolLink" + _jmol.linkCount;    label != undefined && label != null || (label = script.substring(0, 32));
   if (label == undefined || label == null)  
     label = script.substring(0, 32);  
   ++_jmol.linkCount;    ++_jmol.linkCount;
   var scriptIndex = _jmolAddScript(script);    var scriptIndex = _jmolAddScript(script);
   var t = "<span id=\"span_"+id+"\""+(title ? " title =\"" + title + "\"":"")+"><a name='" + id + "' id='" + id +    var t = "<span id=\"span_"+id+"\""+(title ? " title=\"" + title + "\"":"")+"><a name='" + id + "' id='" + id +
           "' href='javascript:_jmolClick(" + scriptIndex + _jmol.targetText + ");' onMouseover='_jmolMouseOver(" + scriptIndex +            "' href='javascript:_jmolClick(this," + scriptIndex + _jmol.targetText + ");' onmouseover='_jmolMouseOver(" + scriptIndex +
           ");return true;' onMouseout='_jmolMouseOut()' " +            ");return true;' onmouseout='_jmolMouseOut()' " +
           _jmol.linkCssText + ">" + label + "</a></span>";            _jmol.linkCssText + ">" + label + "</a></span>";
   if (_jmol.debugAlert)    if (_jmol.debugAlert)
     alert(t);      alert(t);
Line 255  function jmolLink(script, label, id, tit Line 309  function jmolLink(script, label, id, tit
   
 function jmolCommandInput(label, size, id, title) {  function jmolCommandInput(label, size, id, title) {
   _jmolInitCheck();    _jmolInitCheck();
   if (id == undefined || id == null)    id != undefined && id != null || (id = "jmolCmd" + _jmol.cmdCount);
     id = "jmolCmd" + _jmol.cmdCount;    label != undefined && label != null || (label = "Execute");
   if (label == undefined || label == null)    size != undefined && !isNaN(size) || (size = 60);
     label = "Execute";  
   if (size == undefined || isNaN(size))  
     size = 60;  
   ++_jmol.cmdCount;    ++_jmol.cmdCount;
   var t = "<span id=\"span_"+id+"\""+(title ? " title =\"" + title + "\"":"")+"><input name='" + id + "' id='" + id +    var t = "<span id=\"span_"+id+"\""+(title ? " title=\"" + title + "\"":"")+"><input name='" + id + "' id='" + id +
           "' size='"+size+"'><input type=button value = '"+label+"' onClick='jmolScript(document.getElementById(\""+id+"\").value" + _jmol.targetText + ")'/></span>";            "' size='"+size+"' onkeypress='_jmolCommandKeyPress(event,\""+id+"\"" + _jmol.targetText + ")'><input type=button value = '"+label+"' onclick='jmolScript(document.getElementById(\""+id+"\").value" + _jmol.targetText + ")' /></span>";
   if (_jmol.debugAlert)    if (_jmol.debugAlert)
     alert(t);      alert(t);
   return _jmolDocumentWrite(t);    return _jmolDocumentWrite(t);
 }  }
   
   function _jmolCommandKeyPress(e, id, target) {
     var keycode = (window.event ? window.event.keyCode : e ? e.which : 0);
     if (keycode == 13) {
       var inputBox = document.getElementById(id)
       _jmolScriptExecute(inputBox, inputBox.value, target)
     }
   }
   
   function _jmolScriptExecute(element,script,target) {
     if (typeof(script) == "object")
       script[0](element, script, target)
    else if (typeof(script) == "function")
     script(target);
     else
       jmolScript(script, target)
   }
   
 function jmolMenu(arrayOfMenuItems, size, id, title) {  function jmolMenu(arrayOfMenuItems, size, id, title) {
   _jmolInitCheck();    _jmolInitCheck();
   if (id == undefined || id == null)    id != undefined && id != null || (id = "jmolMenu" + _jmol.menuCount);
     id = "jmolMenu" + _jmol.menuCount;  
   ++_jmol.menuCount;    ++_jmol.menuCount;
   var type = typeof arrayOfMenuItems;    var type = typeof arrayOfMenuItems;
   if (type != null && type == "object" && arrayOfMenuItems.length) {    if (type != null && type == "object" && arrayOfMenuItems.length) {
Line 282  function jmolMenu(arrayOfMenuItems, size Line 349  function jmolMenu(arrayOfMenuItems, size
     else if (size < 0)      else if (size < 0)
       size = len;        size = len;
     var sizeText = size ? " size='" + size + "' " : "";      var sizeText = size ? " size='" + size + "' " : "";
     var t = "<span id=\"span_"+id+"\""+(title ? " title =\"" + title + "\"":"")+"><select name='" + id + "' id='" + id +      var t = "<span id=\"span_"+id+"\""+(title ? " title=\"" + title + "\"":"")+"><select name='" + id + "' id='" + id +
             "' onChange='_jmolMenuSelected(this" + _jmol.targetText + ")'" +              "' onChange='_jmolMenuSelected(this" + _jmol.targetText + ")'" +
             sizeText + _jmol.menuCssText + ">";              sizeText + _jmol.menuCssText + ">";
     for (var i = 0; i < len; ++i) {      for (var i = 0; i < len; ++i) {
Line 297  function jmolMenu(arrayOfMenuItems, size Line 364  function jmolMenu(arrayOfMenuItems, size
       } else {        } else {
         script = text = menuItem;          script = text = menuItem;
       }        }
       if (text == undefined || text == null)        text != undefined && text != null || (text = script);
         text = script;        if (script=="#optgroup") {
   if (script=="#optgroup") {          t += "<optgroup label='" + text + "'>";
         t += "<optgroup label='" + text + "'>";        } else if (script=="#optgroupEnd") {
   } else if (script=="#optgroupEnd") {          t += "</optgroup>";
         t += "</optgroup>";        } else {
   } else {  
         var scriptIndex = _jmolAddScript(script);          var scriptIndex = _jmolAddScript(script);
         var selectedText = isSelected ? "' selected>" : "'>";          var selectedText = isSelected ? "' selected='true'>" : "'>";
         t += "<option value='" + scriptIndex + selectedText + text + "</option>";          t += "<option value='" + scriptIndex + selectedText + text + "</option>";
   }        }
     }      }
     t += "</select></span>";      t += "</select></span>";
     if (_jmol.debugAlert)      if (_jmol.debugAlert)
Line 340  function jmolAppletInline(size, inlineMo Line 406  function jmolAppletInline(size, inlineMo
   
 function jmolSetTarget(targetSuffix) {  function jmolSetTarget(targetSuffix) {
   _jmol.targetSuffix = targetSuffix;    _jmol.targetSuffix = targetSuffix;
   _jmol.targetText = targetSuffix ? ",\"" + targetSuffix + "\"" : "";    _jmol.targetText = targetSuffix ? ",\"" + targetSuffix + "\"" : ",0";
 }  }
   
 function jmolScript(script, targetSuffix) {  function jmolScript(script, targetSuffix) {
Line 348  function jmolScript(script, targetSuffix Line 414  function jmolScript(script, targetSuffix
     _jmolCheckBrowser();      _jmolCheckBrowser();
     if (targetSuffix == "all") {      if (targetSuffix == "all") {
       with (_jmol) {        with (_jmol) {
  for (var i = 0; i < appletSuffixes.length; ++i) {    for (var i = 0; i < appletSuffixes.length; ++i) {
   var applet = _jmolGetApplet(appletSuffixes[i]);      var applet = _jmolGetApplet(appletSuffixes[i]);
           if (applet) applet.script(script);            if (applet) applet.script(script);
         }          }
       }        }
Line 361  function jmolScript(script, targetSuffix Line 427  function jmolScript(script, targetSuffix
 }  }
   
 function jmolLoadInline(model, targetSuffix) {  function jmolLoadInline(model, targetSuffix) {
   if (!model)return    if (!model)return "ERROR: NO MODEL"
   var applet=_jmolGetApplet(targetSuffix);    var applet=_jmolGetApplet(targetSuffix);
   if (applet)applet.loadInline(model);    if (!applet)return "ERROR: NO APPLET"
     if (typeof(model) == "string")
       return applet.loadInlineString(model, "", false);
     else
       return applet.loadInlineArray(model, "", false);
 }  }
   
   
 function jmolLoadInlineScript(model, script, targetSuffix) {  function jmolLoadInlineScript(model, script, targetSuffix) {
   if (!model)return    if (!model)return "ERROR: NO MODEL"
   var applet=_jmolGetApplet(targetSuffix);    var applet=_jmolGetApplet(targetSuffix);
   if (applet)applet.loadInline(model, script);    if (!applet)return "ERROR: NO APPLET"
     return applet.loadInlineString(model, script, false);
 }  }
   
   
 function jmolLoadInlineArray(ModelArray, script, targetSuffix) {  function jmolLoadInlineArray(ModelArray, script, targetSuffix) {
   if (!model)return    if (!model)return "ERROR: NO MODEL"
   if (!script)script=""    script || (script="")
     var applet=_jmolGetApplet(targetSuffix);
     if (!applet)return "ERROR: NO APPLET"
     try {
       return applet.loadInlineArray(ModelArray, script, false);
     } catch (err) {
       //IE 7 bug
       return applet.loadInlineString(ModelArray.join("\n"), script, false);
     }
   }
   
   function jmolAppendInlineArray(ModelArray, script, targetSuffix) {
     if (!model)return "ERROR: NO MODEL"
     script || (script="")
     var applet=_jmolGetApplet(targetSuffix);
     if (!applet)return "ERROR: NO APPLET"
     try {
       return applet.loadInlineArray(ModelArray, script, true);
     } catch (err) {
       //IE 7 bug
       return applet.loadInlineString(ModelArray.join("\n"), script, true);
     }
   }
   
   function jmolAppendInlineScript(model, script, targetSuffix) {
     if (!model)return "ERROR: NO MODEL"
   var applet=_jmolGetApplet(targetSuffix);    var applet=_jmolGetApplet(targetSuffix);
   if (applet)applet.loadInlineArray(ModelArray, script);    if (!applet)return "ERROR: NO APPLET"
     return applet.loadInlineString(model, script, true);
 }  }
   
 function jmolCheckBrowser(action, urlOrMessage, nowOrLater) {  function jmolCheckBrowser(action, urlOrMessage, nowOrLater) {
   if (typeof action == "string") {    if (typeof action == "string") {
     action = action.toLowerCase();      action = action.toLowerCase();
     if (action != "alert" && action != "redirect" && action != "popup")      action == "alert" || action == "redirect" || action == "popup" || (action = null);
       action = null;  
   }    }
   if (typeof action != "string")    if (typeof action != "string")
     alert("jmolCheckBrowser(action, urlOrMessage, nowOrLater)\n\n" +      alert("jmolCheckBrowser(action, urlOrMessage, nowOrLater)\n\n" +
Line 455  var _jmol = { Line 553  var _jmol = {
   currentDocument: document,    currentDocument: document,
   
   debugAlert: false,    debugAlert: false,
    
   codebase: ".",    codebase: "",
   modelbase: ".",    modelbase: ".",
    
   appletCount: 0,    appletCount: 0,
   appletSuffixes: [],    appletSuffixes: [],
      appletWindow: null,
     allowedJmolSize: [25, 2048, 300],   // min, max, default (pixels)
       /*  By setting the _jmol.allowedJmolSize[] variable in the webpage
           before calling jmolApplet(), limits for applet size can be overriden.
           2048 standard for GeoWall (http://geowall.geo.lsa.umich.edu/home.html)
       */
   buttonCount: 0,    buttonCount: 0,
   checkboxCount: 0,    checkboxCount: 0,
   linkCount: 0,    linkCount: 0,
Line 469  var _jmol = { Line 572  var _jmol = {
   menuCount: 0,    menuCount: 0,
   radioCount: 0,    radioCount: 0,
   radioGroupCount: 0,    radioGroupCount: 0,
    
   appletCssClass: null,    appletCssClass: null,
   appletCssText: "",    appletCssText: "",
   buttonCssClass: null,    buttonCssClass: null,
   buttonCssText: "",    buttonCssText: "",
   checkboxCssClass: null,    checkboxCssClass: null,
   checkboxCssText: "",    checkboxCssText: "",
     java_arguments: "-Xmx512m",
   radioCssClass: null,    radioCssClass: null,
   radioCssText: "",    radioCssText: "",
   linkCssClass: null,    linkCssClass: null,
   linkCssText: "",    linkCssText: "",
   menuCssClass: null,    menuCssClass: null,
   menuCssText: "",    menuCssText: "",
    
   targetSuffix: 0,    targetSuffix: 0,
   targetText: "",    targetText: ",0",
   scripts: [""],    scripts: [""],
   params: {    params: {
  progressbar: "true",    syncId: ("" + Math.random()).substring(3),
  progresscolor: "blue",    progressbar: "true",
  boxbgcolor: "black",    progresscolor: "blue",
  boxfgcolor: "white",    boxbgcolor: "black",
  boxmessage: "Downloading JmolApplet ..."    boxfgcolor: "white",
     boxmessage: "Downloading JmolApplet ..."
   },    },
   ua: navigator.userAgent.toLowerCase(),    ua: navigator.userAgent.toLowerCase(),
   uaVersion: parseFloat(navigator.appVersion),    // uaVersion: parseFloat(navigator.appVersion),  // not used
    
   os: "unknown",    os: "unknown",
   browser: "unknown",    browser: "unknown",
   browserVersion: 0,    browserVersion: 0,
   hasGetElementById: !!document.getElementById,    hasGetElementById: !!document.getElementById,
   isJavaEnabled: navigator.javaEnabled(),    isJavaEnabled: navigator.javaEnabled(),
   isNetscape47Win: false,    // isNetscape47Win: false,  // not used, N4.7 is no longer supported even for detection
   isIEWin: false,  
   useIEObject: false,    useIEObject: false,
   useHtml4Object: false,    useHtml4Object: false,
    
   windowsClassId: "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93",    windowsClassId: "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93",
   windowsCabUrl:    windowsCabUrl:
    "http://java.sun.com/update/1.5.0/jinstall-1_5_0_05-windows-i586.cab",     "http://java.sun.com/update/1.6.0/jinstall-6u22-windows-i586.cab",
   
   isBrowserCompliant: false,    isBrowserCompliant: false,
   isJavaCompliant: false,    isJavaCompliant: false,
Line 516  var _jmol = { Line 620  var _jmol = {
   
   initialized: false,    initialized: false,
   initChecked: false,    initChecked: false,
    
   browserChecked: false,    browserChecked: false,
   checkBrowserAction: "alert",    checkBrowserAction: "alert",
   checkBrowserUrlOrMessage: null,    checkBrowserUrlOrMessage: null,
Line 524  var _jmol = { Line 628  var _jmol = {
   archivePath: null, // JmolApplet0.jar OR JmolAppletSigned0.jar    archivePath: null, // JmolApplet0.jar OR JmolAppletSigned0.jar
   
   previousOnloadHandler: null,    previousOnloadHandler: null,
   
     jmoljar: null,
     useNoApplet: false,
   
   ready: {}    ready: {}
 }  }
   
 with (_jmol) {  with (_jmol) {
   
   function _jmolTestUA(candidate) {    function _jmolTestUA(candidate) {
     var ua = _jmol.ua;      var ua = _jmol.ua;
     var index = ua.indexOf(candidate);      var index = ua.indexOf(candidate);
Line 538  with (_jmol) { Line 645  with (_jmol) {
     _jmol.browserVersion = parseFloat(ua.substring(index+candidate.length+1));      _jmol.browserVersion = parseFloat(ua.substring(index+candidate.length+1));
     return true;      return true;
   }    }
    
   function _jmolTestOS(candidate) {    function _jmolTestOS(candidate) {
     if (_jmol.ua.indexOf(candidate) < 0)      if (_jmol.ua.indexOf(candidate) < 0)
       return false;        return false;
     _jmol.os = candidate;      _jmol.os = candidate;
     return true;      return true;
   }    }
    
   _jmolTestUA("konqueror") ||    _jmolTestUA("konqueror") ||
   _jmolTestUA("safari") ||    _jmolTestUA("webkit") ||
   _jmolTestUA("omniweb") ||    _jmolTestUA("omniweb") ||
   _jmolTestUA("opera") ||    _jmolTestUA("opera") ||
   _jmolTestUA("webtv") ||    _jmolTestUA("webtv") ||
   _jmolTestUA("icab") ||    _jmolTestUA("icab") ||
   _jmolTestUA("msie") ||    _jmolTestUA("msie") ||
   (_jmol.ua.indexOf("compatible") < 0 && _jmolTestUA("mozilla"));    (_jmol.ua.indexOf("compatible") < 0 && _jmolTestUA("mozilla")); //Netscape, Mozilla, Seamonkey, Firefox and anything assimilated
    
   _jmolTestOS("linux") ||    _jmolTestOS("linux") ||
   _jmolTestOS("unix") ||    _jmolTestOS("unix") ||
   _jmolTestOS("mac") ||    _jmolTestOS("mac") ||
   _jmolTestOS("win");    _jmolTestOS("win");
   
   isNetscape47Win = (os == "win" && browser == "mozilla" &&    isBrowserCompliant = hasGetElementById;
                      browserVersion >= 4.78 && browserVersion <= 4.8);    // known exceptions (old browsers):
     if (browser == "opera" && browserVersion <= 7.54 && os == "mac"
   if (os == "win") {        || browser == "webkit" && browserVersion < 125.12
     isBrowserCompliant = hasGetElementById;        || browser == "msie" && os == "mac"
   } else if (os == "mac") { // mac is the problem child :-(        || browser == "konqueror" && browserVersion <= 3.3
     if (browser == "mozilla" && browserVersion >= 5) {      ) {
       // miguel 2004 11 17      isBrowserCompliant = false;
       // checking the plugins array does not work because  
       // 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');" +  
            " _jmol.isBrowserCompliant = v >= '1.4.2';" +  
            " } catch (e) { }");  
     } else if (browser == "opera" && browserVersion <= 7.54) {  
       isBrowserCompliant = false;  
     } else {  
       isBrowserCompliant = hasGetElementById &&  
         !((browser == "msie") ||  
           (browser == "safari" && browserVersion < 125.12));  
     }  
   } else if (os == "linux" || os == "unix") {  
     if (browser == "konqueror" && browserVersion <= 3.3)  
       isBrowserCompliant = false;  
     else  
       isBrowserCompliant = hasGetElementById;  
   } else { // other OS  
     isBrowserCompliant = hasGetElementById;  
   }    }
   
   // possibly more checks in the future for this    // possibly more checks in the future for this
Line 595  with (_jmol) { Line 682  with (_jmol) {
   
   isFullyCompliant = isBrowserCompliant && isJavaCompliant;    isFullyCompliant = isBrowserCompliant && isJavaCompliant;
   
   // IE5.5 works just fine ... but let's push them to Sun Java    useIEObject = (os == "win" && browser == "msie" && browserVersion >= 5.5);
   isIEWin = (os == "win" && browser == "msie" && browserVersion >= 5.5);  
   useIEObject = isIEWin;  
   useHtml4Object =    useHtml4Object =
    (os != "mac" && browser == "mozilla" && browserVersion >= 5) ||     (browser == "mozilla" && browserVersion >= 5) ||
    (os == "win" && browser == "opera" && browserVersion >= 8) ||     (browser == "opera" && browserVersion >= 8) ||
    (os == "mac" && browser == "safari" && browserVersion >= 412.2);     (browser == "webkit" && browserVersion >= 412.2);
    try {
     if (top.location.search.indexOf("JMOLJAR=")>=0)
       jmoljar = top.location.search.split("JMOLJAR=")[1].split("&")[0];
    } catch(e) {
     // can't access top.location
    }
    try {
     useNoApplet = (top.location.search.indexOf("NOAPPLET")>=0);
    } catch(e) {
     // can't access top.document
    }
   }
   
   function jmolSetMemoryMb(nMb) {
     _jmol.java_arguments = "-Xmx" + Math.round(nMb) + "m"
   }
   
  doTranslate = true;  function jmolSetParameter(name,value) {
  haveSetTranslate = false;    _jmol.params[name] = value
 }  }
   
 function jmolSetCallback(callbackName,funcName) {  function jmolSetCallback(callbackName,funcName) {
   _jmol.params[callbackName] = funcName    _jmol.params[callbackName] = funcName
 }  }
   
    try {
   // note this is done FIRST, so it cannot override a setting done by the developer
     if (top.location.search.indexOf("PARAMS=")>=0) {
       var pars = unescape(top.location.search.split("PARAMS=")[1].split("&")[0]).split(";");
       for (var i = 0; i < pars.length; i++) {
         var p = pars[i].split(":");
         jmolSetParameter(p[0],p[1]);
       }
     }
    } catch(e) {
     // can't access top.location
    }
   
   function jmolSetSyncId(n) {
     return _jmol.params["syncId"] = n
   }
   
   function jmolGetSyncId() {
     return _jmol.params["syncId"]
   }
   
 function jmolSetLogLevel(n) {  function jmolSetLogLevel(n) {
   _jmol.params.logLevel = ''+n;    _jmol.params.logLevel = ''+n;
 }  }
   
  /*  AngelH, mar2007:    /*  AngelH, mar2007:
  By (re)setting these variables in the webpage before calling jmolApplet(),      By (re)setting these variables in the webpage before calling jmolApplet(),
  a custom message can be provided (e.g. localized for user's language) when no Java is installed.      a custom message can be provided (e.g. localized for user's language) when no Java is installed.
  */    */
 if (noJavaMsg==undefined) var noJavaMsg =  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" +          "You do not have Java applets enabled in your web browser, or your browser is blocking this applet.<br />\n" +
         "Check the warning message from your browser and/or enable Java applets in<br />\n" +          "Check the warning message from your browser and/or enable Java applets in<br />\n" +
         "your web browser preferences, or install the Java Runtime Environment from <a href='http://www.java.com'>www.java.com</a><br />";          "your web browser preferences, or install the Java Runtime Environment from <a href='http://www.java.com'>www.java.com</a><br />";
 if (noJavaMsg2==undefined) var noJavaMsg2 =  if (noJavaMsg2==undefined) var noJavaMsg2 =
         "You do not have the<br />\n" +          "You do not have the<br />\n" +
         "Java Runtime Environment<br />\n" +          "Java Runtime Environment<br />\n" +
         "installed for applet support.<br />\n" +          "installed for applet support.<br />\n" +
         "Visit <a href='http://www.java.com'>www.java.com</a>";          "Visit <a href='http://www.java.com'>www.java.com</a>";
 function _jmolApplet(size, inlineModel, script, nameSuffix) {  function _jmolApplet(size, inlineModel, script, nameSuffix) {
  /*  AngelH, mar2007    /*  AngelH, mar2007
  Fixed percent / pixel business, to avoid browser errors:      Fixed percent / pixel business, to avoid browser errors:
  put "px" where needed, avoid where not.      put "px" where needed, avoid where not.
  */  
         Bob Hanson, 1/2010
       Fixed inline escape changing returns to |
     */
   with (_jmol) {    with (_jmol) {
     if (! nameSuffix)      nameSuffix == undefined && (nameSuffix = appletCount);
       nameSuffix = appletCount;  
     appletSuffixes.push(nameSuffix);      appletSuffixes.push(nameSuffix);
     ++appletCount;      ++appletCount;
     if (! script)      script || (script = "select *");
       script = "select *";  
     var sz = _jmolGetAppletSize(size);      var sz = _jmolGetAppletSize(size);
     var widthAndHeight = " width='" + sz[0] + "' height='" + sz[1] + "' ";      var widthAndHeight = " width='" + sz[0] + "' height='" + sz[1] + "' ";
     var tHeader, tFooter;      var tHeader, tFooter;
       codebase || jmolInitialize(".");
       params.name = "jmolApplet" + nameSuffix
       params.permissions = (archivePath.indexOf("Signed") >= 0 ? "all-permissions" : "sandbox");
      
     if (useIEObject || useHtml4Object) {      if (useIEObject || useHtml4Object) {
       params.name = 'jmolApplet' + nameSuffix;  
       params.archive = archivePath;        params.archive = archivePath;
       params.mayscript = 'true';        params.mayscript = 'true';
       params.codebase = codebase;        params.codebase = codebase;
     }        params.code = 'JmolApplet.class';
     if (useIEObject) { // use MSFT IE6 object tag with .cab file reference        tHeader =
       winCodebase = (windowsCabUrl ? " codebase='" + windowsCabUrl + "'\n" : "");  
       tHeader =  
         "<object name='jmolApplet" + nameSuffix +          "<object name='jmolApplet" + nameSuffix +
         "' id='jmolApplet" + nameSuffix + "' " + appletCssText + "\n" +          "' id='jmolApplet" + nameSuffix + "' " + appletCssText + "\n" +
  " classid='" + windowsClassId + "'\n" + winCodebase + widthAndHeight + ">\n";          widthAndHeight + "\n";
         params.code = 'JmolApplet';  
       tFooter = "</object>";        tFooter = "</object>";
       }
       if (java_arguments)
         params.java_arguments = java_arguments;
       if (useIEObject) { // use MSFT IE6 object tag with .cab file reference
         tHeader += " classid='" + windowsClassId + "'\n" +
         (windowsCabUrl ? " codebase='" + windowsCabUrl + "'\n" : "") + ">\n";
     } else if (useHtml4Object) { // use HTML4 object tag      } else if (useHtml4Object) { // use HTML4 object tag
       tHeader =        tHeader += " type='application/x-java-applet'\n>\n";
         "<object name='jmolApplet" + nameSuffix +          /*  " classid='java:JmolApplet'\n" +  AH removed this
         "' id='jmolApplet" + nameSuffix + "' " + appletCssText + "\n" +            Chromium Issue 62076:   Java Applets using an <object> with a classid paramater don't load.
  " classid='java:JmolApplet'\n" +            http://code.google.com/p/chromium/issues/detail?id=62076
         " type='application/x-java-applet'\n" +            They say this is the correct behavior according to the spec, and there's no indication at this point
         widthAndHeight + ">\n";            that WebKit will be changing the handling, so eventually Safari will acquire this behavior too.
       tFooter = "</object>";            Removing the classid parameter seems to be well tolerated by all browsers (even IE!).
           */
     } else { // use applet tag      } else { // use applet tag
       tHeader =        tHeader =
         "<applet name='jmolApplet" + nameSuffix +          "<applet name='jmolApplet" + nameSuffix +
         "' id='jmolApplet" + nameSuffix +          "' id='jmolApplet" + nameSuffix + "' " + appletCssText + "\n" +
         "' " + appletCssText +          widthAndHeight + "\n" +
         " code='JmolApplet'" +          " code='JmolApplet'" +
         " archive='" + archivePath + "' codebase='" + codebase + "'\n" +          " archive='" + archivePath + "' codebase='" + codebase + "'\n" +
  widthAndHeight +  
         " mayscript='true'>\n";          " mayscript='true'>\n";
       tFooter = "</applet>";        tFooter = "</applet>";
     }      }
     var visitJava;      var visitJava;
     if (isIEWin || useHtml4Object) {      if (useIEObject || useHtml4Object) {
  var szX = "width:" + sz[0]      var szX = "width:" + sz[0]
  if ( szX.indexOf("%")==-1 ) szX+="px"      if ( szX.indexOf("%")==-1 ) szX+="px"
  var szY = "height:" + sz[1]      var szY = "height:" + sz[1]
  if ( szY.indexOf("%")==-1 ) szY+="px"      if ( szY.indexOf("%")==-1 ) szY+="px"
       visitJava =        visitJava =
         "<p style='background-color:yellow; color:black; " +          "<p style='background-color:yellow; color:black; " +
  szX + ";" + szY + ";" +      szX + ";" + szY + ";" +
         // why doesn't this vertical-align work?          // why doesn't this vertical-align work?
  "text-align:center;vertical-align:middle;'>\n" +    "text-align:center;vertical-align:middle;'>\n" +
  noJavaMsg +      noJavaMsg +
         "</p>";          "</p>";
     } else {      } else {
       visitJava =        visitJava =
         "<table bgcolor='yellow'><tr>" +          "<table bgcolor='yellow'><tr>" +
         "<td align='center' valign='middle' " + widthAndHeight + "><font color='black'>\n" +          "<td align='center' valign='middle' " + widthAndHeight + "><font color='black'>\n" +
  noJavaMsg2 +      noJavaMsg2 +
         "</font></td></tr></table>";          "</font></td></tr></table>";
     }      }
     params.loadInline = (inlineModel ? inlineModel : "");      params.loadInline = (inlineModel ? inlineModel : "");
Line 710  function _jmolApplet(size, inlineModel, Line 838  function _jmolApplet(size, inlineModel,
   
 function _jmolParams() {  function _jmolParams() {
  var t = "";   var t = "";
  for (i in _jmol.params)   for (var i in _jmol.params)
  if(_jmol.params[i]!="")    if(_jmol.params[i]!="")
  t+="  <param name='"+i+"' value='"+_jmol.params[i]+"' />\n";       t+="  <param name='"+i+"' value='"+_jmol.params[i]+"' />\n";
  return t   return t
 }  }
   
Line 720  function _jmolInitCheck() { Line 848  function _jmolInitCheck() {
   if (_jmol.initChecked)    if (_jmol.initChecked)
     return;      return;
   _jmol.initChecked = true;    _jmol.initChecked = true;
   if (_jmol.initialized)  
     return;  
   jmolInitialize(defaultdir, defaultjar)    jmolInitialize(defaultdir, defaultjar)
 }  }
   
Line 730  function _jmolCheckBrowser() { Line 856  function _jmolCheckBrowser() {
     if (browserChecked)      if (browserChecked)
       return;        return;
     browserChecked = true;      browserChecked = true;
    
     if (isFullyCompliant)      if (isFullyCompliant)
       return true;        return true;
   
Line 745  function _jmolCheckBrowser() { Line 871  function _jmolCheckBrowser() {
               "browser: " + browser +                "browser: " + browser +
               "   version: " + browserVersion +                "   version: " + browserVersion +
               "   os: " + os +                "   os: " + os +
                 "   isBrowserCompliant: " + isBrowserCompliant +
                 "   isJavaCompliant: " + isJavaCompliant +
               "\n\n" + ua;                "\n\n" + ua;
       alert(msg);        alert(msg);
     }      }
Line 752  function _jmolCheckBrowser() { Line 880  function _jmolCheckBrowser() {
   return false;    return false;
 }  }
   
   function jmolSetXHTML(id) {
     _jmol.isXHTML = true
     _jmol.XhtmlElement = null
     _jmol.XhtmlAppendChild = false
     if (id){
       _jmol.XhtmlElement = document.getElementById(id)
       _jmol.XhtmlAppendChild = true
     }
   }
   
 function _jmolDocumentWrite(text) {  function _jmolDocumentWrite(text) {
   if (_jmol.currentDocument)    if (_jmol.currentDocument) {
     _jmol.currentDocument.write(text);      if (_jmol.isXHTML && !_jmol.XhtmlElement) {
         var s = document.getElementsByTagName("script")
         _jmol.XhtmlElement = s.item(s.length - 1)
         _jmol.XhtmlAppendChild = false
       }
       if (_jmol.XhtmlElement) {
         _jmolDomDocumentWrite(text)
       } else {
         _jmol.currentDocument.write(text);
       }
     }
   return text;    return text;
 }  }
   
   function _jmolDomDocumentWrite(data) {
     var pt = 0
     var Ptr = []
     Ptr[0] = 0
     while (Ptr[0] < data.length) {
       var child = _jmolGetDomElement(data, Ptr)
       if (!child)break
       if (_jmol.XhtmlAppendChild)
         _jmol.XhtmlElement.appendChild(child)
       else
         _jmol.XhtmlElement.parentNode.insertBefore(child, _jmol.XhtmlElement);
     }
   }
   function _jmolGetDomElement(data, Ptr, closetag, lvel) {
     var e = document.createElement("span")
     e.innerHTML = data
     Ptr[0] = data.length
     return e
   
   //unnecessary?
   
     closetag || (closetag = "")
     lvel || (lvel = 0)
     var pt0 = Ptr[0]
     var pt = pt0
     while (pt < data.length && data.charAt(pt) != "<") pt++
     if (pt != pt0) {
       var text = data.substring(pt0, pt)
       Ptr[0] = pt
       return document.createTextNode(text)
     }
     pt0 = ++pt
     var ch
     while (pt < data.length && "\n\r\t >".indexOf(ch = data.charAt(pt)) < 0) pt++
     var tagname = data.substring(pt0, pt)
     var e = (tagname == closetag  || tagname == "/" ? ""
       : document.createElementNS ? document.createElementNS('http://www.w3.org/1999/xhtml', tagname)
       : document.createElement(tagname));
     if (ch == ">") {
       Ptr[0] = ++pt
       return e
     }
     while (pt < data.length && (ch = data.charAt(pt)) != ">") {
       while (pt < data.length && "\n\r\t ".indexOf(ch = data.charAt(pt)) >= 0) pt++
       pt0 = pt
       while (pt < data.length && "\n\r\t =/>".indexOf(ch = data.charAt(pt)) < 0) pt++
       var attrname = data.substring(pt0, pt).toLowerCase()
       if (attrname && ch != "=")
         e.setAttribute(attrname, "true")
       while (pt < data.length && "\n\r\t ".indexOf(ch = data.charAt(pt)) >= 0) pt++
       if (ch == "/") {
         Ptr[0] = pt + 2
         return e
       } else if (ch == "=") {
         var quote = data.charAt(++pt)
         pt0 = ++pt
         while (pt < data.length && (ch = data.charAt(pt)) != quote) pt++
         var attrvalue = data.substring(pt0, pt)
         e.setAttribute(attrname, attrvalue)
         pt++
       }
     }
     Ptr[0] = ++pt
     while (Ptr[0] < data.length) {
       var child = _jmolGetDomElement(data, Ptr, "/" + tagname, lvel+1)
       if (!child)break
       e.appendChild(child)
     }
     return e
   }
   
 function _jmolPopup(url) {  function _jmolPopup(url) {
   var popup = window.open(url, "JmolPopup",    var popup = window.open(url, "JmolPopup",
                           "left=150,top=150,height=400,width=600," +                            "left=150,top=150,height=400,width=600," +
Line 775  function _jmolReadyCallback(name) { Line 994  function _jmolReadyCallback(name) {
 }  }
   
 function _jmolSterilizeScript(script) {  function _jmolSterilizeScript(script) {
   var inlineScript = script.replace(/'/g, "&#39;");    script = script.replace(/'/g, "&#39;");
   if (_jmol.debugAlert)    if (_jmol.debugAlert)
     alert("script:\n" + inlineScript);      alert("script:\n" + script);
   return inlineScript;    return script;
 }  }
   
 function _jmolSterilizeInline(model) {  function _jmolSterilizeInline(model) {
   var inlineModel =    model = model.replace(/\r|\n|\r\n/g, (model.indexOf("|") >= 0 ? "\\/n" : "|")).replace(/'/g, "&#39;");
     model.replace(/\r|\n|\r\n/g, "|").replace(/'/g, "&#39;");  
   if (_jmol.debugAlert)    if (_jmol.debugAlert)
     alert("inline model:\n" + inlineModel);      alert("inline model:\n" + model);
   return inlineModel;    return model;
 }  
   
  /*  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) {  function _jmolRadio(script, labelHtml, isChecked, separatorHtml, groupName, id, title) {
   ++_jmol.radioCount;    ++_jmol.radioCount;
   if (groupName == undefined || groupName == null)    groupName != undefined && groupName != null || (groupName = "jmolRadioGroup" + (_jmol.radioGroupCount - 1));
     groupName = "jmolRadioGroup" + (_jmol.radioGroupCount - 1);  
   if (!script)    if (!script)
     return "";      return "";
   if (labelHtml == undefined || labelHtml == null)    labelHtml != undefined && labelHtml != null || (labelHtml = script.substring(0, 32));
     labelHtml = script.substring(0, 32);    separatorHtml || (separatorHtml = "")
   if (! separatorHtml)  
     separatorHtml = "";  
   var scriptIndex = _jmolAddScript(script);    var scriptIndex = _jmolAddScript(script);
   var eospan = "</span>"    var eospan = "</span>"
   var t = "<span id=\"span_"+id+"\""+(title ? " title =\"" + title + "\"":"")+"><input name='"    var t = "<span id=\"span_"+id+"\""+(title ? " title=\"" + title + "\"":"")+"><input name='"
  + groupName + "' id='"+id+"' type='radio' onClick='_jmolClick(" +    + groupName + "' id='"+id+"' type='radio' onclick='_jmolClick(this," +
          scriptIndex + _jmol.targetText + ");return true;' onMouseover='_jmolMouseOver(" +           scriptIndex + _jmol.targetText + ");return true;' onmouseover='_jmolMouseOver(" +
          scriptIndex + ");return true;' onMouseout='_jmolMouseOut()' " +           scriptIndex + ");return true;' onmouseout='_jmolMouseOut()' " +
  (isChecked ? "checked " : "") + _jmol.radioCssText + "/>"     (isChecked ? "checked='true' " : "") + _jmol.radioCssText + " />"
   if (labelHtml.toLowerCase().indexOf("<td>")>=0) {    if (labelHtml.toLowerCase().indexOf("<td>")>=0) {
  t += eospan    t += eospan
  eospan = "";    eospan = "";
   }    }
   t += labelHtml +eospan + separatorHtml;    t += "<label for=\"" + id + "\">" + labelHtml + "</label>" +eospan + separatorHtml;
   
   return t;    return t;
 }  }
   
 function _jmolFindApplet(target) {  function _jmolFindApplet(target) {
   // first look for the target in the current window    // first look for the target in the current window
   var applet = _jmolFindAppletInWindow(window, target);    var applet = _jmolFindAppletInWindow(_jmol.appletWindow != null ? _jmol.appletWindow : window, target);
   // THEN look for the target in child frames    // THEN look for the target in child frames
   if (applet == undefined)    if (applet == undefined)
     applet = _jmolSearchFrames(window, target);      applet = _jmolSearchFrames(window, target);
Line 867  function _jmolGetApplet(targetSuffix){ Line 1046  function _jmolGetApplet(targetSuffix){
  var target = "jmolApplet" + (targetSuffix ? targetSuffix : "0");   var target = "jmolApplet" + (targetSuffix ? targetSuffix : "0");
  var applet = _jmolFindApplet(target);   var applet = _jmolFindApplet(target);
  if (applet) return applet   if (applet) return applet
  if(!_jmol.alerted)alert("could not find applet " + target);   _jmol.alerted || alert("could not find applet " + target);
  _jmol.alerted = true;   _jmol.alerted = true;
  return null   return null
 }  }
Line 876  function _jmolSearchFrames(win, target) Line 1055  function _jmolSearchFrames(win, target)
   var applet;    var applet;
   var frames = win.frames;    var frames = win.frames;
   if (frames && frames.length) { // look in all the frames below this window    if (frames && frames.length) { // look in all the frames below this window
      try{
     for (var i = 0; i < frames.length; ++i) {      for (var i = 0; i < frames.length; ++i) {
       applet = _jmolSearchFrames(frames[i], target);        applet = _jmolSearchFrames(frames[i], target);
       if (applet)        if (applet)
         break;          return applet;
     }      }
   } else { // look for the applet in this window     }catch(e) {
    applet = _jmolFindAppletInWindow(win, target)    if (_jmol.debugAlert)
       alert("Jmol.js _jmolSearchFrames cannot access " + win.name + ".frame[" + i + "] consider using jmolSetAppletWindow()")
      }
   }    }
   return applet;    return applet = _jmolFindAppletInWindow(win, target)
 }  }
   
 function _jmolFindAppletInWindow(win, target) {  function _jmolFindAppletInWindow(win, target) {
     var doc = win.document;      var doc = win.document;
     // getElementById fails on MacOSX Safari & Mozilla      if (doc.getElementById(target))
     if (_jmol.useHtml4Object || _jmol.useIEObject)  
       return doc.getElementById(target);        return doc.getElementById(target);
     else if (doc.applets)      if (doc.applets)
       return doc.applets[target];        return doc.applets[target];
     else      return doc[target];
       return doc[target];  
 }  }
   
 function _jmolAddScript(script) {  function _jmolAddScript(script) {
   if (! script)    if (!script)
     return 0;      return 0;
   var index = _jmol.scripts.length;    var index = _jmol.scripts.length;
   _jmol.scripts[index] = script;    _jmol.scripts[index] = script;
   return index;    return index;
 }  }
   
 function _jmolClick(scriptIndex, targetSuffix) {  function _jmolClick(elementClicked, scriptIndex, targetSuffix) {
   jmolScript(_jmol.scripts[scriptIndex], targetSuffix);    _jmol.element = elementClicked;
     _jmolScriptExecute(elementClicked, _jmol.scripts[scriptIndex], targetSuffix);
 }  }
   
 function _jmolMenuSelected(menuObject, targetSuffix) {  function _jmolMenuSelected(menuObject, targetSuffix) {
   var scriptIndex = menuObject.value;    var scriptIndex = menuObject.value;
   if (scriptIndex != undefined) {    if (scriptIndex != undefined) {
     jmolScript(_jmol.scripts[scriptIndex], targetSuffix);      _jmolScriptExecute(menuObject, _jmol.scripts[scriptIndex], targetSuffix);
     return;      return;
   }    }
   var len = menuObject.length;    var len = menuObject.length;
   if (typeof len == "number") {    if (typeof len == "number") {
     for (var i = 0; i < len; ++i) {      for (var i = 0; i < len; ++i) {
       if (menuObject[i].selected) {        if (menuObject[i].selected) {
         _jmolClick(menuObject[i].value, targetSuffix);          _jmolClick(menuObject[i], menuObject[i].value, targetSuffix);
  return;    return;
       }        }
     }      }
   }    }
Line 929  function _jmolMenuSelected(menuObject, t Line 1110  function _jmolMenuSelected(menuObject, t
 }  }
   
   
 _jmol.checkboxMasters = new Array();  _jmol.checkboxMasters = {};
 _jmol.checkboxItems = new Array();  _jmol.checkboxItems = {};
   
 function jmolSetCheckboxGroup(chkMaster,chkBox) {  function jmolSetCheckboxGroup(chkMaster,chkBox) {
  var id = chkMaster;    var id = chkMaster;
  if(typeof(id)=="number")id = "jmolCheckbox" + id;    if(typeof(id)=="number")id = "jmolCheckbox" + id;
  chkMaster = document.getElementById(id);    chkMaster = document.getElementById(id);
  if (!chkMaster)alert("jmolSetCheckboxGroup: master checkbox not found: " + id);    if (!chkMaster)alert("jmolSetCheckboxGroup: master checkbox not found: " + id);
  var m = _jmol.checkboxMasters[id] = new Array();    var m = _jmol.checkboxMasters[id] = {};
  m.chkMaster = chkMaster;    m.chkMaster = chkMaster;
  m.chkGroup = new Array();    m.chkGroup = {};
  for (var i = 1; i < arguments.length; i++){    for (var i = 1; i < arguments.length; i++){
  var id = arguments[i];      var id = arguments[i];
  if(typeof(id)=="number")id = "jmolCheckbox" + id;      if(typeof(id)=="number")id = "jmolCheckbox" + id;
  checkboxItem = document.getElementById(id);      checkboxItem = document.getElementById(id);
  if (!checkboxItem)alert("jmolSetCheckboxGroup: group checkbox not found: " + id);      if (!checkboxItem)alert("jmolSetCheckboxGroup: group checkbox not found: " + id);
  m.chkGroup[id] = checkboxItem;      m.chkGroup[id] = checkboxItem;
  _jmol.checkboxItems[id] = m;      _jmol.checkboxItems[id] = m;
  }    }
 }  }
   
 function _jmolNotifyMaster(m){  function _jmolNotifyMaster(m){
  //called when a group item is checked    //called when a group item is checked
  var allOn = true;    var allOn = true;
  var allOff = true;    var allOff = true;
  for (var chkBox in m.chkGroup){    for (var chkBox in m.chkGroup){
  if(m.chkGroup[chkBox].checked)      if(m.chkGroup[chkBox].checked)
  allOff = false;        allOff = false;
  else      else
  allOn = false;        allOn = false;
  }    }
  if (allOn)m.chkMaster.checked = true;    if (allOn)m.chkMaster.checked = true;
  if (allOff)m.chkMaster.checked = false;    if (allOff)m.chkMaster.checked = false;
  if ((allOn || allOff) && _jmol.checkboxItems[m.chkMaster.id])    if ((allOn || allOff) && _jmol.checkboxItems[m.chkMaster.id])
  _jmolNotifyMaster(_jmol.checkboxItems[m.chkMaster.id])      _jmolNotifyMaster(_jmol.checkboxItems[m.chkMaster.id])
 }  }
   
 function _jmolNotifyGroup(m, isOn){  function _jmolNotifyGroup(m, isOn){
  //called when a master item is checked    //called when a master item is checked
  for (var chkBox in m.chkGroup){    for (var chkBox in m.chkGroup){
  var item = m.chkGroup[chkBox]      var item = m.chkGroup[chkBox]    
  item.checked = isOn;      if (item.checked != isOn)
  if (_jmol.checkboxMasters[item.id])        item.click();
  _jmolNotifyGroup(_jmol.checkboxMasters[item.id], isOn)      if (_jmol.checkboxMasters[item.id])
  }        _jmolNotifyGroup(_jmol.checkboxMasters[item.id], isOn)
     }
 }  }
   
 function _jmolCbClick(ckbox, whenChecked, whenUnchecked, targetSuffix) {  function _jmolCbClick(ckbox, whenChecked, whenUnchecked, targetSuffix) {
   _jmolClick(ckbox.checked ? whenChecked : whenUnchecked, targetSuffix);    _jmol.control = ckbox
     _jmolClick(ckbox, ckbox.checked ? whenChecked : whenUnchecked, targetSuffix);
   if(_jmol.checkboxMasters[ckbox.id])    if(_jmol.checkboxMasters[ckbox.id])
  _jmolNotifyGroup(_jmol.checkboxMasters[ckbox.id], ckbox.checked)    _jmolNotifyGroup(_jmol.checkboxMasters[ckbox.id], ckbox.checked)
   if(_jmol.checkboxItems[ckbox.id])    if(_jmol.checkboxItems[ckbox.id])
  _jmolNotifyMaster(_jmol.checkboxItems[ckbox.id])    _jmolNotifyMaster(_jmol.checkboxItems[ckbox.id])
 }  }
   
 function _jmolCbOver(ckbox, whenChecked, whenUnchecked) {  function _jmolCbOver(ckbox, whenChecked, whenUnchecked) {
Line 1004  function _jmolSetCodebase(codebase) { Line 1187  function _jmolSetCodebase(codebase) {
 }  }
   
 function _jmolOnloadResetForms() {  function _jmolOnloadResetForms() {
     // must be evaluated ONLY once
   _jmol.previousOnloadHandler = window.onload;    _jmol.previousOnloadHandler = window.onload;
   window.onload =    window.onload =
   function() {    function() {
Line 1026  function _jmolOnloadResetForms() { Line 1210  function _jmolOnloadResetForms() {
   
 function _jmolEvalJSON(s,key){  function _jmolEvalJSON(s,key){
  s=s+""   s=s+""
   
  if(!s)return []   if(!s)return []
  if(s.charAt(0)!="{"){   if(s.charAt(0)!="{"){
  if(s.indexOf(" | ")>=0)s=s.replace(/\ \|\ /g, "\n")    if(s.indexOf(" | ")>=0)s=s.replace(/\ \|\ /g, "\n")
  return s    return s
  }   }
  var A = eval("("+s+")")   var A = eval("("+s+")")
  if(!A)return   if(!A)return
Line 1040  function _jmolEvalJSON(s,key){ Line 1225  function _jmolEvalJSON(s,key){
 function _jmolEnumerateObject(A,key){  function _jmolEnumerateObject(A,key){
  var sout=""   var sout=""
  if(typeof(A) == "string" && A!="null"){   if(typeof(A) == "string" && A!="null"){
  sout+="\n"+key+"=\""+A+"\""    sout+="\n"+key+"=\""+A+"\""
  }else if(!isNaN(A)||A==null){   }else if(!isNaN(A)||A==null){
  sout+="\n"+key+"="+(A+""==""?"null":A)    sout+="\n"+key+"="+(A+""==""?"null":A)
  }else if(A.length){   }else if(A.length){
     sout+=key+"=new Array()"      sout+=key+"=[]"
     for(var i=0;i<A.length;i++){      for(var i=0;i<A.length;i++){
  sout+="\n"    sout+="\n"
  if(typeof(A[i]) == "object"||typeof(A[i]) == "array"){    if(typeof(A[i]) == "object"||typeof(A[i]) == "array"){
  sout+=_jmolEnumerateObject(A[i],key+"["+i+"]")      sout+=_jmolEnumerateObject(A[i],key+"["+i+"]")
  }else{    }else{
  sout+=key+"["+i+"]="+(typeof(A[i]) == "string" && A[i]!="null"?"\""+A[i].replace(/\"/g,"\\\"")+"\"":A[i])      sout+=key+"["+i+"]="+(typeof(A[i]) == "string" && A[i]!="null"?"\""+A[i].replace(/\"/g,"\\\"")+"\"":A[i])
  }    }
     }      }
  }else{   }else{
     if(key != ""){      if(key != ""){
  sout+=key+"=new Array()"    sout+=key+"={}"
  key+="."    key+="."
     }      }
      
     for(var i in A){      for(var i in A){
  sout+="\n"    sout+="\n"
  if(typeof(A[i]) == "object"||typeof(A[i]) == "array"){    if(typeof(A[i]) == "object"||typeof(A[i]) == "array"){
  sout+=_jmolEnumerateObject(A[i],key+i)      sout+=_jmolEnumerateObject(A[i],key+i)
  }else{    }else{
  sout+=key+i+"="+(typeof(A[i]) == "string" && A[i]!="null"?"\""+A[i].replace(/\"/g,"\\\"")+"\"":A[i])      sout+=key+i+"="+(typeof(A[i]) == "string" && A[i]!="null"?"\""+A[i].replace(/\"/g,"\\\"")+"\"":A[i])
  }    }
     }      }
  }   }
  return sout   return sout
 }  }
   
Line 1078  function _jmolSortKey0(a,b){ Line 1263  function _jmolSortKey0(a,b){
   
 function _jmolSortMessages(A){  function _jmolSortMessages(A){
  if(!A || typeof(A)!="object")return []   if(!A || typeof(A)!="object")return []
  var B = new Array()   var B = []
  for(var i=A.length-1;i>=0;i--)for(var j=0;j<A[i].length;j++)B[B.length]=A[i][j]   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   if(B.length == 0) return
  B=B.sort(_jmolSortKey0)   B=B.sort(_jmolSortKey0)
Line 1112  function _jmolExtractPostData(url){ Line 1297  function _jmolExtractPostData(url){
  S=url.split("&POST:")   S=url.split("&POST:")
  var s=""   var s=""
  for(var i=1;i<S.length;i++){   for(var i=1;i<S.length;i++){
  KV=S[i].split("=")    KV=S[i].split("=")
  s+="&POSTKEY"+i+"="+KV[0]    s+="&POSTKEY"+i+"="+KV[0]
  s+="&POSTVALUE"+i+"="+KV[1]    s+="&POSTVALUE"+i+"="+KV[1]
  }   }
  return "&url="+escape(S[0])+s   return "&url="+escape(S[0])+s
 }  }
Line 1123  function _jmolLoadModel(targetSuffix,rem Line 1308  function _jmolLoadModel(targetSuffix,rem
  //called by server, but in client   //called by server, but in client
  //overload this function to customize return   //overload this function to customize return
  _jmol.remoteURL=remoteURL   _jmol.remoteURL=remoteURL
  if(isError)alert(errorMessage)   isError && alert(errorMessage)
  jmolLoadInlineScript(array.join("\n"),_jmol.optionalscript,targetSuffix)   jmolLoadInlineScript(array.join("\n"),_jmol.optionalscript,targetSuffix)
 }  }
   
Line 1139  function jmolGetPropertyAsArray(sKey,sVa Line 1324  function jmolGetPropertyAsArray(sKey,sVa
   
 function jmolGetPropertyAsString(sKey,sValue,targetSuffix) {  function jmolGetPropertyAsString(sKey,sValue,targetSuffix) {
  var applet = _jmolGetApplet(targetSuffix);   var applet = _jmolGetApplet(targetSuffix);
  if(!sValue)sValue=""   sValue == undefined && (sValue="");
  return (applet ? applet.getPropertyAsString(sKey,sValue) + "" : "")   return (applet ? applet.getPropertyAsString(sKey,sValue) + "" : "")
 }  }
   
 function jmolGetPropertyAsJSON(sKey,sValue,targetSuffix) {  function jmolGetPropertyAsJSON(sKey,sValue,targetSuffix) {
  if(!sValue)sValue = ""   sValue == undefined && (sValue = "")
  var applet = _jmolGetApplet(targetSuffix);   var applet = _jmolGetApplet(targetSuffix);
  try {   try {
   return (applet ? applet.getPropertyAsJSON(sKey,sValue) + "" : "")    return (applet ? applet.getPropertyAsJSON(sKey,sValue) + "" : "")
Line 1154  function jmolGetPropertyAsJSON(sKey,sVal Line 1339  function jmolGetPropertyAsJSON(sKey,sVal
 }  }
   
 function jmolGetPropertyAsJavaObject(sKey,sValue,targetSuffix) {  function jmolGetPropertyAsJavaObject(sKey,sValue,targetSuffix) {
  if(!sValue)sValue = ""   sValue == undefined && (sValue = "")
  var applet = _jmolGetApplet(targetSuffix);   var applet = _jmolGetApplet(targetSuffix);
  return (applet ? applet.getProperty(sKey,sValue) : null)   return (applet ? applet.getProperty(sKey,sValue) : null)
 }  }
Line 1168  function jmolDecodeJSON(s) { Line 1353  function jmolDecodeJSON(s) {
 ///////// synchronous scripting ////////  ///////// synchronous scripting ////////
   
 function jmolScriptWait(script, targetSuffix) {  function jmolScriptWait(script, targetSuffix) {
   if(!targetSuffix)targetSuffix="0"    targetSuffix == undefined && (targetSuffix="0")
   var Ret=jmolScriptWaitAsArray(script, targetSuffix)    var Ret=jmolScriptWaitAsArray(script, targetSuffix)
   var s = ""    var s = ""
   for(i=Ret.length;--i>=0;)    for(var i=Ret.length;--i>=0;)
   for(j=0;j< Ret[i].length;j++)    for(var j=0;j< Ret[i].length;j++)
  s+=Ret[i][j]+"\n"    s+=Ret[i][j]+"\n"
   return s    return s
 }  }
   
   function jmolScriptWaitOutput(script, targetSuffix) {
     targetSuffix == undefined && (targetSuffix="0")
     var ret = ""
     try{
      if (script) {
       _jmolCheckBrowser();
       var applet=_jmolGetApplet(targetSuffix);
       if (applet) ret += applet.scriptWaitOutput(script);
      }
     }catch(e){
     }
    return ret;
   }
   
 function jmolEvaluate(molecularMath, targetSuffix) {  function jmolEvaluate(molecularMath, targetSuffix) {
   
   //carries out molecular math on a model    //carries out molecular math on a model
   
   if(!targetSuffix)targetSuffix="0"    targetSuffix == undefined && (targetSuffix="0")
   var result = "" + jmolGetPropertyAsJavaObject("evaluate", molecularMath, targetSuffix);    var result = "" + jmolGetPropertyAsJavaObject("evaluate", molecularMath, targetSuffix);
   var s = result.replace(/\-*\d+/,"")    var s = result.replace(/\-*\d+/,"")
   if (s == "" && !isNaN(parseInt(result)))return parseInt(result);    if (s == "" && !isNaN(parseInt(result)))return parseInt(result);
Line 1192  function jmolEvaluate(molecularMath, tar Line 1391  function jmolEvaluate(molecularMath, tar
   
 function jmolScriptEcho(script, targetSuffix) {  function jmolScriptEcho(script, targetSuffix) {
   // returns a newline-separated list of all echos from a script    // returns a newline-separated list of all echos from a script
   if(!targetSuffix)targetSuffix="0"    targetSuffix == undefined && (targetSuffix="0")
   var Ret=jmolScriptWaitAsArray(script, targetSuffix)    var Ret=jmolScriptWaitAsArray(script, targetSuffix)
   var s = ""    var s = ""
   for(i=Ret.length;--i>=0;)    for(var i=Ret.length;--i>=0;)
   for(j=Ret[i].length;--j>=0;)    for(var j=Ret[i].length;--j>=0;)
         if (Ret[i][j][1] == "scriptEcho")s+=Ret[i][j][3]+"\n"          if (Ret[i][j][1] == "scriptEcho")s+=Ret[i][j][3]+"\n"
   return s.replace(/ \| /g, "\n")    return s.replace(/ \| /g, "\n")
 }  }
Line 1204  function jmolScriptEcho(script, targetSu Line 1403  function jmolScriptEcho(script, targetSu
   
 function jmolScriptMessage(script, targetSuffix) {  function jmolScriptMessage(script, targetSuffix) {
   // returns a newline-separated list of all messages from a script, ending with "script completed\n"    // returns a newline-separated list of all messages from a script, ending with "script completed\n"
   if(!targetSuffix)targetSuffix="0"    targetSuffix == undefined && (targetSuffix="0")
   var Ret=jmolScriptWaitAsArray(script, targetSuffix)    var Ret=jmolScriptWaitAsArray(script, targetSuffix)
   var s = ""    var s = ""
   for(i=Ret.length;--i>=0;)    for(var i=Ret.length;--i>=0;)
   for(j=Ret[i].length;--j>=0;)    for(var j=Ret[i].length;--j>=0;)
         if (Ret[i][j][1] == "scriptStatus")s+=Ret[i][j][3]+"\n"          if (Ret[i][j][1] == "scriptStatus")s+=Ret[i][j][3]+"\n"
   return s.replace(/ \| /g, "\n")    return s.replace(/ \| /g, "\n")
 }  }
Line 1224  function jmolScriptWaitAsArray(script, t Line 1423  function jmolScriptWaitAsArray(script, t
     if (applet) ret += applet.scriptWait(script);      if (applet) ret += applet.scriptWait(script);
     ret = _jmolEvalJSON(ret,"jmolStatus")      ret = _jmolEvalJSON(ret,"jmolStatus")
     if(typeof ret == "object")      if(typeof ret == "object")
  return ret    return ret
   }    }
  }catch(e){   }catch(e){
  }   }
Line 1235  function jmolScriptWaitAsArray(script, t Line 1434  function jmolScriptWaitAsArray(script, t
   
 ////////////   save/restore orientation   /////////////  ////////////   save/restore orientation   /////////////
   
 function jmolSaveOrientation(id, targetSuffix) {    function jmolSaveOrientation(id, targetSuffix) {
  if(!targetSuffix)targetSuffix="0"   targetSuffix == undefined && (targetSuffix="0")
   return _jmol["savedOrientation"+id] = jmolGetPropertyAsArray("orientationInfo","info",targetSuffix).moveTo   return _jmol["savedOrientation"+id] = jmolGetPropertyAsArray("orientationInfo","info",targetSuffix).moveTo
 }  }
   
 function jmolRestoreOrientation(id, targetSuffix) {  function jmolRestoreOrientation(id, targetSuffix) {
  if(!targetSuffix)targetSuffix="0"   targetSuffix == undefined && (targetSuffix="0")
  var s=_jmol["savedOrientation"+id]   var s=_jmol["savedOrientation"+id]
  if (!s || s == "")return   if (!s || s == "")return
  s=s.replace(/1\.0/,"0")   s=s.replace(/1\.0/,"0")
Line 1249  function jmolRestoreOrientation(id, targ Line 1448  function jmolRestoreOrientation(id, targ
 }  }
   
 function jmolRestoreOrientationDelayed(id, delay, targetSuffix) {  function jmolRestoreOrientationDelayed(id, delay, targetSuffix) {
  if(arguments.length < 2)delay=1;   arguments.length < 2 && (delay=1)
  if(!targetSuffix)targetSuffix="0"   targetSuffix == undefined && (targetSuffix="0")
  var s=_jmol["savedOrientation"+id]   var s=_jmol["savedOrientation"+id]
  if (!s || s == "")return   if (!s || s == "")return
  s=s.replace(/1\.0/,delay)   s=s.replace(/1\.0/,delay)
Line 1266  function jmolRestoreOrientationDelayed(i Line 1465  function jmolRestoreOrientationDelayed(i
    s = jmolAppletAddParam(s,"messageCallback", "myFunctionName")     s = jmolAppletAddParam(s,"messageCallback", "myFunctionName")
    document.write(s)     document.write(s)
    jmolSetDocument(document) // if you want to then write buttons and such normally     jmolSetDocument(document) // if you want to then write buttons and such normally
    
  */   */
   
 function jmolAppletAddParam(appletCode,name,value){  function jmolAppletAddParam(appletCode,name,value){
   if(value == "")return appletCode    return (value == "" ? appletCode : appletCode.replace(/\<param/,"\n<param name='"+name+"' value='"+value+"' />\n<param"))
   return appletCode.replace(/\<param/,"\n<param name='"+name+"' value='"+value+"' />\n<param")  
 }  }
   
 ///////////////auto load Research Consortium for Structural Biology (RCSB) data ///////////  ///////////////auto load Research Consortium for Structural Biology (RCSB) data ///////////
   
 function jmolLoadAjax_STOLAF_RCSB(fileformat,pdbid,optionalscript,targetSuffix){  function jmolLoadAjax_STOLAF_RCSB(fileformat,pdbid,optionalscript,targetSuffix){
   
  if(!_jmol.thismodel)_jmol.thismodel = "1crn"   _jmol.thismodel || (_jmol.thismodel = "1crn")
  if(!_jmol.serverURL)_jmol.serverURL="http://fusion.stolaf.edu/chemistry/jmol/getajaxjs.cfm"   _jmol.serverURL || (_jmol.serverURL="http://fusion.stolaf.edu/chemistry/jmol/getajaxjs.cfm")
  if(!_jmol.RCSBserver)_jmol.RCSBserver="http://www.rcsb.org"   _jmol.RCSBserver || (_jmol.RCSBserver="http://www.rcsb.org")
  if(!_jmol.defaultURL_RCSB)_jmol.defaultURL_RCSB=_jmol.RCSBserver+"/pdb/files/1CRN.CIF"   _jmol.defaultURL_RCSB || (_jmol.defaultURL_RCSB=_jmol.RCSBserver+"/pdb/files/1CRN.CIF")
  if(!fileformat)fileformat="PDB"   fileformat || (fileformat="PDB")
  if(!pdbid)pdbid=prompt("Enter a 4-digit PDB ID:",_jmol.thismodel)   pdbid || (pdbid=prompt("Enter a 4-digit PDB ID:",_jmol.thismodel))
  if(!pdbid || pdbid.length != 4)return ""   if(!pdbid || pdbid.length != 4)return ""
  if(!targetSuffix)targetSuffix="0"   targetSuffix || (targetSuffix="0")
  if(!optionalscript)optionalscript=""   optionalscript || (optionalscript="")
  var url=_jmol.defaultURL_RCSB.replace(/1CRN/g,pdbid.toUpperCase())   var url=_jmol.defaultURL_RCSB.replace(/1CRN/g,pdbid.toUpperCase())
  if(fileformat!="CIF")url=url.replace(/CIF/,fileformat)   fileformat=="CIF" || (url=url.replace(/CIF/,fileformat))
  _jmol.optionalscript=optionalscript   _jmol.optionalscript=optionalscript
  _jmol.thismodel=pdbid   _jmol.thismodel=pdbid
  _jmol.thistargetsuffix=targetSuffix   _jmol.thistargetsuffix=targetSuffix
  _jmol.thisurl=url   _jmol.thisurl=url
  _jmol.modelArray = new Array()   _jmol.modelArray = []
  url=_jmol.serverURL+"?returnfunction=_jmolLoadModel&returnArray=_jmol.modelArray&id="+targetSuffix+_jmolExtractPostData(url)   url=_jmol.serverURL+"?returnfunction=_jmolLoadModel&returnArray=_jmol.modelArray&id="+targetSuffix+_jmolExtractPostData(url)
  _jmolDomScriptLoad(url)   _jmolDomScriptLoad(url)
  return url   return url
Line 1303  function jmolLoadAjax_STOLAF_RCSB(filefo Line 1501  function jmolLoadAjax_STOLAF_RCSB(filefo
   
 function jmolLoadAjax_STOLAF_ANY(url, userid, optionalscript,targetSuffix){  function jmolLoadAjax_STOLAF_ANY(url, userid, optionalscript,targetSuffix){
  _jmol.serverURL="http://fusion.stolaf.edu/chemistry/jmol/getajaxjs.cfm"   _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"   _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)   url || (url=prompt("Enter any (uncompressed file) URL:", _jmol.thisurlANY))
  if(!userid)userid="0"   userid || (userid="0")
  if(!targetSuffix)targetSuffix="0"   targetSuffix || (targetSuffix="0")
  if(!optionalscript)optionalscript=""   optionalscript || (optionalscript="")
  _jmol.optionalscript=optionalscript   _jmol.optionalscript=optionalscript
  _jmol.thistargetsuffix=targetSuffix   _jmol.thistargetsuffix=targetSuffix
  _jmol.modelArray = new Array()   _jmol.modelArray = []
  _jmol.thisurl = url   _jmol.thisurl = url
  url=_jmol.serverURL+"?returnfunction=_jmolLoadModel&returnArray=_jmol.modelArray&id="+targetSuffix+_jmolExtractPostData(url)   url=_jmol.serverURL+"?returnfunction=_jmolLoadModel&returnArray=_jmol.modelArray&id="+targetSuffix+_jmolExtractPostData(url)
  _jmolDomScriptLoad(url)   _jmolDomScriptLoad(url)
Line 1321  function jmolLoadAjax_STOLAF_ANY(url, us Line 1519  function jmolLoadAjax_STOLAF_ANY(url, us
   
 function jmolLoadAjax_MSA(key,value,optionalscript,targetSuffix){  function jmolLoadAjax_MSA(key,value,optionalscript,targetSuffix){
   
  if(!_jmol.thiskeyMSA)_jmol.thiskeyMSA = "mineral"   _jmol.thiskeyMSA || (_jmol.thiskeyMSA = "mineral")
  if(!_jmol.thismodelMSA)_jmol.thismodelMSA = "quartz"   _jmol.thismodelMSA || (_jmol.thismodelMSA = "quartz")
  if(!_jmol.ajaxURL_MSA)_jmol.ajaxURL_MSA="http://rruff.geo.arizona.edu/AMS/result.php?mineral=quartz&viewing=ajaxjs"   _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)   key || (key=prompt("Enter a field:", _jmol.thiskeyMSA))
  if(!key)return ""   if(!key)return ""
  if(!value)value=prompt("Enter a "+key+":", _jmol.thismodelMSA)   value || (value=prompt("Enter a "+key+":", _jmol.thismodelMSA))
  if(!value)return ""   if(!value)return ""
  if(!targetSuffix)targetSuffix="0"   targetSuffix || (targetSuffix="0")
  if(!optionalscript)optionalscript=""   optionalscript || (optionalscript="")
  if(optionalscript == 1)optionalscript='load "" {1 1 1}'   optionalscript == 1 && (optionalscript='load "" {1 1 1}')
  var url=_jmol.ajaxURL_MSA.replace(/mineral/g,key).replace(/quartz/g,value)   var url=_jmol.ajaxURL_MSA.replace(/mineral/g,key).replace(/quartz/g,value)
  _jmol.optionalscript=optionalscript   _jmol.optionalscript=optionalscript
  _jmol.thiskeyMSA=key   _jmol.thiskeyMSA=key
  _jmol.thismodelMSA=value   _jmol.thismodelMSA=value
  _jmol.thistargetsuffix=targetSuffix   _jmol.thistargetsuffix=targetSuffix
  _jmol.thisurl=url   _jmol.thisurl=url
  _jmol.modelArray = new Array()   _jmol.modelArray = []
  loadModel=_jmolLoadModel   loadModel=_jmolLoadModel
  _jmolDomScriptLoad(url)   _jmolDomScriptLoad(url)
  return url   return url
Line 1346  function jmolLoadAjax_MSA(key,value,opti Line 1544  function jmolLoadAjax_MSA(key,value,opti
   
   
 function jmolLoadAjaxJS(url, userid, optionalscript,targetSuffix){  function jmolLoadAjaxJS(url, userid, optionalscript,targetSuffix){
  if(!userid)userid="0"   userid || (userid="0")
  if(!targetSuffix)targetSuffix="0"   targetSuffix || (targetSuffix="0")
  if(!optionalscript)optionalscript=""   optionalscript || (optionalscript="")
  _jmol.optionalscript=optionalscript   _jmol.optionalscript=optionalscript
  _jmol.thismodel=userid   _jmol.thismodel=userid
  _jmol.thistargetsuffix=targetSuffix   _jmol.thistargetsuffix=targetSuffix
  _jmol.modelArray = new Array()   _jmol.modelArray = []
  _jmol.thisurl = url   _jmol.thisurl = url
  url+="&returnFunction=_jmolLoadModel&returnArray=_jmol.modelArray&id="+targetSuffix   url+="&returnFunction=_jmolLoadModel&returnArray=_jmol.modelArray&id="+targetSuffix
  _jmolDomScriptLoad(url)   _jmolDomScriptLoad(url)
Line 1383  function jmolSetAtomCoordRelative(i,x,y, Line 1581  function jmolSetAtomCoordRelative(i,x,y,
 ///////////////applet fake for testing buttons/////////////  ///////////////applet fake for testing buttons/////////////
   
   
 if(document.location.search.indexOf("NOAPPLET")>=0){  if(_jmol.useNoApplet){
  jmolApplet = function(w){    jmolApplet = function(w){
  var s="<table style='background-color:black' width="+w+"><tr height="+w+">"      var s="<table style='background-color:black' width="+w+"><tr height="+w+">"
  +"<td align=center valign=center style='background-color:white'>"      +"<td align=center valign=center style='background-color:white'>"
  +"Applet would be here"      +"Applet would be here"
  +"<p><textarea id=fakeApplet rows=5 cols=50></textarea>"      +"<p><textarea id=fakeApplet rows=5 cols=50></textarea>"
  +"</td></tr></table>"      +"</td></tr></table>"
  return _jmolDocumentWrite(s)      return _jmolDocumentWrite(s)
  }    }
   
  _jmolFindApplet = function(){return jmolApplet0}    _jmolFindApplet = function(){return jmolApplet0}
   
  jmolApplet0 = {    jmolApplet0 = {
  script: function(script){document.getElementById("fakeApplet").value="\njmolScript:\n"+script}     script: function(script){document.getElementById("fakeApplet").value="\njmolScript:\n"+script}
  ,scriptWait: function(script){document.getElementById("fakeApplet").value="\njmolScriptWait:\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}    ,loadInline: function(data,script){document.getElementById("fakeApplet").value="\njmolLoadInline data:\n"+data+"\n\nscript:\n"+script}
  }    }
 }  }
   
   
 ///////////////////////////////////////////  ///////////////////////////////////////////
   
 //new 9:49 AM 3/6/2007:    //  This should no longer be needed, jmolResizeApplet() is better; kept for backwards compatibility
     /*
 //both w and h are optional.    Resizes absolutely (pixels) or by percent of window (w or h 0.5 means 50%).
 //if either is between 0 and 1, then it is taken as percent/100.    targetSuffix is optional and defaults to zero (first applet in page).
 //if either is greater than 1, then it is taken as a size.    Both w and h are optional, but needed if you want to use targetSuffix.
 function jmolResize(w,h) {      h defaults to w
       w defaults to 100% of window
     If either w or h is between 0 and 1, then it is taken as percent/100.
     If either w or h is greater than 1, then it is taken as a size (pixels).
     */
   function jmolResize(w,h,targetSuffix) {
  _jmol.alerted = true;   _jmol.alerted = true;
  var percentW = (!w ? 100 : w <= 1  && w > 0 ? w * 100 : 0)   var percentW = (!w ? 100 : w <= 1  && w > 0 ? w * 100 : 0);
  var percentH = (!h ? percentW : h <= 1 && h > 0 ? h * 100 : 0)   var percentH = (!h ? percentW : h <= 1 && h > 0 ? h * 100 : 0);
  if (_jmol.browser=="msie") {   if (_jmol.browser=="msie") {
    var width=document.body.clientWidth;     var width=document.body.clientWidth;
    var height=document.body.clientHeight;     var height=document.body.clientHeight;
Line 1422  function jmolResize(w,h) { Line 1625  function jmolResize(w,h) {
    var width=window.innerWidth - netscapeScrollWidth;     var width=window.innerWidth - netscapeScrollWidth;
    var height=window.innerHeight-netscapeScrollWidth;     var height=window.innerHeight-netscapeScrollWidth;
  }   }
  var applet = _jmolGetApplet(0);   var applet = _jmolGetApplet(targetSuffix);
    if(!applet)return;
    applet.style.width = (percentW ? width * percentW/100 : w)+"px";
    applet.style.height = (percentH ? height * percentH/100 : (h ? h : w))+"px";
    //title=width +  " " + height + " " + (new Date());
   }
   
   // 13 Jun 09 -- makes jmolResize() obsolete  (kept for backwards compatibility)
   function jmolResizeApplet(size,targetSuffix) {
    // See _jmolGetAppletSize() for the formats accepted as size [same used by jmolApplet()]
    //  Special case: an empty value for width or height is accepted, meaning no change in that dimension.
    _jmol.alerted = true;
    var applet = _jmolGetApplet(targetSuffix);
  if(!applet)return;   if(!applet)return;
  applet.style.width = (percentW ? width * percentW/100 : w)+"px"   var sz = _jmolGetAppletSize(size, "px");
  applet.style.height = (percentH ? height * percentH/100 : h)+"px"   sz[0] && (applet.style.width = sz[0]);
  title=width +  " " + height + " " + (new Date())   sz[1] && (applet.style.height = sz[1]);
   }
   
   function _jmolGetAppletSize(size, units) {
     /* Accepts single number or 2-value array, each one can be one of:
        percent (text string ending %), decimal 0 to 1 (percent/100), number, or text string (interpreted as nr.)
        [width, height] array of strings is returned, with units added if specified.
        Percent is relative to container div or element (which should have explicitly set size).
     */
     var width, height;
     if ( (typeof size) == "object" && size != null ) {
       width = size[0]; height = size[1];
     } else {
       width = height = size;
     }
     return [_jmolFixDim(width, units), _jmolFixDim(height, units)];
   }
   
   function _jmolFixDim(x, units) {
     var sx = "" + x;
     return (sx.length == 0 ? (units ? "" : _jmol.allowedJmolSize[2])
     : sx.indexOf("%") == sx.length-1 ? sx
       : (x = parseFloat(x)) <= 1 && x > 0 ? x * 100 + "%"
       : (isNaN(x = Math.floor(x)) ? _jmol.allowedJmolSize[2]
         : x < _jmol.allowedJmolSize[0] ? _jmol.allowedJmolSize[0]
           : x > _jmol.allowedJmolSize[1] ? _jmol.allowedJmolSize[1]
           : x) + (units ? units : ""));
 }  }
   
   
   

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


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