// start info
if(typeof jsReport != 'undefined'){
	jsVersion = new Array(
	/*Name			=*/ 'Debug Window',
	/*Version 		=*/ '1.3',
	/*Date 			=*/ 20040407,
	/*Author		=*/ 'Maurice van Creij',
	/*ProjectCode	=*/ 'lib_debug',
	/*Summary		=*/ 'Open a debug-window for writing non-intrusive messages to, while testing a web-site.',
	/*Dependencies	=*/ new Array('lib_debug.js'),
	/*Browsers		=*/ new Array('NS','MO','IE','OP'),
	/*Changes		=*/ new Array(
						'1.3: Debug windows opens on demand.',
						'1.2: now supports multiple variable tracking, also added tentative support for plotting arrays',
						'1.1: Added the "debugClear()" command for debugging "events" more efficiently',
					  	'1.0: A modular version was compiled from code-scraps'
					  	),
	/*Usage			=*/ new Array(
						'<script language="JavaScript" src="/~wmittens/includes/debug.js" type="text/javascript"></script>',
						'<script language="JavaScript" type="text/javascript">',
						'<!'+'--',
						'debug(\'your string or variable here\')',
						'//'+'-->',
						'</script>'
					  	)
	)
}else{
// end info


	debugLog = new Array();
	dbg = null;
	tellerX = 0;
	interval = 0;
	maxLength = 256;
	
	function debug(){
		// open the debug window if it isn't open yet
		if(dbg==null) dbg = window.open('','debugwindow','width=256,height=580,resizable=yes,scrollbars=yes')
		// add line count
		tellerX = tellerX + 1;
		// for all debugable arguments
		intDebugLine = debugLog.length;
		debugLog[intDebugLine] = '';
		for(var intA=0; intA<arguments.length; intA++){
			// recursive array splitter
			if(typeof(arguments[intA])=='object'){
				strArr2Str = '------Array-------<br />';
				plotArray(arguments[intA],0);
				strArr2Str += '---end-Array------<br />';
				arguments[intA] = strArr2Str;
			}
			// add a debug line
			debugLog[intDebugLine] += arguments[intA] + '&nbsp;';
		}
		// blit all debug lines
		if(tellerX>interval){
			dbg.document.open();
			dbg.document.write('<html><head><title>debug info</title></head><body>');
			tellerY = debugLog.length - 1;
			if(debugLog.length>maxLength){maxLines=maxLength}else{maxLines=debugLog.length}
			for(tellerZ=0 ; tellerZ < maxLines ; tellerZ++){
				dbg.document.writeln(debugLog[tellerY]+"<br />");
				tellerY = tellerY-1;
			}
			dbg.document.write('</body></html>');
			dbg.document.close();
			tellerX = 0;
		}
	}
	
	var strArr2Str= '';
	function plotArray(arrIn,intRecursion){
		// indentation
		var strSpacing = ''
		for(var intC=0; intC<intRecursion; intC++){
			strSpacing += '&nbsp;&nbsp;&nbsp;';
		}
		
		// plotting individual elements
		for(var intB=0; intB<arrIn.length; intB++){
			if(typeof(arrIn[intB])=='object'){
				plotArray(arrIn[intB],intRecursion+1)
			}else{
				strArr2Str += strSpacing + arrIn[intB] + '<br />'
			}
			
			// end of line
			if(intB==arrIn.length-1 && intRecursion==1){
				strArr2Str += '------------------<br />';
			}
		}
	}
	
	function debugClear(){
		debugLog.length = 0;
	}
	
	function debugHtml(string){
		string = '<xmp>' + string + '</xmp>'
		debug(string)
	}
	
}