STMA.splitArgs = function() {
    if (this) {
        args = new Array();
        var a;
        a = this.split(';');
        for(i=0;i<a.length;i++) {
            item = a[i];
            res = item.split('=');
            arg = res.shift();
            val = res.join('=');
            args.push(new Array(arg, val));
        }
        
        return args;        
    } else {
        return false;
    }
}

STMA.redir = function(t) {
    location.href = '/' + t + '.html';
}

STMA.seekParent = function(c) {
    f = true;
    i = 0;
    obj = this;
    while(f) {
        n = obj.parentNode;
        if (n.className.search(c) != '-1') {
            f = false;
            return n;
        } else {
            obj = n;
        }
        i++;
        if (i>50) {
            return false;
        }
    }
}

STMA.getElementsByClassname = function(c) {
    var nodes;
    nodes = this.getElementsByTagName('*');
    res = new Array();
    for(i=0;i<nodes.length;i++) {
        item = nodes[i];
        if (item.className == c) {
            res.push(item);
        }
    }
    return res;
}

STMA.bindWith = function() {
    o = this.previousSibling;
    o.value = (this.checked ? 1 : 0);
    this.checked = (this.checked ? true : false);
}

STMA.parseHash = function() {
    var res = window.location.hash;
    if (res != '') {
        if (res.search('#!') === 0) {
            res = res.substr(2);
            args = new Array();
            a = res.split(';');
            for(i=0;i<a.length;i++) {
                item = a[i];
                res = item.split('=');
                arg = res.shift();
                val = res.join('=');
                args[arg] = val;
            }
            return args;
        }
    }
        
    return new Array();
}

Node.prototype.insertAfter = function(newChild, oldChild) {
    if (oldChild.nextSibling) {
        return this.insertBefore(newChild, oldChild.nextSibling);
    } else {
        return this.appendChild(newChild);
    }
}

Node.prototype.nodePosition = function() {
    var node = this;
    var top = left = 0;
    while (node) {
       if (node.tagName) {
           top = top + node.offsetTop;
           left = left + node.offsetLeft;
           node = node.offsetParent;
       } else {
           node = node.parentNode;
       }
    }
    return [top, left];
}
