<!-- script Language="JavaScript" type="text/javascript" -->
/*

This script processes the QueryString values so that 
they can be accessed by request using javascript.

It uses simple string processing techniques to get 
the required values.

*/

// Global vars
var sQueryString = "";		// Querystring value

function sGetQS() {

	// This function returns the querystring.
	// The Querystring is everything in the URL from the "?"
	// e.g. something.htm?querystring_values
	
	var sTemp = document.location.href;		// Get complete URL
	var iPos = sTemp.indexOf("?");			// Get the location of ?
	var sRetVal = "";						// Set up return value
	
	if ( (iPos != -1) && (iPos != sTemp.length) ){
		// Possible QS
		sRetVal = sTemp.substring(iPos + 1, sTemp.length);
	}
	else {
		// No query string
		sRetVal = "";
	}
	
	return sRetVal;		// Return the querystring
}

function sGetQSVal(sQSVar) {

	// This function returns the value of the querystring variable sQSVar
	// If the variable is not found it returns "" (nothing)
	// Else it returns the value in STRING format

	var sTempQS = sQueryString.toLowerCase();					// Convert qs to lowercase for easier processing	
	var iPosVar = sTempQS.indexOf(sQSVar.toLowerCase() + "=");	// Get location of required var (add the "=" to the end)
	var iPosNxt = -1;											// Position of next qs pair value
	var sValueP = "";											// Temp var to hold value pair
	var sRetVal = "";											// Set up return value
	
	if (iPosVar != -1) {
		// Var exists
		iPosNxt = sTempQS.indexOf("&", iPosVar)
		
		// Get position of end of the qs value pair
		if (iPosNxt == -1) { iPosNxt = sTempQS.length; }
		
		// Get the value of the requested qs var
		sRetVal = sQueryString.substring(iPosVar + (sQSVar.length + 1), iPosNxt);
	}
	else {
		// No var or no value assigned
		sRetVal = "";
	}
	
	return sRetVal;		// Return value of string
}

// Primary Processing
sQueryString = sGetQS();		// Load the querystring value into the global var.
