var _$ = new Array();
var mouseX = 0;
var mouseY = 0;

function $(id) {
    var d = document;
    if (!d._$) d._$ = new Array();
    
    if ((arguments.length > 1) && (arguments[1])) {
        d._$[id] = document.getElementById(id);
    } else if (d._$[id]==null) {
        d._$[id] = document.getElementById(id);
    }
    return d._$[id];
}

document.onmousemove=function(event) {
    if(!event) event = window.event; 
    mouseX = event.clientX + document.documentElement.scrollLeft;
    mouseY = event.clientY + document.documentElement.scrollTop;
}

function addEvent(elm, evType, fn, useCapture) {
        if (elm.addEventListener) {
                elm.addEventListener(evType, fn, useCapture);
        return true;
        }
        else if (elm.attachEvent) {
                var r = elm.attachEvent('on' + evType, fn);
                return r;
        }
        else {
                elm['on' + evType] = fn;
        }
}

function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    }
    else {
        window.onload = function() {
            oldonload();
            func();
        }
    }
}
