;(function($){

/* debug pane w/ template variables, environment config, etc. */
var debug = {
	// store the query for the pane
	pane: null,
	// initialize the dimensions of the pane to the size of the window
	// and bind the event handlers for accessing it.
	init: function() {
		debug.pane = $('#debug');

		debug.pane.height($(window).height()-40);
		$('#debug_data').height( debug.pane.height() - 70 );

		$(document).keypress(function(e){

			// 8706 is alt-d, 2 is ctrl-b (for stupid windows machines)
			// todo: make sure it works on windows
			if (e.which==8706 || e.which==2) {
				debug.pane.toggle();
			}
		});

		debug.pane.find('a.hide').bind('click', function(e){
			e.preventDefault();
			debug.pane.toggle();
		});
	}
}
$(document).ready(function(){ debug.init() });

/*
granular debugging
usage:
	<a href="#" title="debug" class="debug-toggle">debug</a>
	<div class="debug-data hide">data</div>
*/
$('.debug-toggle').live('click', function(e) {
    var box = dialog.create(null, {
        title: 'debug',
        body: '<pre>' + $(this).siblings('.debug-data').html() + '</pre>'
    });
    box.children('.border').css('max-width', '600px');

	// todo: which of these do you really need.. certainly not all of them.
    e.preventDefault();
    e.stopImmediatePropagation();
    e.stopPropagation();
    return false;
});

})(jQuery);

