/*
ButtonCallback then reports the name of the button (e.g. b_xspin)
as the first parameter in bcb(bi, after).

[Before the buttons were named, the callback parameter was a
button index number.]

bcb(bi, after)  calls bcb_action(), which is defined separately
for each page (b_pairs.js, b_code.js, etc.).
*/

function button(tag, action, bname)
{
	with(document)
	{
	writeln(tag + "&nbsp;<embed type='application/x-spt' name='" + bname + "'");
	writeln(" width=12 height=12 button=push target='cgdna'");
	// writeln(" name='" + name + "'"); SEE NOTE ABOVE
	writeln(" ButtonCallback='parent.fr_mol.bcb'>");
//	writeln(" script=\"" + action + "\">" + tag);
	writeln("&nbsp;&nbsp;");
	}
}

// When the button is pushed, this function is called twice, once before
// the script (if any) in the embed-tag-button is processed by Chime ('after'
// false); once after the script is processed ('after' true).

// SEE NOTE ABOVE

function bcb(bi, after)
{
	if (after)
	{
//		var i = parseInt(bi.substring(7,9));
//		bcb_action(i);

//		alert("button.js #1: bcb(" + bi + ")");

		bcb_action(bi);

		if (getCookie("debugc") == "ON")
		{
			// TRIM MSG BOX CONTENTS TO N LINES
			// Note: this occurs while Chime continues to emit messages to the box.
			// Therefore, there may be more than 30 lines in the box when the
			// script is finished (e.g. with AT).
			top.fr_mol.document.c2w_form.chimemessages.value = del_after_line(50,
			top.fr_mol.document.c2w_form.chimemessages.value);

			top.fr_mol.document.c2w_form.chimemessages.value =
					top.fr_mol.document.c2w_form.chimemessages.value +
					"----OLDER LINES ERASED----\n";
		}
	}
}

