// global debug switch ... add DEBUG = true; somewhere after jquery.debug.js is loaded to turn debugging on
var DEBUG = false;
// shamelessly ripped off from http://getfirebug.com/
// if (!("console" in window) || !("firebug" in console)){
	//var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
	// create the logging div
	// jQuery(document).ready(
	// 		function(){
	// 			$(document.body).append('
');
	// 			$("#DEBUG").css({
	// 				'position':'fixed',
	// 				'bottom':'0.5em',
	// 				'right':'0.5em',
	// 				'padding':'0',
	// 				'width':'33%',
	// 				'height':'auto',
	// 				'background-color':"transparent",
	// 				'opacity': '0.9',
	// 				'overflow':'hidden',
	// 				'border':'2px #000 solid'
	// 			}).hide();
	// 			
	// 			$(".output", "#DEBUG").css({'overflow':'auto'}).height($(window).height()*.5+'px').hide();
	// 			
	// 			$('span', '#DEBUG .trigger').css({'fontSize':'0.567em','color':'#fff','textAlign':'center'});
	// 			
	// 			$('.trigger', '#DEBUG').css({'backgroundColor':'#000', 'cursor':'pointer'}).mouseup(function(){
	// 	      $('.output', '#DEBUG').slideToggle();
	// 	    });
	// 		}
	// 	);
	// attach a function to each of the firebug methods
// 	window.console = {};
// 	for (var i = 0; i < names.length; ++i){
// 		window.console[names[i]] = function(msg){ 
// 			$('#DEBUG ol').append( '' + msg + '' );
// 			
// 			$('#DEBUG').css({
// 				'display':'block'
// 			});
// 			
// 			$('#DEBUG li').css({
// 				"background-color":"#fff",
// 				"padding":"5px",
// 				"height":"auto",
// 				"color":"#000",
// 				"font-size":"11px",
// 				"font-family":"Monaco",
// 				"line-height":"1.2",
// 				"border-bottom": "1px solid #000"
// 				});
// 			
// /*			$('#DEBUG ol').css({
// 				"bottom": "0"
// 				});
// */
// 			$('#DEBUG span.object').css({
// 				"color":"blue"
// 				});
// 
// 			$('#DEBUG span.string').css({
// 				"color":"red"
// 				});
// 			
// 			var li = $('#DEBUG li:last');
// 			$('#DEBUG').animate({scrollTop: li.offset().top }, 10);
// 
// 		}
// 	}
// }
/*
 * debug
 * Simply loops thru each jquery item and logs it
 */
jQuery.fn.debug = function(msg) {
	return this.each(function(){
		$.log(msg, this);
	});
};
/*
 * log
 * Send it anything, and it will add a line to the logging console.
 * If firebug is installed, it simple send the item to firebug.
 * If not, it creates a string representation of the html element (if message is an object), or just uses the supplied value (if not an object).
 */
jQuery.log = function(msg, obj){
	// only if debugging is on
	if( window.DEBUG ){
		
		var message = msg != null ? msg : '';
		var object = obj;
		message += object != null && message != '' ? " : " : "";
	
		try{ 
			if( typeof( object) == 'object' ){
				console.log("%s%o", message, object);
			}else{
				console.log("%s", message);
			}
		}catch(e){
			// alert(message)
		}
		
	}else{
		// if debbugin is on hide DEBUG div if existing
		// $("#DEBUG").hide();
	}
};