// loadscript() is for IE

var waiting_script = "";
var waiting_to_load = "";
// busy is defined in msgcall.js

function loadscript(pdbfile, spt)
{
	var s = "";
	if (isNetscape)
	{
		s = "load " + pdbfile + ";\n" + spt;
		scriptToChime(s);
	}
	if (isIE)
	{
		waiting_script = spt;
		scriptToChime("load " + pdbfile + ";");
	}
}

function do_waiting_script()
{
	s2c_regardless(waiting_script);
	waiting_script = "";
}

function do_waiting_to_load()
{
	s2c_regardless("load " + waiting_to_load + "\nwireframe off\n");
	waiting_to_load = "";
}

function scriptToChime(script)
{
	if (busy)
	{
		alert("Busy -- Please wait until Ready.\n" +
		"(See indicator at lower right.)");
	}
	set_busy(true);
	s2c_regardless(script);
}

function s2c_regardless(script)
{
	with (top.fr_dummy.document)
	{
		open();
		writeln("<html><head></head><body bgcolor=white>");

		// write a Chime button which will execute it's script immediately
//		writeln("<embed type=\"application/x-spt\" hidden=true"); UNHIDE TEMPORARILY FOR SGI
		writeln("<embed type=\"application/x-spt\"");

		writeln(" width=20 height=20 button=push target='cgdna'");

//		writeln(" ButtonCallback='bcb'");

		writeln(" script=\""+script+"\" immediate=1>");

		writeln("</body></html>");

		close();
	}
}

function set_busy(mode)
{
	if (!busygif)
		return;
	if (mode)
	{
		busy = true;
		showbusy("busy");
	}
	else
	{
		if (waiting_to_load != "")
		{
			do_waiting_to_load();
			return;
		}
		if (waiting_script != "")
		{
			do_waiting_script();
			return;
		}
		busy = false;
		showbusy("ready");
	}
}

function showbusy(toshow)
{
	if (!busygif) // for dna53.htm
		return;

	if (toshow == "busy")	
		document.busybody.src = "busy.gif";
	else
		document.busybody.src = "ready.gif";	
}

function say_busybody() // when Busy/Ready is clicked.
{
	alert("You clicked the Busy/Ready indicator.\n" +
		"Please click the gray [X] buttons\nonly when it says Ready.");
}

