// utility function
function br(br_arg)
{
	wr_doc("<br" + br_arg + ">");
}

// wr_thirds() is designed for put_mol(), where w1 and w3 are invariant
// and w2 establishes different color schemes.
function wr_thirds(w1, w2, w3)
{
	with(document)
	{
		open();
		writeln(w1);
		writeln(w2);
		writeln(w3);
		close();
	}
}

// wr_doc() saves another open/close when we have only one string to write.
function wr_doc(to_write)
{
	with(document)
	{
		open();
		writeln(to_write);
		close();
	}
}

function put_mol(midtxt)
{
// Terminal \n prevents comment from affecting subsequent lines
//  Note: I'm opening and closing the document many times within this function.
// This seems to be OK.

//	wr_doc("<embed src='1d66-pwz.pdb'");
	wr_doc("<embed type='chemical/x-pdb' src='1atom.pdb' spiny=15");

	if (debug)
		wr_doc("bgcolor='#202020' width=50% height=37% debugscript=on align=right\n");
	else
		wr_doc("bgcolor=black width=100% height=85%");

	wr_doc("menudelay=900");
	wr_doc("MessageCallback='parent.fr_mol.ChimeMsg' name='cgdna'>");

/*
	wr_thirds("MessageCallback='ChimeMsg'\n" +
		"name='cgdna'\n" +
		"script=\"\n",

// CAN BE INSERTED IF DESIRED
//		"javascript toggle_single_step()\n",
		
	midtxt + ";\n", // intended for color scheme

//		"script 'reset.spt';" + CALLING SCRIPT HERE PRODUCES UNWANTED REFRESH. WHY?!

		"select all;\n" +
		"define current selected;\n" +
		"hbonds;\n" +
		"color hbonds white;\n" +
		"zoom 200;\n" +
		"rotate z 90;\n" +
		"rotate y 10;\n" +

		"refresh;\n" +
		"center selected;\n" + // causes mispositioning w/o prior refresh
		"\">"
	);
*/
}
