/**
 * Support for manipulating HTTP parameters (reading/writing)
 *
 * $Revision: 1.7 $
 *
 */

/*
 * $Log$
 */
 
 /**
 * parse the value of the specified param out of my HTTP params 
 * (it it's present)
 */ 
function getHttpParam( param )
{
  	var regex = new RegExp( "[\\?&]"+param+"=([^&#]*)" );
  	var results = regex.exec( window.location.href );
  	if( results == null )
  	  	return null;
  	else
    	return results[1];
} 

/**
 * append this parameter with this value to thie url
 */
function writeHttpParam( baseurl, param, value)
{
	var sep = "?";
	
	if ( indexOf( baseurl, sep)> -1)
	{
		sep = "&";
	}
	
	return baseurl + sep + param + "=" + value;
}

/**
 * copy the named parameter from among my HTTP parameters (if present)
 * and append it to this base url
 */
function copyParam( baseurl, param)
{
	var value = getHttpParam( param);
	
	if ( value != null)
		baseurl = writeHttpParam( baseurl, param, value);
		
	return baseurl;
}
 
