// (c) 2004-2006 Rob Rohan, Richard Applebaum, and Barney Boisvert

var DEBUG_VERSION="0.1";var DEBUG=false;var TYPE_DEBUG="DEBUG";var TYPE_WARN="WARN";var TYPE_INFO="INFO";var TYPE_ERROR="ERROR";function Log()
{this.NEW_WINDOW=0;this.TEXT_AREA=1;this.STRING_BUFFER=2;this.CONSOLE=3;this.USER_DIV=4;this.running=false;this.textele_handle=null;this.logbuffer="";this.type=this.NEW_WINDOW;}
Log.prototype.redirect=function redirect(to)
{this.type=to;};Log.prototype.init=function __log__init()
{if(DEBUG)
{switch(this.type)
{case this.NEW_WINDOW:this.__openwindow();break;case this.CONSOLE:this.__linkdiv();break;case this.USER_DIV:this.__linkinlinediv();break;}
this.running=true;this.info("Log (re)init...",this);}};Log.prototype.__linkdiv=function __log__linkdiv()
{this.output_handle=window;this.textele_handle=document.getElementById("neurostdout");};Log.prototype.__linkinlinediv=function __log__linkinlinediv()
{this.output_handle=window;this.textele_handle=document.getElementById("neurolog");if(this.textele_handle==null||typeof this.textele_handle=="undefined")
{alert("Warning: log set to output to a div with an id of 'neurolog', but no div was found. \n Log items will go nowhere.");}};Log.prototype.__openwindow=function __log__openwindow()
{var wndptr=window.open('','Log_Viewer','height=630,width=550,scrollbars=yes,resizable=yes,left=300,top=100,status=no,toolbar=no,location=no');wndptr.document.open();wndptr.document.write('<html><head><style type="text/css">.error{ color: red; } .info{ color: navy; } .warn{ color: yellow; } .debug{ color: black; }</style></head><body style="margin: 1px;"></body></html>');wndptr.document.close();bdy=wndptr.document.getElementsByTagName("body");toolbarele=wndptr.document.createElement("div");toolbarele.setAttribute("id","LogToolBar");toolbarele.setAttribute("style","background-color: silver; padding: 0px; margin: 0px; width: 100%; top: 0px; position: fixed !important; position: absolute; white-space: nowrap; z-Index: 1000000;");toolbarele.innerHTML="<input type='button' value='Clear' onclick='document.getElementById(\"LogText\").innerHTML=\"\";' title='Clear'>";logtextele=wndptr.document.createElement("div");logtextele.setAttribute("id","LogText");logtextele.setAttribute("style","top: 22px; width: 100%; height: 96%; position: relative;");bdy.item(0).appendChild(toolbarele);bdy.item(0).appendChild(logtextele);this.textele_handle=logtextele;this.output_handle=wndptr;};Log.prototype.__write=function __log__write(type,object,line)
{if(this.running==false)return;if(typeof object=="undefined")object="NO OBJECT";if(this.type==this.NEW_WINDOW)
{if(!this.output_handle.document)
{this.__openwindow();}}
var date=new Date();var datestring=(date.getYear()<1900)?date.getYear()+1900:date.getYear();datestring+="-"+(date.getMonth()+1)
datestring+="-"+date.getDate();datestring+=" "
+date.getHours()+":"
+((date.getMinutes()>=10)?date.getMinutes():"0"+date.getMinutes())+":"
+((date.getSeconds()>=10)?date.getSeconds():"0"+date.getSeconds());var newline=null;if(this.output_handle!=null)
newline=this.output_handle.document.createElement("div");else
newline=document.createElement("div");switch(type)
{case TYPE_DEBUG:newline.setAttribute("class","debug");break;case TYPE_INFO:newline.setAttribute("class","info");break;case TYPE_WARN:newline.setAttribute("class","warn");break;case TYPE_ERROR:newline.setAttribute("class","error");break;}
newline.innerHTML="["+datestring+"] "+type+" :: "+(typeof object)+" :: "+line;this.textele_handle.appendChild(newline);this.output_handle.scrollTo(0,this.textele_handle.scrollHeight);};Log.prototype.debug=function __log__debug(line,object)
{this.__write(TYPE_DEBUG,object,line);};Log.prototype.info=function __log__info(line,object)
{this.__write(TYPE_INFO,object,line);};Log.prototype.warn=function __log__warn(line,object)
{this.__write(TYPE_WARN,object,line);};Log.prototype.error=function __log__error(line,object)
{this.__write(TYPE_ERROR,object,line);};var log=new Log();if(DEBUG)log.init();