// This function puts Chime's messages in the message textarea.function ChimeMsg( buttonname, message ){	top.control_fr.document.c2w_form.chimemessages.value = message + "\r\n" +		top.control_fr.document.c2w_form.chimemessages.value;	top.control_fr.document.c2w_form.chimemessages.value = del_after_line(4,		top.control_fr.document.c2w_form.chimemessages.value);}// This function writes the 2-way html form into the document.function Chime_2way(target_chime){	with (top.control_fr.document)	{		open();		// Set up command-line form.		// We don't need to submit the form to the SERVER.  'return false'		// prevents this from happening.  We just want to use the form		// values internally in the CLIENT-side javascript.				writeln("<form name='c2w_form'");		writeln("onSubmit='exec_script(\"" + target_chime + "\"); return false'>");		// Command-line input slot.		writeln("<input type='text' name='rasmolscript'");		writeln("size='50' maxlength='100'>");		writeln("<font color=green>You will have to display the selected amino acid as \"Spacefill\" - \"Van Der Waals Radii\" since \"Ball & Stick\" is not large enough to show up clearly.</font>");		writeln("<p>Click on an atom and Chime will identify it below.<p>");		writeln("<p>Chime's message will appear at the <b>top</b> of the window.<p>");		// Box to display Chime's messages		writeln("<textarea name='chimemessages' rows=4 cols=45></textarea>");		// end of this form		writeln("</form>");		// close() forces the display of the page.		close();	}}// This function sends the script to the Chime plug-in.// The mechanism is to create a new document in the tiny 'dummy' frame.// This new document contains a hidden button to execute the script.// The button executes immediately (does not need to be clicked).function ScriptToChime(target_chime, rasmol_script){	with (top.fr_dummy.document)	{		open();		writeln("<html><head></head><body bgcolor=white>");		writeln("<embed type=\"application/x-spt\" hidden=true");		writeln(" width=10 height=10 button=push target=\"" + target_chime + "\"");		writeln(" script=\"" + rasmol_script + "\" immediate=1>");		writeln("</body></html>");		close();	}}// This function sends the command line to Chime and then cleans up.function exec_script(target_chime){	ScriptToChime(target_chime, document.c2w_form.rasmolscript.value);	document.c2w_form.rasmolscript.value = ""; // clear the command slot}/*this was stolen from Eric's textutils.js - it's all that's needed here */function del_after_line(n, s){	// find n'th \n	var ret = 0;	for (i=1; i <= n; i++)	{		ret = s.indexOf("\r", ret);		if (ret == -1)			return(s);		ret++;	}	// cut off from n'th \n	return(s.substring(0, ret));}/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */// END OF CHIM2WAY.JS