// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// This file defines special controls for molecular
// views, such as checkboxes. For an explanation, see
// the Authoring Instructions section on Checkboxes.
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

// Here is a chapter-specific writeJmolControls() function.
// It generates the HTML for the checkboxes and places it in the appropriate
// division, here defined in chapter.js and named jcontrol1.

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function writeJmolControls()
{
	var chtml = "";

	chtml += " &nbsp; " + setupJmolCheckbox("select solvent; spacefill;",
		"select solvent; spacefill off;",
		"<span class='solvent'>Solvent</span>", true);

	chtml += " &nbsp; " + setupJmolCheckbox("select protein; spacefill;",
		"select protein; spacefill off;",
		"<span class='protein'>Protein</span>", true);

	chtml += " &nbsp; " + setupJmolCheckbox("select dna; spacefill;",
		"select dna; spacefill off;",
		"<span class='dna'>DNA</span>", true);

	chtml += " &nbsp; " + setupJmolCheckbox("select rna and not hetero; spacefill;",
		"select rna and not hetero; spacefill off;",
		"<span class='rna'>RNA</span>", true);

	chtml += " &nbsp; " + setupJmolCheckbox("select hetero and not solvent; spacefill;",
		"select hetero and not solvent; spacefill off;",
		"<span class='ligand'>Ligand</span>", true);

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

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