var gc_iModeFlagsOnly	= 1;
var gc_iModeValues	= 2;


function PropogateQueryStrings_Wrapper()
{
	try
	{
		PropogateQueryStrings()
	}
	catch (e)
	{
		emitEx(e, "propogating the querystrings");
	}
}


//	Propogate appropriate flags across the querystring.
//
function PropogateQueryStrings()
{
	if  ("" == GetQueryString())
		return;

	var arrLinks		= document.links;
	var strQueryString	= GetQueryString();

	//	Do this for all links.
	//
	for (var i=0; i<arrLinks.length; ++i)
	{
		//	Propogate the current query string to all other links.
		//
		if (isLocal(arrLinks[i].href))
			arrLinks[i].href	= PropogateQueryString( arrLinks[i].href, strQueryString );
	}
}


//	Takes a given URL, and propogates arguments
//	from a different query string to this url.
//
function PropogateQueryString( strUrl, strQueryString )
{
	//	Parse the current querystring into args.
	//
	var arrArgs	= GetAllQueryStringArgsFromQueryString( strQueryString );


	//	Propogate all arguments from the current query string
	//	into the link's querystring.
	//
	for (var i=0; i<arrArgs.length; ++i)
	{
		//	Only propogate arguments that are NOT already
		//	in the link's querystring.
		//
		if (!QueryStringArgExists(arrArgs[i], strUrl ))
		{
			//	Get the value to propogate
			//
			var strValue	= GetQueryStringArg( arrArgs[i], null, "?" + strQueryString );


			//	Only propogate non-valued strings.
			//
			if (null == strValue)
				strUrl	= AppendArgToUrl( strUrl, arrArgs[i], strValue );
		}
	}
	return 	strUrl;
}
