/**
 * Small plug-in for jQuery adding some more string methods.
 */
jQuery.extend({
	/**
	 * Substitutes keywords in a string with values from an object. The keywords
	 * are properties of the object, wrapped in curly braces inside the string (ie. {prop}).
	 * @param String str The string to perform substitions on.
	 * @param Object obj The object with values to inject into the string.
	 * @return String String with all properties existing in the object replaced with the respective values.
	 */
	substitute: function (str, obj) {
		for (var key in obj) {
			str = str.replace(new RegExp('{' + key + '}', 'g'), obj[key]);
		}
		return str;
	},
	camelize: function (str) {
		var camelized = '';

		if (str.indexOf(' ') != -1) {
			var words = str.split(' ');
		}
		else if (str.indexOf('_') != -1) {
			var words = str.split('_');
		}
		else {
			var words = [str];
		}

		for (var i = 0; i < words.length; i++) {
			camelized += words[i].charAt(0).toUpperCase() + words[i].substr(1);
		}

		return camelized;
	}
});
