//**************************************************************************************************
//
// Name:		getArgs
//
// Description:
//				Get the arguements from the query string which is at the end of the invoking script
//				line.
//
// Return:
//				An object containing the keys and their associate values.
//
// Parameters:
//          	none
//
// Inputs:
//				The document object is used to obtain the script line.
//
//**************************************************************************************************

function getArgs()
{
	// Get the script line that invokde us.
	
	var scripts = document.getElementsByTagName('script');
	var myScript = scripts[ scripts.length - 1 ];

	// Now clear everything up to an include the question mark leaving just
	// the query string which will provide us with the relevant parameters.
	
	var queryString = myScript.src.replace(/^[^\?]+\??/,'');
	
	var params = new Object ();
	
	// If no query string return empty object.
	
	if ( queryString.length > 0 )
	{
		// Start by splitting the arguements into pairs (key and value).
		
		var pairs = queryString.split(/[;&]/);
		for ( var i = 0; i < pairs.length; i++ )
		{
			// Now seperate the key and value down into seperate items.
			
			var keyVal = pairs[i].split('=');
			if ( keyVal || (keyVal.length == 2))
			{
				// We have a valid pair decode any escape characters etc and
				// store them in an array by key.
				
				var key = unescape( keyVal[0] );
				var val = unescape( keyVal[1] );
				val = val.replace(/\+/g, ' ');
				params[key] = val;
			}
		}
   }
   return params;
}