// String functions
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); };

// Redirect
function redirect(url){
	window.location.href = url;
}

// String.prototype.get - Extracts a variable from a seralized cookie string
String.prototype.get = function(var_name){
	if(this.length > 0){
		var start = this.indexOf(var_name + "=");
		if(start != -1){
			start = start + var_name.length + 1;
			end = this.indexOf(";", start);
			if (end == -1) end = this.length;
			return unescape(this.substring(start, end));
		}
	}
	return "";
}

String.prototype.ucfirst = function () {

    // Split the string into words if string contains multiple words.
    var x = this.split(/\s+/g);

    for (var i = 0; i < x.length; i++) {

        // Splits the word into two parts. One part being the first letter,
        // second being the rest of the word.
        var parts = x[i].match(/(\w)(\w*)/);

        // Put it back together but uppercase the first letter and
        // lowercase the rest of the word.
        x[i] = parts[1].toUpperCase() + parts[2].toLowerCase();
    }

    // Rejoin the string and return.
    return x.join(' ');
};


