document._getElementById = document.getElementById;   
document.getElementById = function(id) {   
    var a = [];   
    var o = document._getElementById(id);   
    if (!o) return o;   
    while (o.id != id) {   
        a.push({i:o.id,e:o});   
        o.id='';   
        o = document._getElementById(id);   
        if (!o) return o;   
    }   
    for (j=0,jj=a.length; j<jj; j++) a[j].e.id = a[j].i;   
    a = null;   
    return o;   
}   

function LpadTime(i)
  {if (i<10) 
    {i="0" + i}
    return i
  }
  
var ERROR='<font style="color=#C42020">ERROR</font>';
var DEBUG='<font style="color=#319B31">DEBUG</font>';
var WARNING='<font style="color=#E88D25">WARNING</font>';

function getTimestamp() {
     var today=new Date()
     var h=today.getHours();
     var m=LpadTime(today.getMinutes());
     var s=LpadTime(today.getSeconds());
     return  '<font style="color=#5823C0">'+h+':'+m+':'+s+'</font>';
}

function log (str,type,name){
 if (logging==true){
     if (!type || type=='undefined')  {type=DEBUG}
     console.document.write('<br />'
     + getTimestamp()
     +' '+type
     +' '+name
     +' - '+str);
     console.scrollBy(10,100000)  }
}

function handleErr(msg,url,l)
{if (logging==true){
   if (url && url!=''){
      console.document.write('<br />'+ getTimestamp()+' '+ERROR+' '+url+' line '+l);
     }
     console.document.write('<br />'+ getTimestamp()+' '+ERROR+' '+msg);
     console.scrollBy(10,100000);
     return true;
   }
}

Object.prototype.log=function (str){
 if (logging==true)
 log(str,DEBUG,this.name);
}

Object.prototype.logError=function (str){
 if (logging==true)
 log(str,ERROR,this.name);
}

Object.prototype.logWarning=function (str){
 if (logging==true)
 log(str,WARNING,this.name);
}

if (logging==true){ 
  var console = window.open('','Javascriptlog','left=20,top=20,width=800,height=500,scrollbars=1,toolbar=0,menubar=0,resizable=1');
  onerror=handleErr;
}

