var BUGS=true;
var debug=new Array();
function deba(el) {

	var out = "";	
	out = "\n============================================================\n";
	if (deba.caller == null) {
		out += "This function was called from the top!\n"
					+"------------------------------------------------------------\n";
	} else {
		var callerName=deba.caller.toString().substring(0,deba.caller.toString().indexOf('{'));
		out += "This function's caller was: " + callerName +"\n"
					+"------------------------------------------------------------\n";
	}
	
	out += "The debug element or content is:\n" + el + "\n";
	
	if(typeof el=="object"){
		out += "------------------------------------------------------------\n";
		for(prop in el) {
			out += prop+' = '+el[prop]+"\n";
		}
	}
	
	debug[debug.length]=out;
	if(debug.length>100){
		debug.shift();
	}
	
	if(BUGS){
		win = window.open('', 'Debug','width=400,height=300,left=50,top=50,status,menubar,scrollbars,resizable');
		win.document.open();
		win.document.write('<pre>' + debug.join('\n') + '</pre>');
		win.document.close()
		win.focus();
	}
}
