function fC(v,c) {return v?'<font color="'+c+'">'+v+'</font>':''}
String.prototype.italic=function() {return '<i>'+this+'</i>'}
String.prototype.green=function() {return fC(this,'green')}
String.prototype.blue=function() {return fC(this,'blue')}
String.prototype.black=function() {return fC(this,'black')}
String.prototype.red=function() {return fC(this,'red')}
String.prototype.tag=function() {return '&lt;'+this+'&gt;'}

var debug_enabled=0
var D2max=30,DBG=[null,null,null,null]
var Dcss='' +
	'.debug{'+(debug_enabled?'':'display:none;')+'font:normal normal 9px/10px verdana;overflow:hidden;border:1px solid black;margin-top:1px;}' +
	'#debug0,#debug4{position:absolute;width:120px;left:1px;height:160px;background:white;padding:1px}' +
	'.debug EM {width:15px;text-align:right;margin-right:2px;font-style:normal}'+
	'.debug SPAN {}'+
	'#debug2 I {font-style:normal;white-space:nowrap;overflow:hidden;display:block;background:#f6f6f6;border-bottom:1px solid gray}'+
	'#debug2 I:hover {background:#f2f0f2;border-bottom:1px solid #999999}'+
	'#debug0{top:14px;height:80%;overflow:visible}' +
	'#debug0 PRE{overflow:hidden;width:100%}' +
	'#xdebug0:hover PRE{position:absolute}' +
	'#xdebug0 PRE * {white-space:nowrap}' +
	'#debug1{min-height:150px;background:yellow}' +
	'#debug1:hover{overflow-x:hidden;overflow-y:auto;position:absolute;height:240px;width:310px;z-index:9999}' +
	'#debug2{font-size:8px;overflow:hidden;height:200px;font-weight:bold;background:white;white-space:nowrap}' +
	'#debug2:hover{overflow-x:hidden;overflow-y:auto;position:absolute;height:340px;width:310px;z-index:9999}' +
	'#debug3{display:none;height:100px}' +
	'#debug4{top:0px;width:124px;background:#bfef5f;overflow:hidden;height:11px;padding:0px 1px 0px 1px}' +
	'#debug4 B{float:left;clear:left;width:140px;overflow:hidden;padding-right:3px}' +
	'#debug4 A{display:block;clear:both;}' +
	'#debug4 A:hover{background:#f0f0f0}' +
	'#debug4:hover{z-index:9998;height:160px;width:auto;overflow-y:scroll;background:white;z-index:9999}'

function initDebug() {
	if (!debug_enabled) return;
	if (!DBG[1]) {
	    var c=document.createElement('style')
	    c.setAttribute('type','text/css')
	    if (c.styleSheet) c.styleSheet.cssText=Dcss;
		else c.appendChild(document.createTextNode(Dcss));
		document.getElementsByTagName('head')[0].appendChild(c)

		var x,d,p
		for(x=0;x<=4;x++) {
			if (x==0)
			    d=document.createElement('div');
			else {
				d=document.createElement('pre')
				d.setAttribute('ondblclick','this.innerHTML="";this.style.width="auto"')
			}
			d.setAttribute('class','debug')
			d.setAttribute('id','debug'+x)

			if (x==0||x==4) {
			    if (x==0) p=d
				document.body.insertBefore(d,ById('cookie'))
			} else {
				p.appendChild(d)
			}
			DBG[x]=ById('debug'+x)
		}
//		alert(ById('content').)
		var L=document.links,s='',r=get_root();
		for(x in L) if (L[x].text) s+='<a href="'+L[x].href+'">'+L[x].text.bold()+L[x].href.replace(r,'').replace(/javascript:/i,'').black()+'</a>'
        DBG[4].innerHTML=s
	}
}
function cookieDebug(n,v,c) {if (!debug_enabled) return;initDebug();if (arguments[2]&&DBG[1]) DBG[1].innerHTML=(n+'='+v).blue()+'<hr />'+c.bold()+'\n'; else funcDebug(n+'='+v)}
function funcDebug(v) {if (!debug_enabled) return;initDebug();var a=getCaller(),m=D2max;v=v.indexOf('=')<0?(a+(a?'.':'')+v).tag().green().bold():a.black()+' '+v.blue();if (DBG[2]) {a=(trim(DBG[2].innerHTML+'')+'\n').split('\n');if (a.length>m) DBG[2].innerHTML=trim(a.slice(a.length-m,a.length).join('\n'));DBG[2].innerHTML+='\n<i onclick="debugMark(this)"><em>'+Cookie.length+'</em><span>'+trim(v)+'</span></i>'}}
function arrayDebug(a,id,ex) {if (!debug_enabled) return;var r='';for(var j in a)	r+=(j==id?j.red():j)+'\t= '+a[j]+'\t= '+(readCookie(ex+j)+'').blue()+'\n';if (DBG[3]) DBG[3].innerHTML=r}
function getCaller() {var a=arguments.callee.caller,x=0,y=0,r='',c=[];while(a&&x<10) {a=a.caller;c[x++]=a?(a.name?a.name:'EVENT'):''};for(x=0;x<c.length&&y<3;x++) {c[x]=c[x].replace(/cookieDebug|addCookie/i,'');r=c[x]?c[x]+(r?'.':'')+r:'';y+=c[x]?1:0};return r}
function debugMark(e) {e.style.borderColor=e.style.borderColor=='red'?'gray':'red'}
