/*
JS function for getting variables passed to the current document from
the previous document via an anchor link using the syntax
<a href="viewjs.htm?v1=filename.js&v2=what+ever">filename.js</a>

This mechanism is simpler and less flexible/powerful than the cookie
method (see cookie.js).
*/

// returns BLANK string no such parameter

function getqparb(toget)
{
	var qv = getqpar(toget);
	if (qv == ("ERROR: " + toget + " NOT DEFINED."))
		return("");
	else return(qv);
}

// returns ERROR string if no such parameter
function getqpar(toget)
{
	var del = toget.length + 1; // + 1 for equal sign
	var allvars = top.window.location.search;

	var s0 = allvars.indexOf(toget + "=");
	if (s0 == -1)
		return ("ERROR: " + toget + " NOT DEFINED.");

	var s1 = allvars.indexOf("&", s0 + del);
	if (s1 == -1)
		var result = allvars.substring(s0 + del);
	else
		var result = allvars.substring(s0 + del, s1);
	return result;
}
