/*
	This file contains a collection of reusable third party dependencies which have been grouped here
	either because their where too small to put in individual libraries or which have
	been tweeked/debugged for purposes specific to the Intralinks website.

*/


/*
	Function jQuery.safe

	Executes a function in try/catch statement and log any exceptions in the browser console in a comprehensive manner. This prevents any single piece of code to block or break the rest of the sites scripts. This method also times the execution of each block for performance monitoring. Use a console plugin such as Firebug to see the logs. This utility can be left in place when deploying in production as long as it is accompanied by a mock console, otherwise it would break the exectutions of the site on clients browsers.

	Author:
		Mathieu Sylvain 2009 (mathieu@ti-coco.com)

	Parameters:

		desc - Description of the task accomplished
		this - The object used as the local "this" object
		fn - The function to call
*/
;(function($) {
	$.safe = function(desc, $this, fn) {
		console.time(desc);
		var ret; // Return value or exception
		try {
			ret = fn.call($this);
		} catch(e) {
			ret = e;
			console.error("Failed while: " + desc);
			console.dir({
				"exception":e,
				"function":fn,
				"this": $this
			});
		}
		console.timeEnd(desc);
		return ret;
	};
})(jQuery);
