sapiDebug={ 
	debugTxt:"",
	inited:false,
	colorCnt:true,
	tbHeight:30,
	height:300,
	width:400,
	dputs:function(str){
		var st="#eeeeee;";
		if(sapiDebug.colorCnt) st="#ffffff;"
		sapiDebug.colorCnt=!sapiDebug.colorCnt;
		sapiDebug.debugTxt="<div style='display:block;margin:0px;clear:both;background-color:"+st+"'><xmp style='color:black;margin:5px;font-family:Arial;font-size:11px;'>"+str+"</xmp></div>"+sapiDebug.debugTxt;
		if(!sapiDebug.inited){
			if(!document.body){
				regAction(sapiDebug.create);
			} else {
				sapiDebug.create();
			};
		} else {
			sapiDebug.redraw();
		}
	},
	create:function(){
		var d=document.createElement("DIV");
		d.style.position="absolute";
		d.style.border="1px solid black";
		d.style.bottom=0;
		d.style.right=0;
		d.style.width=sapiDebug.width+"px";
		d.style.height=sapiDebug.height+"px";
		d.style.zIndex=20000;
		d.style.padding=0;
		d.style.overflow="hidden";
		d.style.backgroundColor="#ffffff";
		d.style.color="#000000";
		d.style.display="block";

		if(window.sapiCookies){
			d.style.top=sapiCookies.get("debugt",0);
			d.style.left=sapiCookies.get("debugl",0);
		};

		sapiDebug.debugWin=d;

		var d=document.createElement("DIV");
		d.style.position="relative";
		d.style.backgroundColor="#222288";
		d.style.display="block";
		d.style.height=sapiDebug.tbHeight+"px";
		d.style.lineHeight=sapiDebug.tbHeight+"px";
		sapiDebug.debugWin.appendChild(d);

		var b=sapiDebug.mkBut();
		b.innerHTML="CLEAR";
		sapiEvents.attachEvent(b,"click",sapiDebug.onClear);
		d.appendChild(b);

		var b=sapiDebug.mkBut();
		b.innerHTML="CLOSE";
		sapiEvents.attachEvent(b,"click",sapiDebug.onClose);
		d.appendChild(b);
		sapiDebug.butClose=b;

		var b=sapiDebug.mkBut();
		b.innerHTML="OPEN";
		sapiEvents.attachEvent(b,"click",sapiDebug.onOpen);
		d.appendChild(b);
		b.style.display="none";
		sapiDebug.butOpen=b;

		var b=sapiDebug.mkBut();
		b.innerHTML="TEST";
		sapiEvents.attachEvent(b,"click",function(){
			dputs("This is a test string");
		});
		d.appendChild(b);

		var d=document.createElement("DIV");
		d.style.position="relative";
		d.style.backgroundColor="#ffffff";
		d.style.color="#000000";
		d.style.display="block";
		d.style.height=(sapiDebug.height-sapiDebug.tbHeight)+"px";
		d.style.overflow="auto";

		sapiDebug.debugWin.appendChild(d);
		sapiDebug.debugScreen=d;

		document.body.appendChild(sapiDebug.debugWin);
		sapiDebug.inited=true;
		sapiDebug.redraw();
	},
	redraw:function(){
		sapiDebug.debugScreen.innerHTML=sapiDebug.debugTxt;
	},
	mkBut:function(){
		var b=document.createElement("A");
		b.href="#";
		b.style.position="relative";
		b.style.color="#ffffff";
		b.style.margin="0px 10px";
		b.style.lineHeight=sapiDebug.tbHeight+"px";
		return b;
	},
	onClose:function(){
		sapiDebug.debugWin.style.height=sapiDebug.tbHeight+"px";
		sapiDebug.butOpen.style.display="inline";		
		sapiDebug.butClose.style.display="none";		
		return false;
	},
	onOpen:function(){
		sapiDebug.debugWin.style.height=sapiDebug.height+"px";
		sapiDebug.butClose.style.display="inline";		
		sapiDebug.butOpen.style.display="none";		
		return false;
	},
	onClear:function(){
		sapiDebug.debugTxt="";
		sapiDebug.colorCnt=true;
		dputs("Debug cleared");
		return false;
	}
};
window.dputs=sapiDebug.dputs;
