var roboti = {
    font: ["Times New Roman", "Arial", "Georgia", "Verdana"],
    base: {"font": "fontFamily","size": "fontSize","colour": "color"},
    fy: function(el) {
        function R(el) {
            this.el = el;
        };
        R.prototype = roboti;
        var o = new R(el);
        return o;
    },
    get: function(s) {
        return roboti.fy(document.getElementById(s) || document.body);
    },
    set: function(s) {
        (this.el || document.body).innerHTML = s;
    },
    make: function(s) {
        var c = document.createTextNode(s);
        var el = document.createElement("div");
        el.appendChild(c);
        return roboti.fy(el);
    },
    take: function(r) {
        if (r && r.el) { 
          (this.el || document.body).appendChild(r.el);
        }
        else {
            document.body.appendChild(this.el);
        }
        return this;
    },
    style: function(o) {
        for (var i in o) {
            this.el.style[(roboti.base[i]||i)] = 
            i == "font" ? roboti.font[o[i]]:
            typeof o[i]== "number" ? Math.floor(o[i]) + "px":
            o[i];
        }
        return this;
    },
    when: function(evnt, fun, p) {
        var me = this;
        if (evnt === "interval") {
            this.stop().timer = setInterval(function() {
                fun.apply(me, p)
            },
            p[0]);
            return this;
        }
        (this.el || document)["on" + evnt] = function(e) {
            e = [e || event].concat(p);
            e[0].key = e[0].charCode || e[0].keyCode;
            return fun.apply(roboti.fy(e[0].target || document.body), e);
        }
        return this;
    },
    stop: function() {
        clearTimeout(this.timer);
        return this;
    },
    tell: function() {
        var el = this.el || document.body;
        return {
            has: el.innerText || el.textContent,
            tagName: el.tagName.toLowerCase(),
            left: el.offsetLeft,
            top: el.offsetTop,
            width: el.offsetWidth,
            height: el.offsetHeight,
            size: parseInt(el.style.fontSize, 10),
            font: this.font.indexOf(el.style.fontFamily)
        };
    }
}