function je(e){return document.createElement(e);}
var jj = function(){
function range(f, i1, i2, t, cb) {if (!t)return f(this, i2);var me = this;var d = 10 * Math.abs(i1 - i2) / t;var intr = setInterval(function() {f(me, i1);if (i1 == i2) {clearInterval(intr);if (cb)cb.call(me);return;} else if (i1 < i2) {i1 = Math.min(i1 + d, i2);} else {i1 = Math.max(i1 - d, i2);}}, 10);return intr;}
var ep = Element.prototype;
ep.on = function(type, f){this.addEventListener(type, function(e) {f.call(this, e);}, false);return this;}

ep.ih = function(h){if(h){this.innerHTML = h;return this;}return this.innerHTML;}
ep.tc = function(t){if(!arguments.length)return this.textContent;this.textContent = t;return this;}
ep.ap = function(el, f){if(!f)this.appendChild(el);else if(f == '0'){if(this.firstChild)this.insertBefore(el, this.firstChild);else this.appendChild(el);}else if(f == '-')this.parentNode.insertBefore(el, this);else if(f == '+')if(this.nextSibling)this.nextSibling.ap(el, '-');else this.parentNode.appendChild(el);return this;}
ep.rm = function(el){try {this.removeChild(el);} catch (ex) {}return this;}
ep.clr = function(){while (this.firstChild)this.removeChild(this.firstChild);return this;}
ep.cn = function(n) {if (!arguments.length)return this.className;if (n[0] == '+') {if ((" " + this.className + " ").indexOf(" " + n.substr(1) + " ") == -1)this.className = (this.className + " " + n.substr(1)).trim();} else if (n[0] == '-'){var tmp = "", cs = this.className.split(" "), c = n.substr(1);for(var i in cs){if(cs[i] == c)continue;tmp += " " + cs[i];}this.className = tmp.trim();}else this.className = n;return this;}
ep.css = function(c, v){if(typeof c == "string"){if(arguments.length == 2)this.style[c] = v;else return (getComputedStyle(this, null).getPropertyValue(c) || this.style[c])};for(var k in c){this.style[k] = c[k];}return this;};
ep.att = function(a, v){if(typeof a == "string"){if(arguments.length == 2)this.setAttribute(a, v);else return this.getAttribute(a);}else for ( var k in a) this.setAttribute(k, a[k]);return this;}

ep.x = function(x, t, cb) {if (!arguments.length) {if (!this.offsetParent)return this.offsetLeft;return this.offsetLeft + this.offsetParent.x();}clearInterval(this.xint);this.xint = range.call(this, function(e, n) {e.css("left", n + "px");}, this.x(), parseInt(x), t, cb);return this;}
ep.y = function(y, t, cb) {if (!arguments.length) {if (!this.offsetParent)return this.offsetTop;return this.offsetTop + this.offsetParent.y();}clearInterval(this.yint);this.yint = range.call(this, function(e, n) {e.css("top", n + "px");}, this.y(), parseInt(y), t, cb);return this;}
ep.w = function(w, t, cb) {if (!arguments.length)return this.offsetWidth;clearInterval(this.wint);this.wint = range.call(this, function(e, n) {e.css("width", parseInt(n) + "px");}, parseInt(this.w()), parseInt(w), t, cb);return this;}
ep.h = function(h, t, cb) {if (!arguments.length)return this.offsetHeight;clearInterval(this.hint);this.hint = range.call(this, function(e, n) {e.css("height", parseInt(n) + "px");}, parseInt(this.h()), parseInt(h), t, cb);return this;}
ep.op = function(v, t, cb) {clearInterval(this.oint);this.oint = range.call(this, function(e, x) {e.css("opacity", x);}, parseFloat(this.css("opacity")), v, t, cb);return this;}
ep.hide = function(){this.css({display:"none"});return this;}
ep.show = function(){this.css({display:"block"});return this;}

return function(sel, o, cb) {if (o) {var args = "?";for ( var k in o)args += k + "=" + encodeURIComponent(o[k]) + "&";args = args.substring(0, args.length - 1);var url = sel + args;if (!cb) {je("img").src = url;return;}var req = new XMLHttpRequest();req.open("GET", url);req.setRequestHeader("oformat", "json");req.onreadystatechange = function() {if (req.readyState != 4)return;if (req.responseText)cb(eval("(" + req.responseText + ")"));else cb();};req.send(null);} else if (typeof sel == "string") {var es = document.querySelectorAll(sel);if (es.length == 1)return es.item(0);for ( var i = 0, a = []; i < es.length; i++)a.push(es.item(i));return a;} else if (typeof sel == "function") {window.addEventListener("DOMContentLoaded", sel, false);}};
}();
