// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// 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 = "";

	chtml += " &nbsp; " + setupJmolCheckbox(
		"!select (:a,:b,:c) and not water; spacefill; color opaque;",
    "!select (:a,:b) and protein; spacefill off; \
select :c,((:a,:b) and not (protein,water));color translucent -1;",
		"Spacefill", false);

// N.B. "and protein" prevents a crash in Jmol 12.0.11!

	chtml += "<br> &nbsp; " + setupJmolCheckbox(
		"!select (:a,:b) and protein; color structure; color cartoon structure;",
    "!script cs_dr1.spt;",
		"Color by secondary structure<br>" + ss_key(), false);

	document.getElementById("jcontrol1").innerHTML = chtml;

// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
	var html2 = "";

	html2 += " &nbsp; " + setupJmolCheckbox(
		"!script pepprops.spt;",
    "!script cs_pept.spt;",
		"Color peptide by charge, polarity:" + custom_polarity(), false);

	document.getElementById("jcontrol2").innerHTML = html2;
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// 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;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
