/*****************************************************************/
/**** trace window *****/
/*****************************************************************/
var tracecount = 0;
var opener = new Object();
function trace(msg, options){
	if(! options)
	options = new Object();
	tracecount++;
	if(options){
		width = options.width ? options.width:300;
		height = options.height ? options.height:300;
		scrollbars = options.scrollbars ? options.scrollbars:1;
		resizable = options.resizable ? options.resizable:1;
		windowname = options.windowname ? options.windowname:'tracewindow';
		left = options.left ? options.left: (screen.width  - width);
 		top = options.top ? options.top: 0;
 		autoFocus = options.focus ? true : false;

	}
	if(! opener.document){
		
		var title = window.document.title != "" ? window.document.title : window.location;
		title += " "+(new Date()).toGMTString();
		opener = window.open('', windowname,'toolbar=0,scrollbars='+scrollbars+',location=0,statusbar=0,menubar=0,resizable='+resizable+',width='+width+',height='+height+',left='+left+',top='+top);
		
		opener.document.write('<body style="background:#ffffcc"><div id="trace" style="font:10px arial;">'+title+'</div></body>');
		opener.document.close();
		opener.onunload = function(){
			opener = new Object();
		}
	}
	opener.document.getElementById('trace').innerHTML = opener.document.getElementById('trace').innerHTML +"\n<br/>"+tracecount+":"+msg;
	if (window.focus && autoFocus) {
		// firefox enbable Raise / Lower windows, Perferences -> Advanced
		opener.focus()
	}
}
