function $() {
    var elements = new Array();
    for (var i = 0; i < arguments.length; i++) {
        var element = arguments[i];
        if (typeof element == 'string')
            element = document.getElementById(element);
        if (arguments.length == 1)
            return element;
        elements.push(element);
    }
    return elements;
}

function toggle(id) {
    var obj = $(id);
    if ( obj.style.display != 'none' ) {
        obj.olddisplay = obj.style.display;
        obj.style.display = 'none';
    } else {
        obj.style.display = (obj.olddisplay)? obj.olddisplay : '';
    }
}

function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    }
    else {
        window.onload = function() {
            oldonload();
            func();
        }
    }
}

function wrapDivByClass(classn) {
    classTree = ["n","e","s","w","nw","ne","se","sw","inner"];
    tempdivs = [];
    divs = document.getElementsByTagName('div');
    for (i=0;i<divs.length;i++) {
        cdiv = divs[i];
        if (cdiv.className.indexOf(classn) > -1) {
            tempinner = cdiv.innerHTML;
            cdiv.innerHTML = "";
            prevdiv = cdiv;
            for (a=0; a<classTree.length; a++) {
                tempdivs[a] = document.createElement('div');
                tempdivs[a].className = classTree[a];
                prevdiv.appendChild(tempdivs[a]);
                prevdiv = tempdivs[a];
            }
            prevdiv.innerHTML = tempinner;
        }
    }
}