
function NaosDebug() {}

NaosDebug.window = null;

NaosDebug.enable = function() {
	NaosDebug.window = window.open(naosConfig.application.base_url+"/naos/naos/debug_dummy.html", "NaosDebugWindow", "dependent=yes,height=300,width=500,resizable=yes,menubar=no,location=no,scrollbars=yes,status=no,toolbar=no,top=0,left=0");
	NaosDebug.window.blur();
	
	NaosDebug.window.document.open();
	NaosDebug.window.document.write("<html><head><title>Naos Debug Window - "+naosConfig.application.title+"</title></head><body>");
	NaosDebug.window.document.write("<div id=\"debugOutput\"></div>");
	NaosDebug.window.document.write("</body></html>");
	NaosDebug.window.document.close();
	
	NaosDebug.debug("[NaosDebug]: Debug window initialized.");
}

NaosDebug.debug = function(msg) {
	if(NaosDebug.window != null && !NaosDebug.window.closed && NaosDebug.window.document != null)
	{
		var debugOutputObject = NaosDebug.window.document.getElementById("debugOutput");
		debugOutputObject.innerHTML = debugOutputObject.innerHTML + "<div style=\"margin: 3px; padding: 1px; border: 1px solid black; font-size: 8pt;\"><strong>"+(new Date()).toLocaleString()+"</strong><br/>"+msg.encodeXMLViewable()+"</div>";
	}
}
