/*
	Title:	Javascript Debug Output Screen
	Author:	Andrew M King
	Email:	andrewtek@excite.com
	Date:	08/23/01
	
	Usage:	Use at own risk. Free to use, Free to copy. If you use this in 
		your applications, please give credit to me somewhere in the 
		comments of your code.
	
*/
var debug_window = null;
var debug_form = null;
var debug_output = null;

var debug_allowDebug = false;

function debug_insertDebugScreen_a(){
	debug_insertDebugScreen_b(45, 10);
}

function debug_insertDebugScreen_b(cols, rows){
	debug_window = window.open("", "debug", "width="+ (cols*10) + ",height=" + (rows*25));
	debug_window.document.writeln("<p align='center'><form name='debugger'><table><tr><td><font face='verdana' size='2'><b>JAVASCRIPT DEBUG OUTPUT</b></font></td></tr><tr><td><textarea cols='" + cols + "' rows='" + rows + "' name='output'></textarea></td></tr></table></form></p>");
	debug_window.document.close();
}

function debug_println(printVal){
	debug_print(printVal + "\n");
}

function debug_print(printVal){
	if(debug_output != null){
		debug_output.value = debug_output.value + "" + printVal;
	}else{
		if(debug_window != null){
			if((debug_form = debug_window.document.forms["debugger"]) != null){
				if((debug_output = debug_form.elements["output"]) != null){
					debug_output.value = debug_output.value + "" + printVal;
				}
			}
		}else{
			if(debug_allowDebug){
				if(confirm("There is a debugger message. Would you like to open the javascript debug screen?")){
					debug_insertDebugScreen_a();
					debug_print(printVal);
					debug_window.focus();
				}else if(confirm("Would you like to disable the JavaScript debugger screen?")){
					debug_allowDebug = false;
				}
			}
		}
	}
}
