// Parses semicolon-separated 'name=value' argument pairs from the 
// query string of the URL belonging to the HTML page. Expects the 
// Page to be accessed by changing the Page's "Location" Object's 
// "href" property.
// Stores the name=value pairs in properties of an Object and returns 
// that Object. If no 'name=value' arguments supplied after '?',
// returns 'null'.
//
// e.g. a page submits the string:
// parent.PageContent.location.href="Test.html?FOO=42;BAR=splat;"
//
//	var args = _getPageArgs();
//	args[ "FOO" ] will = "42"
//	args[ "BAR" ] will = "splat"
function getPageArgs() {

	// If arument passed, use that, otherwise use window location Object.
	var query = location.search.substring( 1 );			// Get query string less '?'.	

	var args = new Object();
	var pairs = query.split( ";" );						// Break at semi-colon.
	var instance = new Array();
	args.totElements = 0;

	for ( var i = 0, j = 0; i < pairs.length; ++i ) {
		var pos = pairs[ i ].indexOf( '=' );			// Look for "name=value".
		if (pos == -1) continue;						// If not found, skip.
		var argname = pairs[ i ].substring( 0, pos );	// Extract the name.
		var value = pairs[ i ].substring( pos + 1 );	// Extract the value.
		args[ argname ] = unescape( value );			// Store as a property.
		args[ j ] = [ unescape( argname ), unescape( value ) ];
		++args.totElements;

		if (instance[ argname ] >= 0) {
			++instance[ argname ];
		} else {
			instance[ argname ] = 0;
		}
		args[ j++ ].instance = instance[ argname ];
	}

	return args;						
}

