Annotation of loncom/html/adm/jmol/Jmol.js, revision 1.3

1.3     ! albertel    1: 
        !             2: /* Jmol 11.0 script library Jmol.js (aka Jmol-11.js) 1:34 AM 3/19/2007
        !             3: 
        !             4:  checkbox heirarchy -- see http://www.stolaf.edu/academics/jmol/docs/examples-11/check.htm
        !             5: 
        !             6:     based on:
        !             7:  *
        !             8:  * Copyright (C) 2004-2005  Miguel, Jmol Development, www.jmol.org
        !             9:  *
        !            10:  * Contact: hansonr@stolaf.edu
        !            11:  *
        !            12:  *  This library is free software; you can redistribute it and/or
        !            13:  *  modify it under the terms of the GNU Lesser General Public
        !            14:  *  License as published by the Free Software Foundation; either
        !            15:  *  version 2.1 of the License, or (at your option) any later version.
        !            16:  *
        !            17:  *  This library is distributed in the hope that it will be useful,
        !            18:  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
        !            19:  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
        !            20:  *  Lesser General Public License for more details.
        !            21:  *
        !            22:  *  You should have received a copy of the GNU Lesser General Public
        !            23:  *  License along with this library; if not, write to the Free Software
        !            24:  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
        !            25:  *  02111-1307  USA.
        !            26:  */
        !            27: 
        !            28: // for documentation see www.jmol.org/jslibrary
        !            29: 
        !            30: try{if(typeof(_jmol)!="undefined")exit()
        !            31: 
        !            32: // place "?NOAPPLET" on your command line to check applet control action with a textarea
        !            33: 
        !            34: // bob hanson -- jmolResize(w,h) -- resizes absolutely or by percent (w or h 0.5 means 50%)
        !            35: // bob hanson -- jmolEvaluate -- evaluates molecular math 8:37 AM 2/23/2007
        !            36: // bob hanson -- jmolScriptMessage -- returns all "scriptStatus" messages 8:37 AM 2/23/2007
        !            37: // bob hanson -- jmolScriptEcho -- returns all "scriptEcho" messages 8:37 AM 2/23/2007
        !            38: // bob hanson -- jmolScriptWait -- 11:31 AM 5/2/2006
        !            39: // bob hanson -- remove trailing separatorHTML in radio groups -- 12:18 PM 5/6/2006
        !            40: // bob hanson -- adds support for dynamic DOM script nodes 7:04 AM 5/19/2006
        !            41: // bob hanson -- adds try/catch for wiki - multiple code passes 7:05 AM 5/19/2006
        !            42: // bob hanson -- auto-initiates to defaultdir/defaultjar -- change as desired.
        !            43: // bob hanson -- adding save/restore orientation w/ and w/o delay 11:49 AM 5/25/2006
        !            44: // bob hanson -- adding AjaxJS service 11:16 AM 6/3/2006
        !            45: // bob hanson -- fix for iframes not available for finding applet
        !            46: // bob hanson -- added applet fake ?NOAPPLET URL flag
        !            47: // bob hanson -- added jmolSetCallback(calbackName, funcName) 3:32 PM 6/13/2006
        !            48: //			used PRIOR to jmolApplet() or jmolAppletInline()
        !            49: //               added 4th array element in jmolRadioGroup -- title
        !            50: //               added <span> and id around link, checkbox, radio, menu
        !            51: //               fixing AJAX loads for MSIE/Opera-Mozilla incompatibility
        !            52: //            -- renamed Jmol-11.js from Jmol-new.js; JmolApplet.jar from JmolAppletProto.jar
        !            53: //	 	 renamed Jmol.js for Jmol 11 distribution
        !            54: //            -- modified jmolRestoreOrientation() to be immediate, no 1-second delay
        !            55: // bob hanson -- jmolScriptWait always returns a string -- 11:23 AM 9/16/2006
        !            56: // bh         -- jmolCommandInput()
        !            57: // bh         -- jmolSetTranslation(TF) -- forces translation even if there might be message callback issues
        !            58: // bh         -- minor fixes suggested by Angel
        !            59: 	  	
        !            60: var defaultdir = "."
        !            61: var defaultjar = "JmolApplet.jar"
        !            62: 
        !            63: var undefined; // for IE 5 ... wherein undefined is undefined
        !            64: 
        !            65: ////////////////////////////////////////////////////////////////
        !            66: // Basic Scripting infrastruture
        !            67: ////////////////////////////////////////////////////////////////
        !            68: 
        !            69: function jmolInitialize(codebaseDirectory, fileNameOrUseSignedApplet) {
        !            70:   if (_jmol.initialized) {
        !            71:     //alert("jmolInitialize() should only be called *ONCE* within a page");
        !            72:     return;
        !            73:   }
        !            74:   if (! codebaseDirectory) {
        !            75:     alert("codebaseDirectory is a required parameter to jmolInitialize");
        !            76:     codebaseDirectory = ".";
        !            77:   }
        !            78: 
        !            79:   if (codebaseDirectory.indexOf("http://") == 0 ||
        !            80:       codebaseDirectory.indexOf("https://") == 0)
        !            81:     alert("In general, an absolute URL is not recommended for codebaseDirectory.\n" +
        !            82: 	  "A directory- or docroot-relative reference is recommended.\n\n" +
        !            83: 	  "If you need to use an absolute URL (because, for example, the JAR and data\n" +
        !            84: 	  "files are on another server), then insert a space before\n" +
        !            85: 	  "\"http\" in your URL to avoid this warning message.");
        !            86: 
        !            87:   _jmolSetCodebase(codebaseDirectory);
        !            88:   _jmolGetJarFilename(fileNameOrUseSignedApplet);
        !            89:   _jmolOnloadResetForms();
        !            90:   _jmol.initialized = true;
        !            91: }
        !            92: 
        !            93: function jmolSetTranslation(TF) {
        !            94:   _jmol.params.doTranslate = ''+TF;
        !            95: }
        !            96: 
        !            97: function _jmolGetJarFilename(fileNameOrFlag) {
        !            98:   _jmol.archivePath =
        !            99:     (typeof(fileNameOrFlag) == "string"  ? fileNameOrFlag : (fileNameOrFlag ?  "JmolAppletSigned" : "JmolApplet") + "0.jar");
        !           100: }
        !           101: 
        !           102: function jmolSetDocument(doc) {
        !           103:   _jmol.currentDocument = doc;
        !           104: }
        !           105: 
        !           106: function jmolSetAppletColor(boxbgcolor, boxfgcolor, progresscolor) {
        !           107:   _jmolInitCheck();
        !           108:   _jmol.params.boxbgcolor = boxbgcolor;
        !           109:   if (boxfgcolor)
        !           110:     _jmol.params.boxfgcolor = boxfgcolor
        !           111:   else if (boxbgcolor == "white" || boxbgcolor == "#FFFFFF")
        !           112:     _jmol.params.boxfgcolor = "black";
        !           113:   else
        !           114:     _jmol.params.boxfgcolor = "white";
        !           115:   if (progresscolor)
        !           116:     _jmol.params.progresscolor = progresscolor;
        !           117:   if (_jmol.debugAlert)
        !           118:     alert(" boxbgcolor=" + _jmol.params.boxbgcolor +
        !           119:           " boxfgcolor=" + _jmol.params.boxfgcolor +
        !           120:           " progresscolor=" + _jmol.params.progresscolor);
        !           121: }
        !           122: 
        !           123: function jmolApplet(size, script, nameSuffix) {
        !           124:   _jmolInitCheck();
        !           125:   return _jmolApplet(size, null, script, nameSuffix);
        !           126: }
        !           127: 
        !           128: ////////////////////////////////////////////////////////////////
        !           129: // Basic controls
        !           130: ////////////////////////////////////////////////////////////////
        !           131: 
        !           132: function jmolButton(script, label, id, title) {
        !           133:   _jmolInitCheck();
        !           134:   if (id == undefined || id == null)
        !           135:     id = "jmolButton" + _jmol.buttonCount;
        !           136:   if (label == undefined || label == null)
        !           137:     label = script.substring(0, 32);
        !           138:   ++_jmol.buttonCount;
        !           139:   var scriptIndex = _jmolAddScript(script);
        !           140:   var t = "<span id=\"span_"+id+"\""+(title ? " title =\"" + title + "\"":"")+"><input type='button' name='" + id + "' id='" + id +
        !           141:           "' value='" + label +
        !           142:           "' onClick='_jmolClick(" + scriptIndex + _jmol.targetText +
        !           143:           ")' onMouseover='_jmolMouseOver(" + scriptIndex +
        !           144:           ");return true' onMouseout='_jmolMouseOut()' " +
        !           145:           _jmol.buttonCssText + "/></span>";
        !           146:   if (_jmol.debugAlert)
        !           147:     alert(t);
        !           148:   return _jmolDocumentWrite(t);
        !           149: }
        !           150: 
        !           151: function jmolCheckbox(scriptWhenChecked, scriptWhenUnchecked,
        !           152:                       labelHtml, isChecked, id, title) {
        !           153:   _jmolInitCheck();
        !           154:   if (id == undefined || id == null)
        !           155:     id = "jmolCheckbox" + _jmol.checkboxCount;
        !           156:   ++_jmol.checkboxCount;
        !           157:   if (scriptWhenChecked == undefined || scriptWhenChecked == null ||
        !           158:       scriptWhenUnchecked == undefined || scriptWhenUnchecked == null) {
        !           159:     alert("jmolCheckbox requires two scripts");
        !           160:     return;
        !           161:   }
        !           162:   if (labelHtml == undefined || labelHtml == null) {
        !           163:     alert("jmolCheckbox requires a label");
        !           164:     return;
        !           165:   }
        !           166:   var indexChecked = _jmolAddScript(scriptWhenChecked);
        !           167:   var indexUnchecked = _jmolAddScript(scriptWhenUnchecked);
        !           168:   var eospan = "</span>"
        !           169:   var t = "<span id=\"span_"+id+"\""+(title ? " title =\"" + title + "\"":"")+"><input type='checkbox' name='" + id + "' id='" + id +
        !           170:           "' onClick='_jmolCbClick(this," +
        !           171:           indexChecked + "," + indexUnchecked + _jmol.targetText +
        !           172:           ")' onMouseover='_jmolCbOver(this," + indexChecked + "," +
        !           173:           indexUnchecked +
        !           174:           ");return true' onMouseout='_jmolMouseOut()' " +
        !           175: 	  (isChecked ? "checked " : "") + _jmol.checkboxCssText + "/>" 
        !           176:   if (labelHtml.toLowerCase().indexOf("<td>")>=0) {
        !           177: 	t += eospan
        !           178: 	eospan = "";
        !           179:   }
        !           180:   t += labelHtml +eospan;
        !           181:   if (_jmol.debugAlert)
        !           182:     alert(t);
        !           183:   return _jmolDocumentWrite(t);
        !           184: }
        !           185: 
        !           186: function jmolStartNewRadioGroup() {
        !           187:   ++_jmol.radioGroupCount;
        !           188: }
        !           189: 
        !           190: function jmolRadioGroup(arrayOfRadioButtons, separatorHtml, groupName, id, title) {
        !           191:   /*
        !           192: 
        !           193:     array: [radio1,radio2,radio3...]
        !           194:     where radioN = ["script","label",isSelected,"id","title"]
        !           195: 
        !           196:   */
        !           197: 
        !           198:   _jmolInitCheck();
        !           199:   var type = typeof arrayOfRadioButtons;
        !           200:   if (type != "object" || type == null || ! arrayOfRadioButtons.length) {
        !           201:     alert("invalid arrayOfRadioButtons");
        !           202:     return;
        !           203:   }
        !           204:   if (separatorHtml == undefined || separatorHtml == null)
        !           205:     separatorHtml = "&nbsp; ";
        !           206:   var len = arrayOfRadioButtons.length;
        !           207:   jmolStartNewRadioGroup();
        !           208:   if (!groupName)
        !           209:     groupName = "jmolRadioGroup" + (_jmol.radioGroupCount - 1);
        !           210:   var t = "<span id='"+(id ? id : groupName)+"'>";
        !           211:   for (var i = 0; i < len; ++i) {
        !           212:     if (i == len - 1)
        !           213:       separatorHtml = "";
        !           214:     var radio = arrayOfRadioButtons[i];
        !           215:     type = typeof radio;
        !           216:     if (type == "object") {
        !           217:       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);
        !           218:     } else {
        !           219:       t += _jmolRadio(radio, null, null, separatorHtml, groupName, (id ? id : groupName)+"_"+i, title);
        !           220:     }
        !           221:   }
        !           222:   t+="</span>"
        !           223:   if (_jmol.debugAlert)
        !           224:     alert(t);
        !           225:   return _jmolDocumentWrite(t);
        !           226: }
        !           227: 
        !           228: 
        !           229: function jmolRadio(script, labelHtml, isChecked, separatorHtml, groupName, id, title) {
        !           230:   _jmolInitCheck();
        !           231:   if (_jmol.radioGroupCount == 0)
        !           232:     ++_jmol.radioGroupCount;
        !           233:   var t = _jmolRadio(script, labelHtml, isChecked, separatorHtml, groupName, (id ? id : groupName + "_" + _jmol.radioCount), title ? title : 0);
        !           234:   if (_jmol.debugAlert)
        !           235:     alert(t);
        !           236:   return _jmolDocumentWrite(t);
        !           237: }
        !           238: 
        !           239: function jmolLink(script, label, id, title) {
        !           240:   _jmolInitCheck();
        !           241:   if (id == undefined || id == null)
        !           242:     id = "jmolLink" + _jmol.linkCount;
        !           243:   if (label == undefined || label == null)
        !           244:     label = script.substring(0, 32);
        !           245:   ++_jmol.linkCount;
        !           246:   var scriptIndex = _jmolAddScript(script);
        !           247:   var t = "<span id=\"span_"+id+"\""+(title ? " title =\"" + title + "\"":"")+"><a name='" + id + "' id='" + id + 
        !           248:           "' href='javascript:_jmolClick(" + scriptIndex + _jmol.targetText + ");' onMouseover='_jmolMouseOver(" + scriptIndex +
        !           249:           ");return true;' onMouseout='_jmolMouseOut()' " +
        !           250:           _jmol.linkCssText + ">" + label + "</a></span>";
        !           251:   if (_jmol.debugAlert)
        !           252:     alert(t);
        !           253:   return _jmolDocumentWrite(t);
        !           254: }
        !           255: 
        !           256: function jmolCommandInput(label, size, id, title) {
        !           257:   _jmolInitCheck();
        !           258:   if (id == undefined || id == null)
        !           259:     id = "jmolCmd" + _jmol.cmdCount;
        !           260:   if (label == undefined || label == null)
        !           261:     label = "Execute";
        !           262:   if (size == undefined || isNaN(size))
        !           263:     size = 60;
        !           264:   ++_jmol.cmdCount;
        !           265:   var t = "<span id=\"span_"+id+"\""+(title ? " title =\"" + title + "\"":"")+"><input name='" + id + "' id='" + id + 
        !           266:           "' size='"+size+"'><input type=button value = '"+label+"' onClick='jmolScript(document.getElementById(\""+id+"\").value" + _jmol.targetText + ")'/></span>";
        !           267:   if (_jmol.debugAlert)
        !           268:     alert(t);
        !           269:   return _jmolDocumentWrite(t);
        !           270: }
        !           271: 
        !           272: function jmolMenu(arrayOfMenuItems, size, id, title) {
        !           273:   _jmolInitCheck();
        !           274:   if (id == undefined || id == null)
        !           275:     id = "jmolMenu" + _jmol.menuCount;
        !           276:   ++_jmol.menuCount;
        !           277:   var type = typeof arrayOfMenuItems;
        !           278:   if (type != null && type == "object" && arrayOfMenuItems.length) {
        !           279:     var len = arrayOfMenuItems.length;
        !           280:     if (typeof size != "number" || size == 1)
        !           281:       size = null;
        !           282:     else if (size < 0)
        !           283:       size = len;
        !           284:     var sizeText = size ? " size='" + size + "' " : "";
        !           285:     var t = "<span id=\"span_"+id+"\""+(title ? " title =\"" + title + "\"":"")+"><select name='" + id + "' id='" + id +
        !           286:             "' onChange='_jmolMenuSelected(this" + _jmol.targetText + ")'" +
        !           287:             sizeText + _jmol.menuCssText + ">";
        !           288:     for (var i = 0; i < len; ++i) {
        !           289:       var menuItem = arrayOfMenuItems[i];
        !           290:       type = typeof menuItem;
        !           291:       var script, text;
        !           292:       var isSelected = undefined;
        !           293:       if (type == "object" && menuItem != null) {
        !           294:         script = menuItem[0];
        !           295:         text = menuItem[1];
        !           296:         isSelected = menuItem[2];
        !           297:       } else {
        !           298:         script = text = menuItem;
        !           299:       }
        !           300:       if (text == undefined || text == null)
        !           301:         text = script;		
        !           302: 	  if (script=="#optgroup") {
        !           303:         t += "<optgroup label='" + text + "'>";	  
        !           304: 	  } else if (script=="#optgroupEnd") {
        !           305:         t += "</optgroup>";	  
        !           306: 	  } else {		
        !           307:         var scriptIndex = _jmolAddScript(script);
        !           308:         var selectedText = isSelected ? "' selected>" : "'>";
        !           309:         t += "<option value='" + scriptIndex + selectedText + text + "</option>";
        !           310: 	  }
        !           311:     }
        !           312:     t += "</select></span>";
        !           313:     if (_jmol.debugAlert)
        !           314:       alert(t);
        !           315:     return _jmolDocumentWrite(t);
        !           316:   }
        !           317: }
        !           318: 
        !           319: function jmolHtml(html) {
        !           320:   return _jmolDocumentWrite(html);
        !           321: }
        !           322: 
        !           323: function jmolBr() {
        !           324:   return _jmolDocumentWrite("<br />");
        !           325: }
        !           326: 
        !           327: ////////////////////////////////////////////////////////////////
        !           328: // advanced scripting functions
        !           329: ////////////////////////////////////////////////////////////////
        !           330: 
        !           331: function jmolDebugAlert(enableAlerts) {
        !           332:   _jmol.debugAlert = (enableAlerts == undefined || enableAlerts)
        !           333: }
        !           334: 
        !           335: function jmolAppletInline(size, inlineModel, script, nameSuffix) {
        !           336:   _jmolInitCheck();
        !           337:   return _jmolApplet(size, _jmolSterilizeInline(inlineModel),
        !           338:                      script, nameSuffix);
        !           339: }
        !           340: 
        !           341: function jmolSetTarget(targetSuffix) {
        !           342:   _jmol.targetSuffix = targetSuffix;
        !           343:   _jmol.targetText = targetSuffix ? ",\"" + targetSuffix + "\"" : "";
        !           344: }
        !           345: 
        !           346: function jmolScript(script, targetSuffix) {
        !           347:   if (script) {
        !           348:     _jmolCheckBrowser();
        !           349:     if (targetSuffix == "all") {
        !           350:       with (_jmol) {
        !           351: 	for (var i = 0; i < appletSuffixes.length; ++i) {
        !           352: 	  var applet = _jmolGetApplet(appletSuffixes[i]);
        !           353:           if (applet) applet.script(script);
        !           354:         }
        !           355:       }
        !           356:     } else {
        !           357:       var applet=_jmolGetApplet(targetSuffix);
        !           358:       if (applet) applet.script(script);
        !           359:     }
        !           360:   }
        !           361: }
        !           362: 
        !           363: function jmolLoadInline(model, targetSuffix) {
        !           364:   if (!model)return
        !           365:   var applet=_jmolGetApplet(targetSuffix);
        !           366:   if (applet)applet.loadInline(model);
        !           367: }
        !           368: 
        !           369: function jmolLoadInlineScript(model, script, targetSuffix) {
        !           370:   if (!model)return
        !           371:   var applet=_jmolGetApplet(targetSuffix);
        !           372:   if (applet)applet.loadInline(model, script);
        !           373: }
        !           374: 
        !           375: function jmolLoadInlineArray(ModelArray, script, targetSuffix) {
        !           376:   if (!model)return
        !           377:   if (!script)script=""
        !           378:   var applet=_jmolGetApplet(targetSuffix);
        !           379:   if (applet)applet.loadInlineArray(ModelArray, script);
        !           380: }
        !           381: 
        !           382: function jmolCheckBrowser(action, urlOrMessage, nowOrLater) {
        !           383:   if (typeof action == "string") {
        !           384:     action = action.toLowerCase();
        !           385:     if (action != "alert" && action != "redirect" && action != "popup")
        !           386:       action = null;
        !           387:   }
        !           388:   if (typeof action != "string")
        !           389:     alert("jmolCheckBrowser(action, urlOrMessage, nowOrLater)\n\n" +
        !           390:           "action must be 'alert', 'redirect', or 'popup'");
        !           391:   else {
        !           392:     if (typeof urlOrMessage != "string")
        !           393:       alert("jmolCheckBrowser(action, urlOrMessage, nowOrLater)\n\n" +
        !           394:             "urlOrMessage must be a string");
        !           395:     else {
        !           396:       _jmol.checkBrowserAction = action;
        !           397:       _jmol.checkBrowserUrlOrMessage = urlOrMessage;
        !           398:     }
        !           399:   }
        !           400:   if (typeof nowOrLater == "string" && nowOrLater.toLowerCase() == "now")
        !           401:     _jmolCheckBrowser();
        !           402: }
        !           403: 
        !           404: ////////////////////////////////////////////////////////////////
        !           405: // Cascading Style Sheet Class support
        !           406: ////////////////////////////////////////////////////////////////
        !           407: 
        !           408: function jmolSetAppletCssClass(appletCssClass) {
        !           409:   if (_jmol.hasGetElementById) {
        !           410:     _jmol.appletCssClass = appletCssClass;
        !           411:     _jmol.appletCssText = appletCssClass ? "class='" + appletCssClass + "' " : "";
        !           412:   }
        !           413: }
        !           414: 
        !           415: function jmolSetButtonCssClass(buttonCssClass) {
        !           416:   if (_jmol.hasGetElementById) {
        !           417:     _jmol.buttonCssClass = buttonCssClass;
        !           418:     _jmol.buttonCssText = buttonCssClass ? "class='" + buttonCssClass + "' " : "";
        !           419:   }
        !           420: }
        !           421: 
        !           422: function jmolSetCheckboxCssClass(checkboxCssClass) {
        !           423:   if (_jmol.hasGetElementById) {
        !           424:     _jmol.checkboxCssClass = checkboxCssClass;
        !           425:     _jmol.checkboxCssText = checkboxCssClass ? "class='" + checkboxCssClass + "' " : "";
        !           426:   }
        !           427: }
        !           428: 
        !           429: function jmolSetRadioCssClass(radioCssClass) {
        !           430:   if (_jmol.hasGetElementById) {
        !           431:     _jmol.radioCssClass = radioCssClass;
        !           432:     _jmol.radioCssText = radioCssClass ? "class='" + radioCssClass + "' " : "";
        !           433:   }
        !           434: }
        !           435: 
        !           436: function jmolSetLinkCssClass(linkCssClass) {
        !           437:   if (_jmol.hasGetElementById) {
        !           438:     _jmol.linkCssClass = linkCssClass;
        !           439:     _jmol.linkCssText = linkCssClass ? "class='" + linkCssClass + "' " : "";
        !           440:   }
        !           441: }
        !           442: 
        !           443: function jmolSetMenuCssClass(menuCssClass) {
        !           444:   if (_jmol.hasGetElementById) {
        !           445:     _jmol.menuCssClass = menuCssClass;
        !           446:     _jmol.menuCssText = menuCssClass ? "class='" + menuCssClass + "' " : "";
        !           447:   }
        !           448: }
        !           449: 
        !           450: ////////////////////////////////////////////////////////////////
        !           451: // functions for INTERNAL USE ONLY which are subject to change
        !           452: // use at your own risk ... you have been WARNED!
        !           453: ////////////////////////////////////////////////////////////////
        !           454: var _jmol = {
        !           455:   currentDocument: document,
        !           456: 
        !           457:   debugAlert: false,
        !           458:   
        !           459:   codebase: ".",
        !           460:   modelbase: ".",
        !           461:   
        !           462:   appletCount: 0,
        !           463:   appletSuffixes: [],
        !           464:   
        !           465:   buttonCount: 0,
        !           466:   checkboxCount: 0,
        !           467:   linkCount: 0,
        !           468:   cmdCount: 0,
        !           469:   menuCount: 0,
        !           470:   radioCount: 0,
        !           471:   radioGroupCount: 0,
        !           472:   
        !           473:   appletCssClass: null,
        !           474:   appletCssText: "",
        !           475:   buttonCssClass: null,
        !           476:   buttonCssText: "",
        !           477:   checkboxCssClass: null,
        !           478:   checkboxCssText: "",
        !           479:   radioCssClass: null,
        !           480:   radioCssText: "",
        !           481:   linkCssClass: null,
        !           482:   linkCssText: "",
        !           483:   menuCssClass: null,
        !           484:   menuCssText: "",
        !           485:   
        !           486:   targetSuffix: 0,
        !           487:   targetText: "",
        !           488:   scripts: [""],
        !           489:   params: {
        !           490: 	progressbar: "true",
        !           491: 	progresscolor: "blue",
        !           492: 	boxbgcolor: "black",
        !           493: 	boxfgcolor: "white",
        !           494: 	boxmessage: "Downloading JmolApplet ..."
        !           495:   },
        !           496:   ua: navigator.userAgent.toLowerCase(),
        !           497:   uaVersion: parseFloat(navigator.appVersion),
        !           498:   
        !           499:   os: "unknown",
        !           500:   browser: "unknown",
        !           501:   browserVersion: 0,
        !           502:   hasGetElementById: !!document.getElementById,
        !           503:   isJavaEnabled: navigator.javaEnabled(),
        !           504:   isNetscape47Win: false,
        !           505:   isIEWin: false,
        !           506:   useIEObject: false,
        !           507:   useHtml4Object: false,
        !           508:   
        !           509:   windowsClassId: "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93",
        !           510:   windowsCabUrl:
        !           511:    "http://java.sun.com/update/1.5.0/jinstall-1_5_0_05-windows-i586.cab",
        !           512: 
        !           513:   isBrowserCompliant: false,
        !           514:   isJavaCompliant: false,
        !           515:   isFullyCompliant: false,
        !           516: 
        !           517:   initialized: false,
        !           518:   initChecked: false,
        !           519:   
        !           520:   browserChecked: false,
        !           521:   checkBrowserAction: "alert",
        !           522:   checkBrowserUrlOrMessage: null,
        !           523: 
        !           524:   archivePath: null, // JmolApplet0.jar OR JmolAppletSigned0.jar
        !           525: 
        !           526:   previousOnloadHandler: null,
        !           527:   ready: {}
        !           528: }
        !           529: 
        !           530: with (_jmol) {
        !           531: 
        !           532:   function _jmolTestUA(candidate) {
        !           533:     var ua = _jmol.ua;
        !           534:     var index = ua.indexOf(candidate);
        !           535:     if (index < 0)
        !           536:       return false;
        !           537:     _jmol.browser = candidate;
        !           538:     _jmol.browserVersion = parseFloat(ua.substring(index+candidate.length+1));
        !           539:     return true;
        !           540:   }
        !           541:   
        !           542:   function _jmolTestOS(candidate) {
        !           543:     if (_jmol.ua.indexOf(candidate) < 0)
        !           544:       return false;
        !           545:     _jmol.os = candidate;
        !           546:     return true;
        !           547:   }
        !           548:   
        !           549:   _jmolTestUA("konqueror") ||
        !           550:   _jmolTestUA("safari") ||
        !           551:   _jmolTestUA("omniweb") ||
        !           552:   _jmolTestUA("opera") ||
        !           553:   _jmolTestUA("webtv") ||
        !           554:   _jmolTestUA("icab") ||
        !           555:   _jmolTestUA("msie") ||
        !           556:   (_jmol.ua.indexOf("compatible") < 0 && _jmolTestUA("mozilla"));
        !           557:   
        !           558:   _jmolTestOS("linux") ||
        !           559:   _jmolTestOS("unix") ||
        !           560:   _jmolTestOS("mac") ||
        !           561:   _jmolTestOS("win");
        !           562: 
        !           563:   isNetscape47Win = (os == "win" && browser == "mozilla" &&
        !           564:                      browserVersion >= 4.78 && browserVersion <= 4.8);
        !           565: 
        !           566:   if (os == "win") {
        !           567:     isBrowserCompliant = hasGetElementById;
        !           568:   } else if (os == "mac") { // mac is the problem child :-(
        !           569:     if (browser == "mozilla" && browserVersion >= 5) {
        !           570:       // miguel 2004 11 17
        !           571:       // checking the plugins array does not work because
        !           572:       // Netscape 7.2 OS X still has Java 1.3.1 listed even though
        !           573:       // javaplugin.sf.net is installed to upgrade to 1.4.2
        !           574:       eval("try {var v = java.lang.System.getProperty('java.version');" +
        !           575:            " _jmol.isBrowserCompliant = v >= '1.4.2';" +
        !           576:            " } catch (e) { }");
        !           577:     } else if (browser == "opera" && browserVersion <= 7.54) {
        !           578:       isBrowserCompliant = false;
        !           579:     } else {
        !           580:       isBrowserCompliant = hasGetElementById &&
        !           581:         !((browser == "msie") ||
        !           582:           (browser == "safari" && browserVersion < 125.12));
        !           583:     }
        !           584:   } else if (os == "linux" || os == "unix") {
        !           585:     if (browser == "konqueror" && browserVersion <= 3.3)
        !           586:       isBrowserCompliant = false;
        !           587:     else
        !           588:       isBrowserCompliant = hasGetElementById;
        !           589:   } else { // other OS
        !           590:     isBrowserCompliant = hasGetElementById;
        !           591:   }
        !           592: 
        !           593:   // possibly more checks in the future for this
        !           594:   isJavaCompliant = isJavaEnabled;
        !           595: 
        !           596:   isFullyCompliant = isBrowserCompliant && isJavaCompliant;
        !           597: 
        !           598:   // IE5.5 works just fine ... but let's push them to Sun Java
        !           599:   isIEWin = (os == "win" && browser == "msie" && browserVersion >= 5.5);
        !           600:   useIEObject = isIEWin;
        !           601:   useHtml4Object =
        !           602:    (os != "mac" && browser == "mozilla" && browserVersion >= 5) ||
        !           603:    (os == "win" && browser == "opera" && browserVersion >= 8) ||
        !           604:    (os == "mac" && browser == "safari" && browserVersion >= 412.2);
        !           605: 
        !           606:  doTranslate = true;
        !           607:  haveSetTranslate = false;
        !           608: }
        !           609: 
        !           610: function jmolSetCallback(callbackName,funcName) {
        !           611:   _jmol.params[callbackName] = funcName
        !           612: }
        !           613: 
        !           614: function jmolSetLogLevel(n) {
        !           615:   _jmol.params.logLevel = ''+n;
        !           616: }
        !           617: 
        !           618: 	/*  AngelH, mar2007:
        !           619: 		By (re)setting these variables in the webpage before calling jmolApplet(), 
        !           620: 		a custom message can be provided (e.g. localized for user's language) when no Java is installed.
        !           621: 	*/
        !           622: if (noJavaMsg==undefined) var noJavaMsg = 
        !           623:         "You do not have Java applets enabled in your web browser, or your browser is blocking this applet.<br />\n" +
        !           624:         "Check the warning message from your browser and/or enable Java applets in<br />\n" +
        !           625:         "your web browser preferences, or install the Java Runtime Environment from <a href='http://www.java.com'>www.java.com</a><br />";
        !           626: if (noJavaMsg2==undefined) var noJavaMsg2 = 
        !           627:         "You do not have the<br />\n" +
        !           628:         "Java Runtime Environment<br />\n" +
        !           629:         "installed for applet support.<br />\n" +
        !           630:         "Visit <a href='http://www.java.com'>www.java.com</a>";
        !           631: function _jmolApplet(size, inlineModel, script, nameSuffix) {
        !           632: 	/*  AngelH, mar2007
        !           633: 		Fixed percent / pixel business, to avoid browser errors:
        !           634: 		put "px" where needed, avoid where not.		
        !           635: 	*/
        !           636:   with (_jmol) {
        !           637:     if (! nameSuffix)
        !           638:       nameSuffix = appletCount;
        !           639:     appletSuffixes.push(nameSuffix);
        !           640:     ++appletCount;
        !           641:     if (! script)
        !           642:       script = "select *";
        !           643:     var sz = _jmolGetAppletSize(size);
        !           644:     var widthAndHeight = " width='" + sz[0] + "' height='" + sz[1] + "' ";
        !           645:     var tHeader, tFooter;
        !           646: 
        !           647:     if (useIEObject || useHtml4Object) {
        !           648:       params.name = 'jmolApplet' + nameSuffix;
        !           649:       params.archive = archivePath;
        !           650:       params.mayscript = 'true';
        !           651:       params.codebase = codebase;
        !           652:     }
        !           653:     if (useIEObject) { // use MSFT IE6 object tag with .cab file reference
        !           654:       winCodebase = (windowsCabUrl ? " codebase='" + windowsCabUrl + "'\n" : "");
        !           655:       tHeader = 
        !           656:         "<object name='jmolApplet" + nameSuffix +
        !           657:         "' id='jmolApplet" + nameSuffix + "' " + appletCssText + "\n" +
        !           658: 	" classid='" + windowsClassId + "'\n" + winCodebase + widthAndHeight + ">\n";
        !           659:         params.code = 'JmolApplet';
        !           660:       tFooter = "</object>";
        !           661:     } else if (useHtml4Object) { // use HTML4 object tag
        !           662:       tHeader = 
        !           663:         "<object name='jmolApplet" + nameSuffix +
        !           664:         "' id='jmolApplet" + nameSuffix + "' " + appletCssText + "\n" +
        !           665: 	" classid='java:JmolApplet'\n" +
        !           666:         " type='application/x-java-applet'\n" +
        !           667:         widthAndHeight + ">\n";
        !           668:       tFooter = "</object>";
        !           669:     } else { // use applet tag
        !           670:       tHeader = 
        !           671:         "<applet name='jmolApplet" + nameSuffix +
        !           672:         "' id='jmolApplet" + nameSuffix +
        !           673:         "' " + appletCssText +
        !           674:         " code='JmolApplet'" +
        !           675:         " archive='" + archivePath + "' codebase='" + codebase + "'\n" +
        !           676: 		widthAndHeight +
        !           677:         " mayscript='true'>\n";
        !           678:       tFooter = "</applet>";
        !           679:     }
        !           680:     var visitJava;
        !           681:     if (isIEWin || useHtml4Object) {
        !           682: 		var szX = "width:" + sz[0]
        !           683: 		if ( szX.indexOf("%")==-1 ) szX+="px" 
        !           684: 		var szY = "height:" + sz[1]
        !           685: 		if ( szY.indexOf("%")==-1 ) szY+="px" 
        !           686:       visitJava =
        !           687:         "<p style='background-color:yellow; color:black; " +
        !           688: 		szX + ";" + szY + ";" +
        !           689:         // why doesn't this vertical-align work?
        !           690: 	"text-align:center;vertical-align:middle;'>\n" +
        !           691: 		noJavaMsg +
        !           692:         "</p>";
        !           693:     } else {
        !           694:       visitJava =
        !           695:         "<table bgcolor='yellow'><tr>" +
        !           696:         "<td align='center' valign='middle' " + widthAndHeight + "><font color='black'>\n" +
        !           697: 		noJavaMsg2 +
        !           698:         "</font></td></tr></table>";
        !           699:     }
        !           700:     params.loadInline = (inlineModel ? inlineModel : "");
        !           701:     params.script = (script ? _jmolSterilizeScript(script) : "");
        !           702:     var t = tHeader + _jmolParams() + visitJava + tFooter;
        !           703:     jmolSetTarget(nameSuffix);
        !           704:     ready["jmolApplet" + nameSuffix] = false;
        !           705:     if (_jmol.debugAlert)
        !           706:       alert(t);
        !           707:     return _jmolDocumentWrite(t);
        !           708:   }
        !           709: }
        !           710: 
        !           711: function _jmolParams() {
        !           712:  var t = "";
        !           713:  for (i in _jmol.params)
        !           714: 	if(_jmol.params[i]!="")
        !           715: 		 t+="  <param name='"+i+"' value='"+_jmol.params[i]+"' />\n";
        !           716:  return t
        !           717: }
        !           718: 
        !           719: function _jmolInitCheck() {
        !           720:   if (_jmol.initChecked)
        !           721:     return;
        !           722:   _jmol.initChecked = true;
        !           723:   if (_jmol.initialized)
        !           724:     return;
        !           725:   jmolInitialize(defaultdir, defaultjar)
        !           726: }
        !           727: 
        !           728: function _jmolCheckBrowser() {
        !           729:   with (_jmol) {
        !           730:     if (browserChecked)
        !           731:       return;
        !           732:     browserChecked = true;
        !           733:   
        !           734:     if (isFullyCompliant)
        !           735:       return true;
        !           736: 
        !           737:     if (checkBrowserAction == "redirect")
        !           738:       location.href = checkBrowserUrlOrMessage;
        !           739:     else if (checkBrowserAction == "popup")
        !           740:       _jmolPopup(checkBrowserUrlOrMessage);
        !           741:     else {
        !           742:       var msg = checkBrowserUrlOrMessage;
        !           743:       if (msg == null)
        !           744:         msg = "Your web browser is not fully compatible with Jmol\n\n" +
        !           745:               "browser: " + browser +
        !           746:               "   version: " + browserVersion +
        !           747:               "   os: " + os +
        !           748:               "\n\n" + ua;
        !           749:       alert(msg);
        !           750:     }
        !           751:   }
        !           752:   return false;
        !           753: }
        !           754: 
        !           755: function _jmolDocumentWrite(text) {
        !           756:   if (_jmol.currentDocument)
        !           757:     _jmol.currentDocument.write(text);
        !           758:   return text;
        !           759: }
        !           760: 
        !           761: function _jmolPopup(url) {
        !           762:   var popup = window.open(url, "JmolPopup",
        !           763:                           "left=150,top=150,height=400,width=600," +
        !           764:                           "directories=yes,location=yes,menubar=yes," +
        !           765:                           "toolbar=yes," +
        !           766:                           "resizable=yes,scrollbars=yes,status=yes");
        !           767:   if (popup.focus)
        !           768:     poup.focus();
        !           769: }
        !           770: 
        !           771: function _jmolReadyCallback(name) {
        !           772:   if (_jmol.debugAlert)
        !           773:     alert(name + " is ready");
        !           774:   _jmol.ready["" + name] = true;
        !           775: }
        !           776: 
        !           777: function _jmolSterilizeScript(script) {
        !           778:   var inlineScript = script.replace(/'/g, "&#39;");
        !           779:   if (_jmol.debugAlert)
        !           780:     alert("script:\n" + inlineScript);
        !           781:   return inlineScript;
        !           782: }
        !           783: 
        !           784: function _jmolSterilizeInline(model) {
        !           785:   var inlineModel =
        !           786:     model.replace(/\r|\n|\r\n/g, "|").replace(/'/g, "&#39;");
        !           787:   if (_jmol.debugAlert)
        !           788:     alert("inline model:\n" + inlineModel);
        !           789:   return inlineModel;
        !           790: }
        !           791: 
        !           792: 	/*  AngelH, mar2007:
        !           793: 		By (re)setting this variable in the webpage before calling jmolApplet(), limits for applet size can be overriden.
        !           794: 	*/
        !           795: 
        !           796: 	/* hansonr, jun2007:
        !           797: 		2048 standard for GeoWall (http://geowall.geo.lsa.umich.edu/home.html)
        !           798: 	*/
        !           799: 
        !           800: if (allowedJmolSize==undefined) var allowedJmolSize = [25, 2048, 300]   // min, max, default (pixels)
        !           801: function _jmolGetAppletSize(size) {
        !           802: 	/*  AngelH, mar2007
        !           803: 		Accepts single number or 2-value array, each one can be either:
        !           804: 	   percent (text string ending %), decimal 0 to 1 (percent/100), number, or text string (interpreted as nr.)
        !           805: 	   Size is now returned as string or number, no "px".
        !           806: 	*/
        !           807:   var width, height;
        !           808:   if ( (typeof size) == "object" && size != null ) {
        !           809:     width = size[0]; height = size[1];
        !           810:   } else {
        !           811:     width = height = size;
        !           812:   }
        !           813:   // if percent, leave it as it is:
        !           814:   if ( width.toString().charAt(width.toString().length-1) != "%" ) {
        !           815:     width = parseFloat(width);	// convert to nr., or strip text, or make zero
        !           816: 	if ( width <= 1 && width > 0 ) { width = (width*100)+"%" }	// decimal: convert to percent and quit
        !           817: 	else if ( width >= allowedJmolSize[0] && width <= allowedJmolSize[1] ) { width = parseInt(width) }	// accept only that range (pixels)
        !           818: 	else { width = allowedJmolSize[2] }	// default size 300 pixels
        !           819:   }
        !           820:   if ( height.toString().charAt(height.toString().length-1) != "%" ) {
        !           821:     height = parseFloat(height);
        !           822: 	if ( height <= 1 && height > 0 ) { height = (height*100)+"%" }
        !           823: 	else if ( height >= allowedJmolSize[0] && height <= allowedJmolSize[1] ) { height = parseInt(height) }
        !           824: 	else { height = allowedJmolSize[2] }
        !           825:   }
        !           826:   return [width, height];
        !           827: }
        !           828: 
        !           829: function _jmolRadio(script, labelHtml, isChecked, separatorHtml, groupName, id, title) {
        !           830:   ++_jmol.radioCount;
        !           831:   if (groupName == undefined || groupName == null)
        !           832:     groupName = "jmolRadioGroup" + (_jmol.radioGroupCount - 1);
        !           833:   if (!script)
        !           834:     return "";
        !           835:   if (labelHtml == undefined || labelHtml == null)
        !           836:     labelHtml = script.substring(0, 32);
        !           837:   if (! separatorHtml)
        !           838:     separatorHtml = "";
        !           839:   var scriptIndex = _jmolAddScript(script);
        !           840:   var eospan = "</span>"
        !           841:   var t = "<span id=\"span_"+id+"\""+(title ? " title =\"" + title + "\"":"")+"><input name='" 
        !           842: 	+ groupName + "' id='"+id+"' type='radio' onClick='_jmolClick(" +
        !           843:          scriptIndex + _jmol.targetText + ");return true;' onMouseover='_jmolMouseOver(" +
        !           844:          scriptIndex + ");return true;' onMouseout='_jmolMouseOut()' " +
        !           845: 	 (isChecked ? "checked " : "") + _jmol.radioCssText + "/>"
        !           846:   if (labelHtml.toLowerCase().indexOf("<td>")>=0) {
        !           847: 	t += eospan
        !           848: 	eospan = "";
        !           849:   }
        !           850:   t += labelHtml +eospan + separatorHtml;
        !           851:   return t;
        !           852: }
        !           853: 
        !           854: function _jmolFindApplet(target) {
        !           855:   // first look for the target in the current window
        !           856:   var applet = _jmolFindAppletInWindow(window, target);
        !           857:   // THEN look for the target in child frames
        !           858:   if (applet == undefined)
        !           859:     applet = _jmolSearchFrames(window, target);
        !           860:   // FINALLY look for the target in sibling frames
        !           861:   if (applet == undefined)
        !           862:     applet = _jmolSearchFrames(top, target); // look starting in top frame
        !           863:   return applet;
        !           864: }
        !           865: 
        !           866: function _jmolGetApplet(targetSuffix){
        !           867:  var target = "jmolApplet" + (targetSuffix ? targetSuffix : "0");
        !           868:  var applet = _jmolFindApplet(target);
        !           869:  if (applet) return applet
        !           870:  if(!_jmol.alerted)alert("could not find applet " + target);
        !           871:  _jmol.alerted = true;
        !           872:  return null
        !           873: }
        !           874: 
        !           875: function _jmolSearchFrames(win, target) {
        !           876:   var applet;
        !           877:   var frames = win.frames;
        !           878:   if (frames && frames.length) { // look in all the frames below this window
        !           879:     for (var i = 0; i < frames.length; ++i) {
        !           880:       applet = _jmolSearchFrames(frames[i], target);
        !           881:       if (applet)
        !           882:         break;
        !           883:     }
        !           884:   } else { // look for the applet in this window
        !           885:    applet = _jmolFindAppletInWindow(win, target)
        !           886:   }
        !           887:   return applet;
        !           888: }
        !           889: 
        !           890: function _jmolFindAppletInWindow(win, target) {
        !           891:     var doc = win.document;
        !           892:     // getElementById fails on MacOSX Safari & Mozilla	
        !           893:     if (_jmol.useHtml4Object || _jmol.useIEObject)
        !           894:       return doc.getElementById(target);
        !           895:     else if (doc.applets)
        !           896:       return doc.applets[target];
        !           897:     else
        !           898:       return doc[target]; 
        !           899: }
        !           900: 
        !           901: function _jmolAddScript(script) {
        !           902:   if (! script)
        !           903:     return 0;
        !           904:   var index = _jmol.scripts.length;
        !           905:   _jmol.scripts[index] = script;
        !           906:   return index;
        !           907: }
        !           908: 
        !           909: function _jmolClick(scriptIndex, targetSuffix) {
        !           910:   jmolScript(_jmol.scripts[scriptIndex], targetSuffix);
        !           911: }
        !           912: 
        !           913: function _jmolMenuSelected(menuObject, targetSuffix) {
        !           914:   var scriptIndex = menuObject.value;
        !           915:   if (scriptIndex != undefined) {
        !           916:     jmolScript(_jmol.scripts[scriptIndex], targetSuffix);
        !           917:     return;
        !           918:   }
        !           919:   var len = menuObject.length;
        !           920:   if (typeof len == "number") {
        !           921:     for (var i = 0; i < len; ++i) {
        !           922:       if (menuObject[i].selected) {
        !           923:         _jmolClick(menuObject[i].value, targetSuffix);
        !           924: 	return;
        !           925:       }
        !           926:     }
        !           927:   }
        !           928:   alert("?Que? menu selected bug #8734");
        !           929: }
        !           930: 
        !           931: 
        !           932: _jmol.checkboxMasters = new Array();
        !           933: _jmol.checkboxItems = new Array();
        !           934: 
        !           935: function jmolSetCheckboxGroup(chkMaster,chkBox) {
        !           936: 	var id = chkMaster;
        !           937: 	if(typeof(id)=="number")id = "jmolCheckbox" + id;
        !           938: 	chkMaster = document.getElementById(id);
        !           939: 	if (!chkMaster)alert("jmolSetCheckboxGroup: master checkbox not found: " + id);
        !           940: 	var m = _jmol.checkboxMasters[id] = new Array();
        !           941: 	m.chkMaster = chkMaster;
        !           942: 	m.chkGroup = new Array();
        !           943: 	for (var i = 1; i < arguments.length; i++){
        !           944: 		var id = arguments[i];
        !           945: 		if(typeof(id)=="number")id = "jmolCheckbox" + id;
        !           946: 		checkboxItem = document.getElementById(id);
        !           947: 		if (!checkboxItem)alert("jmolSetCheckboxGroup: group checkbox not found: " + id);
        !           948: 		m.chkGroup[id] = checkboxItem;
        !           949: 		_jmol.checkboxItems[id] = m;
        !           950: 	}
        !           951: }
        !           952: 
        !           953: function _jmolNotifyMaster(m){
        !           954: 	//called when a group item is checked
        !           955: 	var allOn = true;
        !           956: 	var allOff = true;
        !           957: 	for (var chkBox in m.chkGroup){
        !           958: 		if(m.chkGroup[chkBox].checked)
        !           959: 			allOff = false;
        !           960: 		else
        !           961: 			allOn = false;
        !           962: 	}
        !           963: 	if (allOn)m.chkMaster.checked = true;	
        !           964: 	if (allOff)m.chkMaster.checked = false;
        !           965: 	if ((allOn || allOff) && _jmol.checkboxItems[m.chkMaster.id])
        !           966: 		_jmolNotifyMaster(_jmol.checkboxItems[m.chkMaster.id])
        !           967: }
        !           968: 
        !           969: function _jmolNotifyGroup(m, isOn){
        !           970: 	//called when a master item is checked
        !           971: 	for (var chkBox in m.chkGroup){
        !           972: 		var item = m.chkGroup[chkBox]
        !           973: 		item.checked = isOn;
        !           974: 		if (_jmol.checkboxMasters[item.id])
        !           975: 			_jmolNotifyGroup(_jmol.checkboxMasters[item.id], isOn)
        !           976: 	}
        !           977: }
        !           978: 
        !           979: function _jmolCbClick(ckbox, whenChecked, whenUnchecked, targetSuffix) {
        !           980:   _jmolClick(ckbox.checked ? whenChecked : whenUnchecked, targetSuffix);
        !           981:   if(_jmol.checkboxMasters[ckbox.id])
        !           982: 	_jmolNotifyGroup(_jmol.checkboxMasters[ckbox.id], ckbox.checked)
        !           983:   if(_jmol.checkboxItems[ckbox.id])
        !           984: 	_jmolNotifyMaster(_jmol.checkboxItems[ckbox.id])
        !           985: }
        !           986: 
        !           987: function _jmolCbOver(ckbox, whenChecked, whenUnchecked) {
        !           988:   window.status = _jmol.scripts[ckbox.checked ? whenUnchecked : whenChecked];
        !           989: }
        !           990: 
        !           991: function _jmolMouseOver(scriptIndex) {
        !           992:   window.status = _jmol.scripts[scriptIndex];
        !           993: }
        !           994: 
        !           995: function _jmolMouseOut() {
        !           996:   window.status = " ";
        !           997:   return true;
        !           998: }
        !           999: 
        !          1000: function _jmolSetCodebase(codebase) {
        !          1001:   _jmol.codebase = codebase ? codebase : ".";
        !          1002:   if (_jmol.debugAlert)
        !          1003:     alert("jmolCodebase=" + _jmol.codebase);
        !          1004: }
        !          1005: 
        !          1006: function _jmolOnloadResetForms() {
        !          1007:   _jmol.previousOnloadHandler = window.onload;
        !          1008:   window.onload =
        !          1009:   function() {
        !          1010:     with (_jmol) {
        !          1011:       if (buttonCount+checkboxCount+menuCount+radioCount+radioGroupCount > 0) {
        !          1012:         var forms = document.forms;
        !          1013:         for (var i = forms.length; --i >= 0; )
        !          1014:           forms[i].reset();
        !          1015:       }
        !          1016:       if (previousOnloadHandler)
        !          1017:         previousOnloadHandler();
        !          1018:     }
        !          1019:   }
        !          1020: }
        !          1021: 
        !          1022: ////////////////////////////////////
        !          1023: /////extensions for getProperty/////
        !          1024: ////////////////////////////////////
        !          1025: 
        !          1026: 
        !          1027: function _jmolEvalJSON(s,key){
        !          1028:  s=s+""
        !          1029:  if(!s)return []
        !          1030:  if(s.charAt(0)!="{"){
        !          1031: 	if(s.indexOf(" | ")>=0)s=s.replace(/\ \|\ /g, "\n")
        !          1032: 	return s
        !          1033:  }
        !          1034:  var A = eval("("+s+")")
        !          1035:  if(!A)return
        !          1036:  if(key && A[key])A=A[key]
        !          1037:  return A
        !          1038: }
        !          1039: 
        !          1040: function _jmolEnumerateObject(A,key){
        !          1041:  var sout=""
        !          1042:  if(typeof(A) == "string" && A!="null"){
        !          1043: 	sout+="\n"+key+"=\""+A+"\""
        !          1044:  }else if(!isNaN(A)||A==null){
        !          1045: 	sout+="\n"+key+"="+(A+""==""?"null":A)
        !          1046:  }else if(A.length){
        !          1047:     sout+=key+"=new Array()"
        !          1048:     for(var i=0;i<A.length;i++){
        !          1049: 	sout+="\n"
        !          1050: 	if(typeof(A[i]) == "object"||typeof(A[i]) == "array"){
        !          1051: 		sout+=_jmolEnumerateObject(A[i],key+"["+i+"]")
        !          1052: 	}else{
        !          1053: 		sout+=key+"["+i+"]="+(typeof(A[i]) == "string" && A[i]!="null"?"\""+A[i].replace(/\"/g,"\\\"")+"\"":A[i])
        !          1054: 	}
        !          1055:     }
        !          1056:  }else{
        !          1057:     if(key != ""){
        !          1058: 	sout+=key+"=new Array()"
        !          1059: 	key+="."
        !          1060:     }
        !          1061:     
        !          1062:     for(var i in A){
        !          1063: 	sout+="\n"
        !          1064: 	if(typeof(A[i]) == "object"||typeof(A[i]) == "array"){
        !          1065: 		sout+=_jmolEnumerateObject(A[i],key+i)
        !          1066: 	}else{
        !          1067: 		sout+=key+i+"="+(typeof(A[i]) == "string" && A[i]!="null"?"\""+A[i].replace(/\"/g,"\\\"")+"\"":A[i])
        !          1068: 	}
        !          1069:     }
        !          1070:  } 
        !          1071:  return sout
        !          1072: }
        !          1073: 
        !          1074: 
        !          1075: function _jmolSortKey0(a,b){
        !          1076:  return (a[0]<b[0]?1:a[0]>b[0]?-1:0)
        !          1077: }
        !          1078: 
        !          1079: function _jmolSortMessages(A){
        !          1080:  if(!A || typeof(A)!="object")return []
        !          1081:  var B = new Array()
        !          1082:  for(var i=A.length-1;i>=0;i--)for(var j=0;j<A[i].length;j++)B[B.length]=A[i][j]
        !          1083:  if(B.length == 0) return
        !          1084:  B=B.sort(_jmolSortKey0)
        !          1085:  return B
        !          1086: }
        !          1087: 
        !          1088: /////////additional extensions //////////
        !          1089: 
        !          1090: 
        !          1091: function _jmolDomScriptLoad(URL){
        !          1092:  //open(URL) //to debug
        !          1093:  _jmol.servercall=URL
        !          1094:  var node = document.getElementById("_jmolScriptNode")
        !          1095:  if (node && _jmol.browser!="msie"){
        !          1096:     document.getElementsByTagName("HEAD")[0].removeChild(node)
        !          1097:     node=null
        !          1098:  }
        !          1099:  if (node) {
        !          1100:    node.setAttribute("src",URL)
        !          1101:  } else {
        !          1102:    node=document.createElement("script")
        !          1103:    node.setAttribute("id","_jmolScriptNode")
        !          1104:    node.setAttribute("type","text/javascript")
        !          1105:    node.setAttribute("src",URL)
        !          1106:    document.getElementsByTagName("HEAD")[0].appendChild(node)
        !          1107:  }
        !          1108: }
        !          1109: 
        !          1110: 
        !          1111: function _jmolExtractPostData(url){
        !          1112:  S=url.split("&POST:")
        !          1113:  var s=""
        !          1114:  for(var i=1;i<S.length;i++){
        !          1115: 	KV=S[i].split("=")
        !          1116: 	s+="&POSTKEY"+i+"="+KV[0]
        !          1117: 	s+="&POSTVALUE"+i+"="+KV[1]
        !          1118:  }
        !          1119:  return "&url="+escape(S[0])+s
        !          1120: }
        !          1121: 
        !          1122: function _jmolLoadModel(targetSuffix,remoteURL,array,isError,errorMessage){
        !          1123:  //called by server, but in client
        !          1124:  //overload this function to customize return
        !          1125:  _jmol.remoteURL=remoteURL
        !          1126:  if(isError)alert(errorMessage)
        !          1127:  jmolLoadInlineScript(array.join("\n"),_jmol.optionalscript,targetSuffix)
        !          1128: }
        !          1129: 
        !          1130: //////////user property/status functions/////////
        !          1131: 
        !          1132: function jmolGetStatus(strStatus,targetSuffix){
        !          1133:  return _jmolSortMessages(jmolGetPropertyAsArray("jmolStatus",strStatus,targetSuffix))
        !          1134: }
        !          1135: 
        !          1136: function jmolGetPropertyAsArray(sKey,sValue,targetSuffix) {
        !          1137:  return _jmolEvalJSON(jmolGetPropertyAsJSON(sKey,sValue,targetSuffix),sKey)
        !          1138: }
        !          1139: 
        !          1140: function jmolGetPropertyAsString(sKey,sValue,targetSuffix) {
        !          1141:  var applet = _jmolGetApplet(targetSuffix);
        !          1142:  if(!sValue)sValue=""
        !          1143:  return (applet ? applet.getPropertyAsString(sKey,sValue) + "" : "")
        !          1144: }
        !          1145: 
        !          1146: function jmolGetPropertyAsJSON(sKey,sValue,targetSuffix) {
        !          1147:  if(!sValue)sValue = ""
        !          1148:  var applet = _jmolGetApplet(targetSuffix);
        !          1149:  try {
        !          1150:   return (applet ? applet.getPropertyAsJSON(sKey,sValue) + "" : "")
        !          1151:  } catch(e) {
        !          1152:   return ""
        !          1153:  }
        !          1154: }
        !          1155: 
        !          1156: function jmolGetPropertyAsJavaObject(sKey,sValue,targetSuffix) {
        !          1157:  if(!sValue)sValue = ""
        !          1158:  var applet = _jmolGetApplet(targetSuffix);
        !          1159:  return (applet ? applet.getProperty(sKey,sValue) : null)
        !          1160: }
        !          1161: 
        !          1162: 
        !          1163: function jmolDecodeJSON(s) {
        !          1164:  return _jmolEnumerateObject(_jmolEvalJSON(s),"")
        !          1165: }
        !          1166: 
        !          1167: 
        !          1168: ///////// synchronous scripting ////////
        !          1169: 
        !          1170: function jmolScriptWait(script, targetSuffix) {
        !          1171:   if(!targetSuffix)targetSuffix="0"
        !          1172:   var Ret=jmolScriptWaitAsArray(script, targetSuffix)
        !          1173:   var s = ""
        !          1174:   for(i=Ret.length;--i>=0;)
        !          1175:   for(j=0;j< Ret[i].length;j++)
        !          1176: 	s+=Ret[i][j]+"\n"
        !          1177:   return s
        !          1178: }
        !          1179: 
        !          1180: function jmolEvaluate(molecularMath, targetSuffix) {
        !          1181: 
        !          1182:   //carries out molecular math on a model
        !          1183: 
        !          1184:   if(!targetSuffix)targetSuffix="0"
        !          1185:   var result = "" + jmolGetPropertyAsJavaObject("evaluate", molecularMath, targetSuffix);
        !          1186:   var s = result.replace(/\-*\d+/,"")
        !          1187:   if (s == "" && !isNaN(parseInt(result)))return parseInt(result);
        !          1188:   var s = result.replace(/\-*\d*\.\d*/,"")
        !          1189:   if (s == "" && !isNaN(parseFloat(result)))return parseFloat(result);
        !          1190:   return result;
        !          1191: }
        !          1192: 
        !          1193: function jmolScriptEcho(script, targetSuffix) {
        !          1194:   // returns a newline-separated list of all echos from a script
        !          1195:   if(!targetSuffix)targetSuffix="0"
        !          1196:   var Ret=jmolScriptWaitAsArray(script, targetSuffix)
        !          1197:   var s = ""
        !          1198:   for(i=Ret.length;--i>=0;)
        !          1199:   for(j=Ret[i].length;--j>=0;)
        !          1200:         if (Ret[i][j][1] == "scriptEcho")s+=Ret[i][j][3]+"\n"
        !          1201:   return s.replace(/ \| /g, "\n")
        !          1202: }
        !          1203: 
        !          1204: 
        !          1205: function jmolScriptMessage(script, targetSuffix) {
        !          1206:   // returns a newline-separated list of all messages from a script, ending with "script completed\n"
        !          1207:   if(!targetSuffix)targetSuffix="0"
        !          1208:   var Ret=jmolScriptWaitAsArray(script, targetSuffix)
        !          1209:   var s = ""
        !          1210:   for(i=Ret.length;--i>=0;)
        !          1211:   for(j=Ret[i].length;--j>=0;)
        !          1212:         if (Ret[i][j][1] == "scriptStatus")s+=Ret[i][j][3]+"\n"
        !          1213:   return s.replace(/ \| /g, "\n")
        !          1214: }
        !          1215: 
        !          1216: 
        !          1217: function jmolScriptWaitAsArray(script, targetSuffix) {
        !          1218:  var ret = ""
        !          1219:  try{
        !          1220:   jmolGetStatus("scriptEcho,scriptMessage,scriptStatus,scriptError",targetSuffix)
        !          1221:   if (script) {
        !          1222:     _jmolCheckBrowser();
        !          1223:     var applet=_jmolGetApplet(targetSuffix);
        !          1224:     if (applet) ret += applet.scriptWait(script);
        !          1225:     ret = _jmolEvalJSON(ret,"jmolStatus")
        !          1226:     if(typeof ret == "object")
        !          1227: 	return ret
        !          1228:   }
        !          1229:  }catch(e){
        !          1230:  }
        !          1231:   return [[ret]]
        !          1232: }
        !          1233: 
        !          1234: 
        !          1235: 
        !          1236: ////////////   save/restore orientation   /////////////
        !          1237: 
        !          1238: function jmolSaveOrientation(id, targetSuffix) {  
        !          1239:  if(!targetSuffix)targetSuffix="0"
        !          1240:   return _jmol["savedOrientation"+id] = jmolGetPropertyAsArray("orientationInfo","info",targetSuffix).moveTo
        !          1241: }
        !          1242: 
        !          1243: function jmolRestoreOrientation(id, targetSuffix) {
        !          1244:  if(!targetSuffix)targetSuffix="0"
        !          1245:  var s=_jmol["savedOrientation"+id]
        !          1246:  if (!s || s == "")return
        !          1247:  s=s.replace(/1\.0/,"0")
        !          1248:  return jmolScriptWait(s,targetSuffix)
        !          1249: }
        !          1250: 
        !          1251: function jmolRestoreOrientationDelayed(id, delay, targetSuffix) {
        !          1252:  if(arguments.length < 2)delay=1;
        !          1253:  if(!targetSuffix)targetSuffix="0"
        !          1254:  var s=_jmol["savedOrientation"+id]
        !          1255:  if (!s || s == "")return
        !          1256:  s=s.replace(/1\.0/,delay)
        !          1257:  return jmolScriptWait(s,targetSuffix)
        !          1258: }
        !          1259: 
        !          1260: ////////////  add parameter /////////////
        !          1261: /*
        !          1262:  * for adding callbacks or other parameters. Use:
        !          1263: 
        !          1264:    jmolSetDocument(0)
        !          1265:    var s= jmolApplet(....)
        !          1266:    s = jmolAppletAddParam(s,"messageCallback", "myFunctionName")
        !          1267:    document.write(s)
        !          1268:    jmolSetDocument(document) // if you want to then write buttons and such normally
        !          1269:  
        !          1270:  */
        !          1271: 
        !          1272: function jmolAppletAddParam(appletCode,name,value){
        !          1273:   if(value == "")return appletCode
        !          1274:   return appletCode.replace(/\<param/,"\n<param name='"+name+"' value='"+value+"' />\n<param")
        !          1275: }
        !          1276: 
        !          1277: ///////////////auto load Research Consortium for Structural Biology (RCSB) data ///////////
        !          1278: 
        !          1279: function jmolLoadAjax_STOLAF_RCSB(fileformat,pdbid,optionalscript,targetSuffix){
        !          1280: 
        !          1281:  if(!_jmol.thismodel)_jmol.thismodel = "1crn"
        !          1282:  if(!_jmol.serverURL)_jmol.serverURL="http://fusion.stolaf.edu/chemistry/jmol/getajaxjs.cfm"
        !          1283:  if(!_jmol.RCSBserver)_jmol.RCSBserver="http://www.rcsb.org"
        !          1284:  if(!_jmol.defaultURL_RCSB)_jmol.defaultURL_RCSB=_jmol.RCSBserver+"/pdb/files/1CRN.CIF"
        !          1285:  if(!fileformat)fileformat="PDB"
        !          1286:  if(!pdbid)pdbid=prompt("Enter a 4-digit PDB ID:",_jmol.thismodel)
        !          1287:  if(!pdbid || pdbid.length != 4)return ""
        !          1288:  if(!targetSuffix)targetSuffix="0"
        !          1289:  if(!optionalscript)optionalscript=""
        !          1290:  var url=_jmol.defaultURL_RCSB.replace(/1CRN/g,pdbid.toUpperCase())
        !          1291:  if(fileformat!="CIF")url=url.replace(/CIF/,fileformat)
        !          1292:  _jmol.optionalscript=optionalscript
        !          1293:  _jmol.thismodel=pdbid
        !          1294:  _jmol.thistargetsuffix=targetSuffix
        !          1295:  _jmol.thisurl=url
        !          1296:  _jmol.modelArray = new Array()
        !          1297:  url=_jmol.serverURL+"?returnfunction=_jmolLoadModel&returnArray=_jmol.modelArray&id="+targetSuffix+_jmolExtractPostData(url)
        !          1298:  _jmolDomScriptLoad(url)
        !          1299:  return url
        !          1300: }
        !          1301: 
        !          1302: /////////////// St. Olaf College AJAX server -- ANY URL ///////////
        !          1303: 
        !          1304: function jmolLoadAjax_STOLAF_ANY(url, userid, optionalscript,targetSuffix){
        !          1305:  _jmol.serverURL="http://fusion.stolaf.edu/chemistry/jmol/getajaxjs.cfm"
        !          1306:  if(!_jmol.thisurlANY)_jmol.thisurlANY = "http://www.stolaf.edu/depts/chemistry/mo/struc/data/ycp3-1.mol"
        !          1307:  if(!url)url=prompt("Enter any (uncompressed file) URL:", _jmol.thisurlANY)
        !          1308:  if(!userid)userid="0"
        !          1309:  if(!targetSuffix)targetSuffix="0"
        !          1310:  if(!optionalscript)optionalscript=""
        !          1311:  _jmol.optionalscript=optionalscript
        !          1312:  _jmol.thistargetsuffix=targetSuffix
        !          1313:  _jmol.modelArray = new Array()
        !          1314:  _jmol.thisurl = url
        !          1315:  url=_jmol.serverURL+"?returnfunction=_jmolLoadModel&returnArray=_jmol.modelArray&id="+targetSuffix+_jmolExtractPostData(url)
        !          1316:  _jmolDomScriptLoad(url)
        !          1317: }
        !          1318: 
        !          1319: 
        !          1320: /////////////// Mineralogical Society of America (MSA) data /////////
        !          1321: 
        !          1322: function jmolLoadAjax_MSA(key,value,optionalscript,targetSuffix){
        !          1323: 
        !          1324:  if(!_jmol.thiskeyMSA)_jmol.thiskeyMSA = "mineral"
        !          1325:  if(!_jmol.thismodelMSA)_jmol.thismodelMSA = "quartz"
        !          1326:  if(!_jmol.ajaxURL_MSA)_jmol.ajaxURL_MSA="http://rruff.geo.arizona.edu/AMS/result.php?mineral=quartz&viewing=ajaxjs"
        !          1327:  if(!key)key=prompt("Enter a field:", _jmol.thiskeyMSA)
        !          1328:  if(!key)return ""
        !          1329:  if(!value)value=prompt("Enter a "+key+":", _jmol.thismodelMSA)
        !          1330:  if(!value)return ""
        !          1331:  if(!targetSuffix)targetSuffix="0"
        !          1332:  if(!optionalscript)optionalscript=""
        !          1333:  if(optionalscript == 1)optionalscript='load "" {1 1 1}'
        !          1334:  var url=_jmol.ajaxURL_MSA.replace(/mineral/g,key).replace(/quartz/g,value)
        !          1335:  _jmol.optionalscript=optionalscript
        !          1336:  _jmol.thiskeyMSA=key
        !          1337:  _jmol.thismodelMSA=value
        !          1338:  _jmol.thistargetsuffix=targetSuffix
        !          1339:  _jmol.thisurl=url
        !          1340:  _jmol.modelArray = new Array()
        !          1341:  loadModel=_jmolLoadModel
        !          1342:  _jmolDomScriptLoad(url)
        !          1343:  return url
        !          1344: }
        !          1345: 
        !          1346: 
        !          1347: 
        !          1348: function jmolLoadAjaxJS(url, userid, optionalscript,targetSuffix){
        !          1349:  if(!userid)userid="0"
        !          1350:  if(!targetSuffix)targetSuffix="0"
        !          1351:  if(!optionalscript)optionalscript=""
        !          1352:  _jmol.optionalscript=optionalscript
        !          1353:  _jmol.thismodel=userid
        !          1354:  _jmol.thistargetsuffix=targetSuffix
        !          1355:  _jmol.modelArray = new Array()
        !          1356:  _jmol.thisurl = url
        !          1357:  url+="&returnFunction=_jmolLoadModel&returnArray=_jmol.modelArray&id="+targetSuffix
        !          1358:  _jmolDomScriptLoad(url)
        !          1359: }
        !          1360: 
        !          1361: 
        !          1362: //// in case Jmol library has already been loaded:
        !          1363: 
        !          1364: }catch(e){}
        !          1365: 
        !          1366: ///////////////moving atoms //////////////
        !          1367: 
        !          1368: // HIGHLY experimental!!
        !          1369: 
        !          1370: function jmolSetAtomCoord(i,x,y,z,targetSuffix){
        !          1371:     _jmolCheckBrowser();
        !          1372:       var applet=_jmolGetApplet(targetSuffix);
        !          1373:       if (applet) applet.getProperty('jmolViewer').setAtomCoord(i,x,y,z)
        !          1374: }
        !          1375: 
        !          1376: function jmolSetAtomCoordRelative(i,x,y,z,targetSuffix){
        !          1377:     _jmolCheckBrowser();
        !          1378:       var applet=_jmolGetApplet(targetSuffix);
        !          1379:       if (applet) applet.getProperty('jmolViewer').setAtomCoordRelative(i,x,y,z)
        !          1380: }
        !          1381: 
        !          1382: 
        !          1383: ///////////////applet fake for testing buttons/////////////
        !          1384: 
        !          1385: 
        !          1386: if(document.location.search.indexOf("NOAPPLET")>=0){
        !          1387: 	jmolApplet = function(w){
        !          1388: 		var s="<table style='background-color:black' width="+w+"><tr height="+w+">"
        !          1389: 		+"<td align=center valign=center style='background-color:white'>"
        !          1390: 		+"Applet would be here"
        !          1391: 		+"<p><textarea id=fakeApplet rows=5 cols=50></textarea>"
        !          1392: 		+"</td></tr></table>"
        !          1393: 		return _jmolDocumentWrite(s)
        !          1394: 	}
        !          1395: 
        !          1396: 	_jmolFindApplet = function(){return jmolApplet0}
        !          1397: 
        !          1398: 	jmolApplet0 = {
        !          1399: 	 script: function(script){document.getElementById("fakeApplet").value="\njmolScript:\n"+script}
        !          1400: 	,scriptWait: function(script){document.getElementById("fakeApplet").value="\njmolScriptWait:\n"+script}	
        !          1401: 	,loadInline: function(data,script){document.getElementById("fakeApplet").value="\njmolLoadInline data:\n"+data+"\n\nscript:\n"+script}
        !          1402: 	}
        !          1403: }
        !          1404: 
        !          1405: 
        !          1406: ///////////////////////////////////////////
        !          1407: 
        !          1408: //new 9:49 AM 3/6/2007:
        !          1409: 
        !          1410: //both w and h are optional. 
        !          1411: //if either is between 0 and 1, then it is taken as percent/100.
        !          1412: //if either is greater than 1, then it is taken as a size. 
        !          1413: function jmolResize(w,h) {
        !          1414:  _jmol.alerted = true;
        !          1415:  var percentW = (!w ? 100 : w <= 1  && w > 0 ? w * 100 : 0)
        !          1416:  var percentH = (!h ? percentW : h <= 1 && h > 0 ? h * 100 : 0)
        !          1417:  if (_jmol.browser=="msie") {
        !          1418:    var width=document.body.clientWidth;
        !          1419:    var height=document.body.clientHeight;
        !          1420:  } else {
        !          1421:    var netscapeScrollWidth=15;
        !          1422:    var width=window.innerWidth - netscapeScrollWidth;
        !          1423:    var height=window.innerHeight-netscapeScrollWidth;
        !          1424:  }
        !          1425:  var applet = _jmolGetApplet(0);
        !          1426:  if(!applet)return;
        !          1427:  applet.style.width = (percentW ? width * percentW/100 : w)+"px"
        !          1428:  applet.style.height = (percentH ? height * percentH/100 : h)+"px"
        !          1429:  title=width +  " " + height + " " + (new Date())
        !          1430: }
        !          1431: 

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