// debug alerts through # 1

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function writeFGControls()
{
	controlPanel = "fg";

	var fgc = "";

	// DEBUGGING CONTROLS ** NEWLY UNCONDITIONAL FOR LABEL CHECKBOXES
//	if (checkboxToDebugScripts || debuggingFG || buttonToShowMessages)
		fgc += "<form name='controlsForm'> \n";

	fgc += "<center>";

	if (checkboxToDebugScripts || debuggingFG)
		fgc += makeDebugCheckbox();

	if (buttonToShowMessages || debuggingFG)
		fgc += 
"<input type='button' onClick='showMessagesInWindow()' \
value='Messages'> \
<input type='button' onClick='showMessageTopEscapedInWindow()' \
value='\\n\\r'> \
<input type='button' onClick='messageStream=\"\"' \
value='Clear'> \
<input type='button' onClick='show_pipe_block()' \
value='Show'> \
";

	if (checkboxToDebugScripts || debuggingFG || buttonToShowMessages)
		fgc += "<br>";

	// END DEBUGGING CONTROLS

	fgc +=
	makeViewLink("rocketSpt", "Secondary Structure", "makeRocketHelp()",
		"Colored by Secondary Structure, with Rocket Helices")
		+ "&nbsp; &nbsp;" +
	makeViewLink("cartoonSpt", "Cartoon", "makeCartoonHelp()", "Backbone Ribbons Colored By Chain")
		+ "&nbsp; &nbsp;" +
	makeViewLink("rainbowSpt",
		"<nobr>N<img src='arrow.gif' border='0'>C&nbsp;Rainbow</nobr>",
		"makeRainbowHelp()", "Amino and Carboxy Termini")
		+ "<br>" +

	makeViewLink("compositionSpt", "Composition", "makeCompositionHelp()",
		"Protein, DNA, RNA, Ligand, & Solvent")
		+ "&nbsp; &nbsp;" +
	makeViewLink("polaritySpt", "Hydrophobic/Polar", "makePolarityHelp()",
		"Hydrophilic vs. Lipophilic")
		+ "&nbsp; &nbsp;" +
	makeViewLink("makeChargeSpt()", "Charge..", "makeChargeHelp()",
		"Negatively & Positively Charged Amino Acids")
		+ "<br>" +

	makeViewLink("makePreContactsSpt()", "Contacts..", "makePreContactsHelp()",
		"See Non-Covalent Bonds")
		+ "&nbsp; &nbsp;" +
	makeViewLink("makeVineSpt()", "Vines..", "makeVinesHelp()",
		"All-Atom Detail")
		+ "&nbsp; &nbsp;" +
	makeViewLink("allModelsSpt", "All&nbsp;Models", "makeAllModelsHelp()",
		"See Multiple Models in NMR Ensembles")
		+ "&nbsp; &nbsp;" +
	makeViewLink("hideSpt", "Hide..", "makeHideHelp()",
		"Hide Portions of the Molecule")
		+ "&nbsp; &nbsp;" +
	makeViewLink("makePreFindSpt()", "Find..", "makeFindHelp()",
		"Locate Sequence Numbers, Elements, Amino Acids, or Bases in 3D")

	// START TABLE CONTAINING BUTTONS

	+ "<table border=0 cellpadding=3><tr><td>"

// Use of <br> between buttons causes IE to double-space them.
// Firefox and Netscape 4 single-space them.

	+ "<div>" +

	makeToggleButton("ligandSpt", "ligandOffSpt", "Ligands+..", "down",
		"makeLigandsHelp()", "Show or Hide Ligands+")
	+ "<\/div>" +
	makeToggleButton("waterSpt", "waterOffSpt", "Water..", "up",
		"makeWaterHelp()", "Show or Hide Water")
	+ "<div>" +
	makeToggleButton("makeSlabSpt(true)", "slabOffSpt", "Slab..", "up",
		"makeSlabHelp()", "See Uncluttered Details with a Slice through the Interior")
	+ "<\/div>" +

	"<\/td><td>" + //&nbsp; &nbsp;<\/td><td>" +

	makeBkgSpinZoomButtons(true) // incolumn=true

	// END OF TABLE CONTAINING BUTTONS

	+ "</td></tr></table>\n" +

	// CONTROLS BELOW BUTTONS

//	makeSafari() + // REMOVED in FGiJ 1.43

	makeViewLink("moreViews", "More&nbsp;Views..", "makeMoreViewsHelp()",
		"Non-Standard Residues, Model Quality, Distances & Angles, Unit Cell, \
Advanced Features, Related Viewers")
	+ "&nbsp; &nbsp; &nbsp;" +

	makeInfoLinks()

		+ "<br>" +

	makeBottomLinks();

	fgc += "<br><a href='index.htm' target=_blank>New Session..</a>";

	fgc += makeLabelsCheckboxes();

	if (showPDBURL)
		fgc += '<br><font color="magenta">' + pdbURL + '</font>';

//	if (checkboxToDebugScripts || debuggingFG || buttonToShowMessages)
		fgc += "</form>";
	fgc += "</center>";

//	alert("controls.js #1: filling controlsDiv.");

	// controlsTarget: This works fine on first load in new tab, but fails
	// controlsTarget: as undefined on reload for reasons unknown.
	// controlsTarget: There was a similar problem in consurf/consurf.js.
	// controlsTarget: So we'll re-initialize it for good measure.

	initTargetDivs();
	controlsTarget.innerHTML = fgc;

}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function makeBkgSpinZoomButtons(incolumn)
{
	var bsz = ""
	if (incolumn)
		bsz += "<div>\n";

	bsz +=
	makeToggleButton("bgWhiteSpt", "bgBlackSpt", "Background", "down", "",
		"White vs. Black Background")

	if (incolumn)
		bsz += "<\/div>\n";
	else
		bsz += "&nbsp; &nbsp;";

	bsz +=
	makeToggleButton("spinOnSpt", "spinOffSpt", "Spin", "down", "",
		"Start or Stop Spinning")

	bsz += "&nbsp; &nbsp; &nbsp;" +
	makeToggleButton("qualityOnSpt", "qualityOffSpt", "Quality", "up", "",
		"Toggle Molecular Graphics Quality")

	if (incolumn)
		bsz += "<div>\n";
	else
		bsz += "&nbsp; &nbsp;";
	
	bsz +=
"<a href=\"javascript: top.doZoom('');\">" +
"<img src=\"zoomup.gif\" border=\"0\" title='Bigger'>" +
"</a><a href=\"javascript: top.doZoom('-');\">" +
"<img src=\"zoomdown.gif\" border=\"0\" title='Smaller'>" +
"</a>&nbsp;Zoom</div>\n";

	if (incolumn)
		bsz += "<\/div>\n";
	
	return bsz;
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function makeDebugCheckbox()
{
	var dbc =
"<input type='checkbox' onClick='setDebugScripts()' \
name='debugSpts'><font color='red'>Debug Scripts</font> \
&nbsp; \
<a href='javascript: show_pipe_block()'><font color='red'>Header</font></a> \
&nbsp; \
<a href='javascript: reDisplay(\"\", \"\")'><font color='red'>reDisplay()</font></a> \
&nbsp; \
<a href='javascript: alert(currentView)'><font color='red'>currentView</font></a>";

	return dbc;
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function makeBottomLinks()
{
	var botl =

	makeViewLink("centerSpt", "Center&nbsp;Atom..", "centerAtomHelp",
		"Center One Atom, or the Entire Molecule")
		+ "&nbsp; &nbsp;" +
	makeViewLink("troubleshooting", "Troubleshooting", "makeTroubleHelp()",
		"Pitfalls, Java, Browsers, OSX, Windows, Linux")
		+ "&nbsp; &nbsp;";

	if (controlPanel == "fg")
		botl +=
		makeViewLink("makeView1Spt()", "Reset", "makeIntroHelp()",
		"Restore the Initial View")
		+ "&nbsp; &nbsp;";
//	else // consurf
//		botl +=
//"<a href='javascript: resetConsurf()' \
//title='Restore the Initial ConSurf View'>Reset</a> &nbsp; &nbsp;";
// or confirm_reset_consurf()?

	botl +=
		"<a href=\"javascript: closeFgij()\" \
			title='Quit This Session'>Close</a>";

	return botl;
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function makeLabelsCheckboxes()
{
	var cklon = "";
	if (labelsOn)
		cklon = " checked";

	var cklf = "";
	if (labelsFront)
		cklf = " checked";

	var ckid = "";
	if (labelsID)
		ckid = " checked";

//title='Click for explanation of labels.'>\

	var lboxes =
"<br>Labels <a href='notes.htm#labels' target=_blank \
title='X=NonStandard, S-=Sidechain Incomplete, ?=Anomalous'>\
<font face='sans-serif'><b>X, S-, ?</b></font></a>:\
<span title='Show or Hide X/S-/? Labels'>\
<input type='checkbox' onClick=toggleLabelsShow()" + cklon + ">Show</span>\
&nbsp; &nbsp;\
<span title='Show X/S-/? Labels in Front'>\
<input type='checkbox' onClick=toggleLabelsFront()" + cklf + ">Front</span>\
&nbsp; &nbsp;\
<span title='Identify X/S-/? Labeled Atoms'>\
<input type='checkbox' onClick=toggleLabelsID()" + ckid + ">ID</span>\
";


	return lboxes;
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

