/* $Ergänzungsdatei zu Jmol.js $
 * $Author: Dr.Detlef Pagel, Wetzlar, Germany $
 * $Date: 10.01.2006 13:45:00 $
 * $Version: 1.1 $
 *
 * Copyright (C) 2006 Dr.Detlef Pagel, Wetzlar, Germany
 */

 // *****************************************************************
 //   meine neuen Werte und Funktionen:
 // *****************************************************************
	var sizeall="0"; // bei Gebrauch von vier Applets muss im Programmteil oder in einer späteren Function "4" stehen

function jmolButtonAlle(script, label, id) {
  _jmolInitCheck();
  var scriptIndex = _jmolAddScript(script);
  if (label == undefined || label == null)
    label = script.substring(0, 32);
  if (id == undefined || id == null)
    id = "jmolButton" + _jmol.buttonCount;
  ++_jmol.buttonCount;
  var t = "<input type='button' name='" + id + "' id='" + id +
          "' value='" + label +
          "' onClick='_jmolClickAlle(" + scriptIndex + _jmol.targetText +
          ")' onMouseover='_jmolMouseOver(" + scriptIndex +
          ");return true' onMouseout='_jmolMouseOut()' " +
          _jmol.buttonCssText + "/>";
  if (_jmol.debugAlert)
    alert(t);
  document.write(t);
}

function _jmolClickAlle(scriptIndex, targetSuffix) {
  if (_jmol.debugAlert){
    alert("scriptindex;targetSuffix,_jmol.scripts[scriptindex],sizeall =:"+scriptIndex+" ; "+targetSuffix+" ; "+_jmol.scripts[scriptIndex]+" ; "+sizeall+" ; ");
 };
  jmolScriptAlle(_jmol.scripts[scriptIndex], targetSuffix);
}

function jmolScriptAlle(script, targetSuffix) {
  if (script) {
    _jmolCheckBrowser();
iall=0;
for (iall = 0; iall < sizeall; ++iall) {
   var target = "jmolApplet"+ iall;
//  alert("target ("+iall+") =:" +target);
   var applet = _jmolFindApplet(target);
    if (applet)
      applet.script(script);
    else
      {alert("could not find applet " + target);return;}
} //for
      return;
  } //script
}

function jmolCheckboxAlle(scriptWhenChecked, scriptWhenUnchecked,
                      labelHtml, isChecked, id) {
  _jmolInitCheck();
  if (id == undefined || id == null)
    id = "jmolCheckbox" + _jmol.checkboxCount;
  ++_jmol.checkboxCount;
  if (scriptWhenChecked == undefined || scriptWhenChecked == null ||
      scriptWhenUnchecked == undefined || scriptWhenUnchecked == null) {
    alert("jmolCheckbox requires two scripts");
    return;
  }
  if (labelHtml == undefined || labelHtml == null) {
    alert("jmolCheckbox requires a label");
    return;
  }
  var indexChecked = _jmolAddScript(scriptWhenChecked);
  var indexUnchecked = _jmolAddScript(scriptWhenUnchecked);
  var t = "<input type='checkbox' name='" + id + "' id='" + id +
          "' onClick='_jmolCbClickAlle(this," +
          indexChecked + "," + indexUnchecked + _jmol.targetText +
          ")' onMouseover='_jmolCbOver(this," + indexChecked + "," +
          indexUnchecked +
          ");return true' onMouseout='_jmolMouseOut()' " +
	  (isChecked ? "checked " : "") + _jmol.checkboxCssText + "/>" +
          labelHtml;
  if (_jmol.debugAlert)
    alert(t);
  document.write(t);
}

function _jmolCbClickAlle(ckbox, whenChecked, whenUnchecked, targetSuffix) {
  _jmolClickAlle(ckbox.checked ? whenChecked : whenUnchecked, targetSuffix);
}

 // *****************************************************************
 //   meine neuen Werte und Funktionen;
 // #################################################################
