var dwin = null; 
function debug(msg) { 
	if ((dwin == null) || (dwin.closed)) { 
		dwin = window.open('','debugconsole','scrollbars=yes,resizable=yes,height=150,width=300'); 
		dwin.document.open('text/html', 'replace'); 
		dwin.document.writeln('<html><head><title>Javascript debug console</title><style type="text/css">');
		dwin.document.writeln('body {font-size: 8pt; font-family: "Tahoma"; background-color: white; margin: 0px; overflow: hidden;}');
		dwin.document.writeln('input {font-size: 8pt; font-family: "Tahoma";}');
		dwin.document.writeln('div#actions {background-color: #e5e5e5;border-bottom: 1px solid grey; padding: 5px;}');	
		dwin.document.writeln('div#debug {padding: 5px; width:100%; overflow:auto; height:120px; }');		
		dwin.document.writeln('</style></head><body><div id="actions"><input type="button" value="Clear" onClick="document.getElementById(\'debug\').innerHTML=\'\'"/> <input type="button" value="Close" onClick="self.close()"/></div><div id="debug">');
	}
	dwin.document.writeln(msg+'<br/>'); 
	var objDiv = dwin.document.getElementById('debug');
	objDiv.scrollTop = 10000;
	dwin.focus();
}
