
/*
 * Calls a function after a specified interval
 * better than setTimeout because it does not leak memory
 */
$.fn.delayedCall = function (time, callback) {
    return this.animate({delay: 1}, time, callback);
};

/*
 * Remove all future delayed calls from an object
 */
$.fn.killDelayCalls = function () {
	return this.stop(true, false);
};

/*
 * Add jQuery support for HTML5 video's play() method
 */
$.fn.play = function (fn) {
	return (fn) ? this.bind("play", fn) : this.trigger("play");
};

/*
 * Add jQuery support for HTML5 video's pause() method
 */
$.fn.pause = function (fn) {
	return (fn) ? this.bind("pause", fn) : this.trigger("pause");
};

/*
 * Add jQuery support for HTML5 video's ended event
 */
$.fn.ended = function (fn) {
	return (fn) ? this.bind("ended", fn) : this.trigger("ended");
};

String.prototype.trim = function () {
    return this.replace(/^\s+|\s+$/g, "");
}
String.prototype.ltrim = function () {
    return this.replace(/^\s+/, "");
}
String.prototype.rtrim = function () {
    return this.replace(/\s+$/, "");
}
