var gDebug = false;

function RunDebugger( aCalledFrom ) {
	gDebug = true;
	
	var oldBodyOnload = window.onload;

	window.onload = function() {
		oldBodyOnload();
		
		if(!getElement(DEBUG_WINDOW_ELEMENT_ID)) {
			debugWindow = document.createElement("textarea");
			
			debugWindow.id = DEBUG_WINDOW_ELEMENT_ID;
			
			debugWindow.style["width"] = "100%";
			debugWindow.style["height"] = "500px";
			
			debugWindow.innerHTML = "---- I AM THE JAVASCRIPT DEBUG WINDOW ----\n\nI was called via RunDebugger() in " + aCalledFrom + ". Comment me out to get rid of me!\n\nTo use me simply...\n\n1) Call RunDebugger('the_file_you_called_me_from'); in your JavaScript anywhere after the <body> tag.\n\n2) Add if(gDebug){ getElement(DEBUG_WINDOW_ELEMENT_ID).innerHTML += 'What you want to display!'; } Anywhere you want to output to the debug window.\n\nSimple, isn't it?\n\n";
			
			document.body.appendChild(debugWindow);
		}
		else {
			getElement(DEBUG_WINDOW_ELEMENT_ID).innerHTML += "\n\nPlease don't call me more then once. I only need to be called once. It appears " + aCalledFrom + " is also trying to call me.\n\n";
		}
	}
}