/*
String extensions

fritz, 2005.07.04

*/


/*
 * trim
 *	removes all chars of set from beginning and end of string
 *
 * params
 *	string chars	[the char sets to be removed - default \s]
 *
 * return string	the trimmed string
 */
String.prototype.trim	= function( chars )
	{
		chars	= chars?	chars:	'';
		var re1	= new RegExp( "^[\\s"+chars+"]+" );
		var re2	= new RegExp( "[\\s"+chars+"]+$" );
		var str	= this.replace( re1, '' );
		return str.replace( re2, '' );
	}

/*
 * lastChar
 *	returns the last character of a string
 *
 * params
 *
 * return string	the trimmed string
 */
String.prototype.lastChar	= function()
	{
		return this.charAt( this.length - 1);
	}
	
/*
 * locationDir
 *	gets the name of the current directory
 *
 * params
 *
 * return string	the anme of the directory
 */
function locationDir()
{
	var url	= new String( document.location.pathname ).trim( '/' );
	var	dirs	= url.split( '/' );
	url = dirs.pop();
	if( url.match( /\./ ) )	url	= dirs.pop();
	return url;
}
	
/*
 * locationPage
 *	gets the name of the current page
 *
 * params
 *
 * return string	the name of the page
 */
function locationPage()
{
	var url	= new String( document.location.pathname );
	if( url.lastChar() == '/'  )	return "";
	return url.split( '/' ).pop();
}