// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// This is a placeholder file into which special controls for molecular
// views, such as checkboxes, can be inserted. For an explanation, see
// the Authoring Instructions section on Checkboxes.
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

// Create a chapter-specific writeJmolControls() function here.
// It must generate the control HTML and place it in the appropriate
// division(s), e.g. divisions named jcontrol1 (and optionally
// jcontrol2, jcontrol3, etc.).

function writeJmolControls()
{
	var chtml = "";
	var cRhtml = "";

// Here is an example that creates three radio buttons.
// to a jcontrol1 division, or any specified division(s).

	var radButs = new Array();
	var isChecked = true;
	var isNotChecked = false;

	radButs[0] = ["!script face.spt", "Face", isChecked,
		"radioOrientations", ""];
	radButs[1] = ["!script side.spt", "Side", isNotChecked,
		"radioOrientations", ""];
	radButs[2] = ["!script end.spt", "End", isNotChecked,
		"radioOrientations", ""];

	cRhtml += " &nbsp; " + setupJmolRadioGroup(radButs,
		" ", "radioOrientations", "");

// Here is an example that creates a single checkbox to hide/show
// chain :p. Additional checkboxes can be added in the same way,
// to this jcontrol1 division, or to other jcontrol divisions.

	chtml += "<br> &nbsp; " + setupJmolCheckbox("!display displayed or :p;",
		"!hide :p;",
		'Show <font color="#00ff00">Peptide</font>', isChecked);

// A second checkbox
	chtml += "<br> &nbsp; " + setupJmolCheckbox(
		"!select ~cleft,:p; spacefill; color atoms opaque;",
		"!select ~cleft; spacefill off;select :p;color atoms translucent -1;color cartoon opaque;",
		'Spacefill (use Cut slider below)', isNotChecked);

// And a third
	chtml += "<br><br> &nbsp; " + setupJmolCheckbox(
		"!select ~cleft; color structure;",
		"!script co_cleft.spt; ",
		'Color by secondary structure', isNotChecked);

	cRhtml += chtml;

	document.getElementById("jcontrol1").innerHTML = cRhtml;
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Here is the service function that actually generates the checkbox
// HTML.

function setupJmolCheckbox(whenChecked, whenUnchecked,
	labelHtml, startsChecked)
{
	// Save the current document.
	var cdoc = _jmol.currentDocument;

	// Tell Jmol.js functions not to write into the current document, but merely
	// to return the relevant HTML.
	_jmol.currentDocument = false;

	// Use the checkbox-generating function in Jmol.js to make HTML
	// for a checkbox.
	var chtml = jmolCheckbox(whenChecked, whenUnchecked, labelHtml,
		startsChecked);

	// Restore current document to its default.
	_jmol.currentDocument = cdoc;

	// Return the checkbox HTML.
	return chtml;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function setupJmolRadioGroup(arrayOfRadiobuttons, separatorHtml,
  groupName, id, title)
{
	// Save currentDocument
	var cdoc = _jmol.currentDocument;

	// Tell Jmol.js functions not to write into the current document, but merely
	// to return the relevant HTML.
	_jmol.currentDocument = false;

	// Use the radio button-generating function in Jmol.js to make the HTML.
	var cRhtml = jmolRadioGroup(arrayOfRadiobuttons, separatorHtml,
	  groupName, id, title);

	// Restore current document to its default.
	_jmol.currentDocument = cdoc;

	// Return the radio button HTML.
	return cRhtml;
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
