/**
 * fuMan - developped by fugu GmbH, Bern, Switzerland, www.fugu.ch
 * Please see licence.txt in the root directory for further information.
 *
 * $Id: stringextension.js,v 1.3 2009-03-04 15:07:30 higi Exp $
 * $Date: 2009-03-04 15:07:30 $
 * $Revision: 1.3 $
 */

// converts the first letter of each word to uppercase
String.prototype.ucFirst = function () {
	if (arguments[0] == true) {
		var words = this.split (' ');
		for (var w in words) {
			words[w] = words[w].ucFirst ();
		}
		return words.join (' ');
	}
	return this.charAt (0).toUpperCase () + this.substring (1, this.length);
}

String.prototype.trim = function () {
	var str = this;
	while (str && str.length > 0 && str.substring (0, 1) == ' ') {
		str = str.substring (1, str.length);
	}
	while (str && str.length > 0 && str.substring (str.length - 1, str.length) == ' ') {
		str = str.substring (0, str.length - 1);
	}
	return str;
}

/**
 * can be used to strip the last two characters off of given value (iff they are 'PX')
 * usually used in retrieval of a div's dimensions
 */
function stripPX (val) {
	if (val && val.length >= 2 && val.substr (val.length - 2).toUpperCase () == 'PX') {
		val = 1 * (val.substr (0, val.length - 2));
	}
	return val;
}

