/**
  *  @name        jQuery Logging plugin
  *  @author      Dominic Mitchell | http://happygiraffe.net/
  *  @modified    Joan Piedra | http://www.justaquit.com/
  *  @link        http://happygiraffe.net/blog/archives/2007/09/26/jquery-logging
  */

(function($){ // block scope

	// code yanked from the Yahoo media player. Thanks, Yahoo.
		if (!('console' in window) || !('firebug' in console)) {
			window.console = new Object();
			var names = ['log', 'debug', 'info', 'warn', 'error', 'assert', 'dir', 'dirxml', 'group', 'groupEnd', 'time', 'timeEnd', 'count', 'trace', 'profile', 'profileEnd'];
			for (var i = 0; i <names.length; ++i) window.console[names[i]] = function() {};
		}
	
	var hasConsole = (typeof window.console !== 'undefined' && typeof console.firebug !== 'undefined');

	$.fn.log = function(msg){
		if (hasConsole){
			msg = msg || '';
			if(msg !== '') msg += ': ';
			console.log("%s%o", msg, this);
		}
		return this;
	};

	$.log = function(obj,msg){
		if (hasConsole){
			msg = msg || '';
			if(msg !== '') msg += ': ';
			console.log("%s%o", msg, obj);
		}
		return;
	};

})(jQuery);