sapiDebug={ 
	setup:function(){
		var debugObj=null;
		var debugWin=null;
		var colorCnt=0;
		dputs=function(str){
			if(!debugObj) createDebugDiv();
			var st="";
			if(colorCnt){
				st="#eeeeee;"
				colorCnt=0;	
			} else {
				st="#ffffff;"
				colorCnt=1;
			}
			debugObj.innerHTML="<xmp style='display:block;width:100%;font-family:Arial;font-size:11px;color:black;margin:0px;float:left;clear:both;padding:4px;background-color:"+st+"'>"+str+"</xmp>"+debugObj.innerHTML;
		}
		dputo=function(obj){
			if(!debugObj) createDebugDiv();
			var st="";
			if(colorCnt){
				st="#eeeeee;"
				colorCnt=0;	
			} else {
				st="#ffffff;"
				colorCnt=1;
			}
			str="";
			for(var o in obj) str+=o+"="+obj[o]+"\n";
			debugObj.innerHTML="<xmp style='display:block;width:100%;font-family:Arial;font-size:11px;color:black;margin:0px;float:left;clear:both;padding:4px;background-color:"+st+"'>"+str+"</xmp>"+debugObj.innerHTML;
		}
		createDebugDiv=function(){
			var d=document.createElement("DIV");
			d.style.position="absolute";
			d.style.top=0;
			d.style.left=0;
			if(window.sapiCookies){
				d.style.top=sapiCookies.get("debugt",0);
				d.style.left=sapiCookies.get("debugl",0);
			}
			d.style.width="352px";
			d.style.height="400px";
			d.style.zIndex=20000;
			d.style.padding=0;
			d.style.overflow="hidden";
			d.style.backgroundColor="#ffffff";
			d.style.color="#000000";
			d.style.display="block";
			debugWin=d;
			var buf='<table cellspacing=0 cellpadding=0 width=350 height=100%>';
			buf+='<tr height=10><Td style="background-color:#222288;color:white;font-family:Arial;font-size:11px;padding:4px" onmousedown="onDragStart(event)">';
			buf+='<span onmouseup="sapiDebug.onClear()" style="float:left;clear:none;cursor:arrow;">Clear</span>';
			buf+='<span onmouseup="sapiDebug.onWinClose(this)" style="float:right;cursor:arrow;">Close</span>';
			buf+='</td></tr>';
			buf+='<tr><Td><div id="debugOutputDiv" style="padding:0px;width:350px;height:385px;overflow:auto;border:1px solid black;"></div></td></tr></table>';
			d.innerHTML=buf;
			document.body.appendChild(d);
			var o=document.getElementById("debugOutputDiv");
			debugObj=o;
		}
		onClear=function(){
			debugObj.innerHTML="";
		}
		onWinClose=function(o){
			var d=debugWin;
			var s=d.style;
			if(o.innerHTML!="Open"){
				s.height=22;
				o.innerHTML="Open";
			} else {
				o.innerHTML="Close";
				s.height=400;
			}
		}
		onDragStart=function(e){
			if(!e) e=window.event;
			document.body.onmousemove=onMouseMove;
			document.body.onmouseup=onMouseUp;
			dx=parseInt(debugWin.style.left)-e.clientX;
			dy=parseInt(debugWin.style.top)-e.clientY;
			e.cancelBubble=true;
			e.returnValue=false;
		}
		onMouseMove=function(e){
			if(!e) e=window.event;
			e.cancelBubble=true;
			e.returnValue=false;
			debugWin.style.left=e.clientX+dx;	
			debugWin.style.top=e.clientY+dy;	
		}
		onMouseUp=function(){
			if(window.sapiCookies){
				sapiCookies.set("debugt",debugWin.offsetTop);
				sapiCookies.set("debugl",debugWin.offsetLeft);
			}

			document.body.onmousemove="";
			document.body.onmouseup="";
		}
		window.dputs=dputs;
		sapiDebug.onClear=onClear;
		sapiDebug.onWinClose=onWinClose;
	}
};
sapiDebug.setup();