﻿/* Faux Console by Chris Heilmann http://wait-till-i.com */
if(!window.console) {
    var isLoggingOn = true;
    var console = {
        init : function() {
            //this.isLoggingOn = true;
            this.isLoggingOn = false;
            console.d = document.createElement('div');
            document.body.appendChild(console.d);

            var a = document.createElement('a');
            a.href = 'javascript:console.hide()';
            a.innerHTML = 'close';
            console.d.appendChild(a);

            var a = document.createElement('a');
            a.href = 'javascript:console.clear();';
            a.innerHTML = 'clear';
            console.d.appendChild(a);

            var a = document.createElement('a');
            a.href = 'javascript:console.stop();';
            a.innerHTML = 'stop';
            console.d.appendChild(a);

            var a = document.createElement('a');
            a.href = 'javascript:console.start();';
            a.innerHTML = 'start';
            console.d.appendChild(a);

            var id = 'fauxconsole';
            if (!document.getElementById(id)) {
                console.d.id=id;
            }
            console.hide();
        },
        start:function() {
            if (console.d) this.isLoggingOn = false;
        },
        stop:function() {
            if (console.d) this.isLoggingOn = false;
        },
        hide:function() {
            if (console.d) console.d.style.display='none';
        },
        show:function() {
            if (console.d) console.d.style.display='block';
        },
        log:function(o) {
            if (this.isLoggingOn) {
              if (console.d) console.d.innerHTML += '<br/>' + o;
              console.show();
            }
        },
        clear:function() {
            if (console.d) console.d.parentNode.removeChild(console.d);
            console.init();
            console.show();
        },
        addLoadEvent:function(func) {
            var oldonload=window.onload;
            if (typeof window.onload!='function') {
                alert('NOT FUNCTION');
                window.onload=func;
            } else {
                alert('FOUND FUNCTION');
                window.onload=function() {
                    if(oldonload) {
                        oldonload();
                    }
                    func();
                }
            }
        }
    };
    //console.addLoadEvent(console.init);
}

