/* **********************************************************************
 * 
 * File:	Common.js
 * Date:	August 9, 2001
 * Author:	Rodney M. Chun
 * Desc:	Contains common client-side Javascript code used by both
 *		user and management pages.
 *
 *		The following functions are defined here:
 *		1)  trim
 * 		2)  trimLead
 *		3)  trimLag
 *		4)  makeURLString -- if server address changes, must change this code.
 *
 ***********************************************************************/



/* Function Name: 	trim
 * -----------------------------
 * Function that trims off both lagging and leading blank spaces.  
 * Calls trimLead and trimLag.
 */
function trim(str)
{
	str = trimLag(trimLead(str));
	return str;
}

/* Function Name: 	trimLead
 * -----------------------------
 * Function that recursively trims off leading blank spaces.
 */
function trimLead(str)
{
	if (str.charAt(0) != " ") return str;					// no leading blanks so return.
	else return trimLead(str.substring(1,str.length));		// call trim again with truncated str.
}

/* Function Name: 	trimLag
 * -----------------------------
 * Function that recursively trims off laggin blank spaces.
 */
function trimLag(str)
{
	if (str.charAt(str.length-1) != " ") return str;
	else return trimLag(str.substring(0,str.length-1));
}


/* Function Name:	makeURLString
 * -----------------------------
 * Function that constructs the proper URL string for the webserver.
 * If any server environments change (e.g. an administrator changes an
 * address, etc.) the code here must be updated to be consistent with 
 * those changes.  Otherwise all the links constructed will break.
 */
function makeURLString(fileName)
{
	// Change this string to be consistent with the web-server's address!!!!
	var prefix = "http\://econseminars.stanford.edu/papers/allpapers/";

	return (prefix + fileName);
}
