var debugLogReady = false;
var debugLogCache = "";

$(document).ready(function(){
	debugLog("debug.document.ready()");
	debugLogReady = true;
});

function debugLog(data) {
	if (debug) {
		if ($('#debug').length==0) {
			debugLogCache += data+'\n';
			if (debugLogReady) {
				var html = "<style>";
				html += "#debug {background-color: #FFFFFF;border-bottom: 2px solid #000000;border-right: 2px solid #000000;font-family: 'Courier New',Courier,monospace;font-size: 9px;height: 100px;left: 0;opacity: 0.3;overflow: auto;padding: 3px;position: fixed;top: 0;white-space: pre;width: 100px;z-index: 9999;}";
				html += "#debug:hover {border-bottom: medium none;bottom: 0;height: auto;opacity: 1;width: 200px;}";
				html += "</style>";
				html += "<div id='debug'>cache{\n"+debugLogCache+"}\n</div>";
				$('body').append(html);
				debugLogCache = "";
			}
		} else {
			$('#debug').append(data+'\n');
		}
	}
}
