(function (d) {
    function o(s) {
        return typeof s == "object" ? s : {
            top: s,
            left: s
        }
    }
    var h = d.scrollTo = function (s, D, i) {
            d(window).scrollTo(s, D, i)
        };
    h.defaults = {
        axis: "xy",
        duration: parseFloat(d.fn.jquery) >= 1.3 ? 0 : 1
    };
    h.window = function () {
        return d(window)._scrollable()
    };
    d.fn._scrollable = function () {
        return this.map(function () {
            if (!(!this.nodeName || d.inArray(this.nodeName.toLowerCase(), ["iframe", "#document", "html", "body"]) != -1)) return this;
            var s = (this.contentWindow || this).document || this.ownerDocument || this;
            return d.browser.safari || s.compatMode == "BackCompat" ? s.body : s.documentElement
        })
    };
    d.fn.scrollTo = function (s, D, i) {
        if (typeof D == "object") {
            i = D;
            D = 0
        }
        if (typeof i == "function") i = {
            onAfter: i
        };
        if (s == "max") s = 9E9;
        i = d.extend({}, h.defaults, i);
        D = D || i.speed || i.duration;
        i.queue = i.queue && i.axis.length > 1;
        if (i.queue) D /= 2;
        i.offset = o(i.offset);
        i.over = o(i.over);
        return this._scrollable().each(function () {
            function j(L) {
                w.animate(r, D, i.easing, L &&
                function () {
                    L.call(this, s, i)
                })
            }
            var E = this,
                w = d(E),
                k = s,
                N, r = {},
                y = w.is("html,body");
            switch (typeof k) {
            case "number":
            case "string":
                if (/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(k)) {
                    k = o(k);
                    break
                }
                k = d(k, this);
            case "object":
                if (k.is || k.style) N = (k = d(k)).offset()
            }
            d.each(i.axis.split(""), function (L, a) {
                var b = a == "x" ? "Left" : "Top",
                    c = b.toLowerCase(),
                    f = "scroll" + b,
                    m = E[f],
                    l = h.max(E, a);
                if (N) {
                    r[f] = N[c] + (y ? 0 : m - w.offset()[c]);
                    if (i.margin) {
                        r[f] -= parseInt(k.css("margin" + b)) || 0;
                        r[f] -= parseInt(k.css("border" + b + "Width")) || 0
                    }
                    r[f] += i.offset[c] || 0;
                    if (i.over[c]) r[f] += k[a == "x" ? "width" : "height"]() * i.over[c]
                } else {
                    b = k[c];
                    r[f] = b.slice && b.slice(-1) == "%" ? parseFloat(b) / 100 * l : b
                }
                if (/^\d+$/.test(r[f])) r[f] = r[f] <= 0 ? 0 : Math.min(r[f], l);
                if (!L && i.queue) {
                    m != r[f] && j(i.onAfterFirst);
                    delete r[f]
                }
            });
            j(i.onAfter)
        }).end()
    };
    h.max = function (s, D) {
        var i = D == "x" ? "Width" : "Height",
            j = "scroll" + i;
        if (!d(s).is("html,body")) return s[j] - d(s)[i.toLowerCase()]();
        i = "client" + i;
        var E = s.ownerDocument.documentElement,
            w = s.ownerDocument.body;
        return Math.max(E[j], w[j]) - Math.min(E[i], w[i])
    }
})(jQuery);
(function () {})(this.jQuery);
window.log = function () {
    log.history = log.history || [];
    log.history.push(arguments);
    this.console && console.log(Array.prototype.slice.call(arguments))
};
(function (d) {
    var o = d.write;
    d.write = function (h) {
        log("document.write(): ", arguments);
        /docwriteregexwhitelist/.test(h) && o.apply(d, arguments)
    }
})(document);
(function (d, o) {
    var h, s = /:([\w\d]+)/g,
        D = /\?([^#]*)$/,
        i = function (a) {
            return Array.prototype.slice.call(a)
        },
        j = function (a) {
            return Object.prototype.toString.call(a) === "[object Function]"
        },
        E = function (a) {
            return Object.prototype.toString.call(a) === "[object Array]"
        },
        w = function (a) {
            return decodeURIComponent(a.replace(/\+/g, " "))
        },
        k = encodeURIComponent,
        N = function (a) {
            return String(a).replace(/&(?!\w+;)/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;")
        },
        r = function (a) {
            return function (b, c) {
                return this.route.apply(this, [a, b, c])
            }
        },
        y = {},
        L = [];
    h = function () {
        var a = i(arguments),
            b, c;
        h.apps = h.apps || {};
        if (a.length === 0 || a[0] && j(a[0])) return h.apply(h, ["body"].concat(a));
        else if (typeof (c = a.shift()) == "string") {
            b = h.apps[c] || new h.Application;
            b.element_selector = c;
            a.length > 0 && d.each(a, function (f, m) {
                b.use(m)
            });
            b.element_selector != c && delete h.apps[c];
            return h.apps[b.element_selector] = b
        }
    };
    h.VERSION = "0.6.3";
    h.addLogger = function (a) {
        L.push(a)
    };
    h.log = function () {
        var a = i(arguments);
        a.unshift("[" + Date() + "]");
        d.each(L, function (b, c) {
            c.apply(h, a)
        })
    };
    if (typeof o.console != "undefined") j(o.console.log.apply) ? h.addLogger(function () {
        o.console.log.apply(o.console, arguments)
    }) : h.addLogger(function () {
        o.console.log(arguments)
    });
    else typeof console != "undefined" && h.addLogger(function () {
        console.log.apply(console, arguments)
    });
    d.extend(h, {
        makeArray: i,
        isFunction: j,
        isArray: E
    });
    h.Object = function (a) {
        return d.extend(this, a || {})
    };
    d.extend(h.Object.prototype, {
        escapeHTML: N,
        h: N,
        toHash: function () {
            var a = {};
            d.each(this, function (b, c) {
                j(c) || (a[b] = c)
            });
            return a
        },
        toHTML: function () {
            var a = "";
            d.each(this, function (b, c) {
                j(c) || (a += "<strong>" + b + "</strong> " + c + "<br />")
            });
            return a
        },
        keys: function (a) {
            var b = [],
                c;
            for (c in this) if (!j(this[c]) || !a) b.push(c);
            return b
        },
        has: function (a) {
            return this[a] && d.trim(this[a].toString()) != ""
        },
        join: function () {
            var a = i(arguments),
                b = a.shift();
            return a.join(b)
        },
        log: function () {
            h.log.apply(h, arguments)
        },
        toString: function (a) {
            var b = [];
            d.each(this, function (c, f) {
                if (!j(f) || a) b.push('"' + c + '": ' + f.toString())
            });
            return "Sammy.Object: {" + b.join(",") + "}"
        }
    });
    h.HashLocationProxy = function (a, b) {
        this.app = a;
        this.is_native = false;
        this._startPolling(b)
    };
    h.HashLocationProxy.prototype = {
        bind: function () {
            var a = this,
                b = this.app;
            d(o).bind("hashchange." + this.app.eventNamespace(), function (c, f) {
                if (a.is_native === false && !f) {
                    h.log("native hash change exists, using");
                    a.is_native = true;
                    o.clearInterval(h.HashLocationProxy._interval)
                }
                b.trigger("location-changed")
            });
            if (!h.HashLocationProxy._bindings) h.HashLocationProxy._bindings = 0;
            h.HashLocationProxy._bindings++
        },
        unbind: function () {
            d(o).unbind("hashchange." + this.app.eventNamespace());
            h.HashLocationProxy._bindings--;
            h.HashLocationProxy._bindings <= 0 && o.clearInterval(h.HashLocationProxy._interval)
        },
        getLocation: function () {
            var a = o.location.toString().match(/^[^#]*(#.+)$/);
            return a ? a[1] : ""
        },
        setLocation: function (a) {
            return o.location = a
        },
        _startPolling: function (a) {
            var b = this;
            if (!h.HashLocationProxy._interval) {
                a || (a = 10);
                var c = function () {
                        var f = b.getLocation();
                        if (!h.HashLocationProxy._last_location || f != h.HashLocationProxy._last_location) o.setTimeout(function () {
                            d(o).trigger("hashchange", [true])
                        }, 0);
                        h.HashLocationProxy._last_location = f
                    };
                c();
                h.HashLocationProxy._interval = o.setInterval(c, a)
            }
        }
    };
    h.Application = function (a) {
        var b = this;
        this.routes = {};
        this.listeners = new h.Object({});
        this.arounds = [];
        this.befores = [];
        this.namespace = (new Date).getTime() + "-" + parseInt(Math.random() * 1E3, 10);
        this.context_prototype = function () {
            h.EventContext.apply(this, arguments)
        };
        this.context_prototype.prototype = new h.EventContext;
        j(a) && a.apply(this, [this]);
        this._location_proxy || this.setLocationProxy(new h.HashLocationProxy(this, this.run_interval_every));
        this.debug && this.bindToAllEvents(function (c, f) {
            b.log(b.toString(), c.cleaned_type, f || {})
        })
    };
    h.Application.prototype = d.extend({}, h.Object.prototype, {
        ROUTE_VERBS: ["get", "post", "put", "delete"],
        APP_EVENTS: ["run", "unload", "lookup-route", "run-route", "route-found", "event-context-before", "event-context-after", "changed", "error", "check-form-submission", "redirect", "location-changed"],
        _last_route: null,
        _location_proxy: null,
        _running: false,
        element_selector: "body",
        debug: false,
        raise_errors: false,
        run_interval_every: 50,
        template_engine: null,
        toString: function () {
            return "Sammy.Application:" + this.element_selector
        },
        $element: function (a) {
            return a ? d(this.element_selector).find(a) : d(this.element_selector)
        },
        use: function () {
            var a = i(arguments),
                b = a.shift(),
                c = b || "";
            try {
                a.unshift(this);
                if (typeof b == "string") {
                    c = "Sammy." + b;
                    b = h[b]
                }
                b.apply(this, a)
            } catch (f) {
                if (typeof b === "undefined") this.error("Plugin Error: called use() but plugin (" + c.toString() + ") is not defined", f);
                else j(b) ? this.error("Plugin Error", f) : this.error("Plugin Error: called use() but '" + c.toString() + "' is not a function", f)
            }
            return this
        },
        setLocationProxy: function (a) {
            var b = this._location_proxy;
            this._location_proxy = a;
            if (this.isRunning()) {
                b && b.unbind();
                this._location_proxy.bind()
            }
        },
        route: function (a, b, c) {
            var f = this,
                m = [],
                l, p;
            if (!c && j(b)) {
                c = b = a;
                a = "any"
            }
            a = a.toLowerCase();
            if (b.constructor == String) {
                for (s.lastIndex = 0;
                (p = s.exec(b)) !== null;) m.push(p[1]);
                b = RegExp("^" + b.replace(s, "([^/]+)") + "$")
            }
            if (typeof c == "string") c = f[c];
            l = function (v) {
                var x = {
                    verb: v,
                    path: b,
                    callback: c,
                    param_names: m
                };
                f.routes[v] = f.routes[v] || [];
                f.routes[v].push(x)
            };
            a === "any" ? d.each(this.ROUTE_VERBS, function (v, x) {
                l(x)
            }) : l(a);
            return this
        },
        get: r("get"),
        post: r("post"),
        put: r("put"),
        del: r("delete"),
        any: r("any"),
        mapRoutes: function (a) {
            var b = this;
            d.each(a, function (c, f) {
                b.route.apply(b, f)
            });
            return this
        },
        eventNamespace: function () {
            return ["sammy-app", this.namespace].join("-")
        },
        bind: function (a, b, c) {
            var f = this;
            if (typeof c == "undefined") c = b;
            b = function (m, l) {
                var p;
                if (l && l.context) {
                    p = l.context;
                    delete l.context
                } else p = new f.context_prototype(f, "bind", m.type, l, m.target);
                m.cleaned_type = m.type.replace(f.eventNamespace(), "");
                c.apply(p, [m, l])
            };
            this.listeners[a] || (this.listeners[a] = []);
            this.listeners[a].push(b);
            this.isRunning() && this._listen(a, b);
            return this
        },
        trigger: function (a, b) {
            this.$element().trigger([a, this.eventNamespace()].join("."), [b]);
            return this
        },
        refresh: function () {
            this.last_location = null;
            this.trigger("location-changed");
            return this
        },
        before: function (a, b) {
            if (j(a)) {
                b = a;
                a = {}
            }
            this.befores.push([a, b]);
            return this
        },
        after: function (a) {
            return this.bind("event-context-after", a)
        },
        around: function (a) {
            this.arounds.push(a);
            return this
        },
        isRunning: function () {
            return this._running
        },
        helpers: function (a) {
            d.extend(this.context_prototype.prototype, a);
            return this
        },
        helper: function (a, b) {
            this.context_prototype.prototype[a] = b;
            return this
        },
        run: function (a) {
            if (this.isRunning()) return false;
            var b = this;
            d.each(this.listeners.toHash(), function (c, f) {
                d.each(f, function (m, l) {
                    b._listen(c, l)
                })
            });
            this.trigger("run", {
                start_url: a
            });
            this._running = true;
            this.last_location = null;
            this.getLocation() == "" && typeof a != "undefined" && this.setLocation(a);
            this._checkLocation();
            this._location_proxy.bind();
            this.bind("location-changed", function () {
                b._checkLocation()
            });
            this.bind("submit", function (c) {
                return b._checkFormSubmission(d(c.target).closest("form")) === false ? c.preventDefault() : false
            });
            d(o).bind("beforeunload", function () {
                b.unload()
            });
            return this.trigger("changed")
        },
        unload: function () {
            if (!this.isRunning()) return false;
            var a = this;
            this.trigger("unload");
            this._location_proxy.unbind();
            this.$element().unbind("submit").removeClass(a.eventNamespace());
            d.each(this.listeners.toHash(), function (b, c) {
                d.each(c, function (f, m) {
                    a._unlisten(b, m)
                })
            });
            this._running = false;
            return this
        },
        bindToAllEvents: function (a) {
            var b = this;
            d.each(this.APP_EVENTS, function (c, f) {
                b.bind(f, a)
            });
            d.each(this.listeners.keys(true), function (c, f) {
                b.APP_EVENTS.indexOf(f) == -1 && b.bind(f, a)
            });
            return this
        },
        routablePath: function (a) {
            return a.replace(D, "")
        },
        lookupRoute: function (a, b) {
            var c = this,
                f = false;
            this.trigger("lookup-route", {
                verb: a,
                path: b
            });
            typeof this.routes[a] != "undefined" && d.each(this.routes[a], function (m, l) {
                if (c.routablePath(b).match(l.path)) {
                    f = l;
                    return false
                }
            });
            return f
        },
        runRoute: function (a, b, c, f) {
            var m = this,
                l = this.lookupRoute(a, b),
                p, v, x, q, M, G, Y;
            this.log("runRoute", [a, b].join(" "));
            this.trigger("run-route", {
                verb: a,
                path: b,
                params: c
            });
            if (typeof c == "undefined") c = {};
            d.extend(c, this._parseQueryString(b));
            if (l) {
                this.trigger("route-found", {
                    route: l
                });
                if ((G = l.path.exec(this.routablePath(b))) !== null) {
                    G.shift();
                    d.each(G, function (K, Q) {
                        if (l.param_names[K]) c[l.param_names[K]] = w(Q);
                        else {
                            if (!c.splat) c.splat = [];
                            c.splat.push(w(Q))
                        }
                    })
                }
                p = new this.context_prototype(this, a, b, c, f);
                f = this.arounds.slice(0);
                x = this.befores.slice(0);
                M = [p].concat(c.splat);
                v = function () {
                    for (var K; x.length > 0;) {
                        q = x.shift();
                        if (m.contextMatchesOptions(p, q[0])) {
                            K = q[1].apply(p, [p]);
                            if (K === false) return false
                        }
                    }
                    m.last_route = l;
                    p.trigger("event-context-before", {
                        context: p
                    });
                    K = l.callback.apply(p, M);
                    p.trigger("event-context-after", {
                        context: p
                    });
                    return K
                };
                d.each(f.reverse(), function (K, Q) {
                    var z = v;
                    v = function () {
                        return Q.apply(p, [z])
                    }
                });
                try {
                    Y = v()
                } catch (aa) {
                    this.error(["500 Error", a, b].join(" "), aa)
                }
                return Y
            } else return this.notFound(a, b)
        },
        contextMatchesOptions: function (a, b, c) {
            b = b;
            if (typeof b === "undefined" || b == {}) return true;
            if (typeof c === "undefined") c = true;
            if (typeof b === "string" || j(b.test)) b = {
                path: b
            };
            if (b.only) return this.contextMatchesOptions(a, b.only, true);
            else if (b.except) return this.contextMatchesOptions(a, b.except, false);
            var f = true,
                m = true;
            if (b.path) f = j(b.path.test) ? b.path.test(a.path) : b.path.toString() === a.path;
            if (b.verb) m = b.verb === a.verb;
            return c ? m && f : !(m && f)
        },
        getLocation: function () {
            return this._location_proxy.getLocation()
        },
        setLocation: function (a) {
            return this._location_proxy.setLocation(a)
        },
        swap: function (a) {
            return this.$element().html(a)
        },
        templateCache: function (a, b) {
            return typeof b != "undefined" ? y[a] = b : y[a]
        },
        clearTemplateCache: function () {
            return y = {}
        },
        notFound: function (a, b) {
            var c = this.error(["404 Not Found", a, b].join(" "));
            return a === "get" ? c : true
        },
        error: function (a, b) {
            b || (b = Error());
            b.message = [a, b.message].join(" ");
            this.trigger("error", {
                message: b.message,
                error: b
            });
            if (this.raise_errors) throw b;
            else this.log(b.message, b)
        },
        _checkLocation: function () {
            var a, b;
            a = this.getLocation();
            if (!this.last_location || this.last_location[0] != "get" || this.last_location[1] != a) {
                this.last_location = ["get", a];
                b = this.runRoute("get", a)
            }
            return b
        },
        _getFormVerb: function (a) {
            a = d(a);
            var b, c;
            c = a.find('input[name="_method"]');
            if (c.length > 0) b = c.val();
            b || (b = a[0].getAttribute("method"));
            if (!b || b == "") b = "get";
            return d.trim(b.toString().toLowerCase())
        },
        _checkFormSubmission: function (a) {
            var b, c, f;
            this.trigger("check-form-submission", {
                form: a
            });
            b = d(a);
            c = b.attr("action");
            f = this._getFormVerb(b);
            this.log("_checkFormSubmission", b, c, f);
            if (f === "get") {
                this.setLocation(c + "?" + this._serializeFormParams(b));
                a = false
            } else {
                b = d.extend({}, this._parseFormParams(b));
                a = this.runRoute(f, c, b, a.get(0))
            }
            return typeof a == "undefined" ? false : a
        },
        _serializeFormParams: function (a) {
            var b = "";
            a = a.serializeArray();
            var c;
            if (a.length > 0) {
                b = this._encodeFormPair(a[0].name, a[0].value);
                for (c = 1; c < a.length; c++) b = b + "&" + this._encodeFormPair(a[c].name, a[c].value)
            }
            return b
        },
        _encodeFormPair: function (a, b) {
            return k(a) + "=" + k(b)
        },
        _parseFormParams: function (a) {
            var b = {};
            a = a.serializeArray();
            var c;
            for (c = 0; c < a.length; c++) b = this._parseParamPair(b, a[c].name, a[c].value);
            return b
        },
        _parseQueryString: function (a) {
            var b = {},
                c, f;
            if (a = a.match(D)) {
                a = a[1].split("&");
                for (f = 0; f < a.length; f++) {
                    c = a[f].split("=");
                    b = this._parseParamPair(b, w(c[0]), w(c[1] || ""))
                }
            }
            return b
        },
        _parseParamPair: function (a, b, c) {
            if (a[b]) if (E(a[b])) a[b].push(c);
            else a[b] = [a[b], c];
            else a[b] = c;
            return a
        },
        _listen: function (a, b) {
            return this.$element().bind([a, this.eventNamespace()].join("."), b)
        },
        _unlisten: function (a, b) {
            return this.$element().unbind([a, this.eventNamespace()].join("."), b)
        }
    });
    h.RenderContext = function (a) {
        this.event_context = a;
        this.callbacks = [];
        this.content = this.previous_content = null;
        this.waiting = this.next_engine = false
    };
    h.RenderContext.prototype = d.extend({}, h.Object.prototype, {
        then: function (a) {
            if (!j(a)) if (typeof a === "string" && a in this.event_context) {
                var b = this.event_context[a];
                a = function (f) {
                    return b.apply(this.event_context, [f])
                }
            } else return this;
            var c = this;
            if (this.waiting) this.callbacks.push(a);
            else {
                this.wait();
                o.setTimeout(function () {
                    var f = a.apply(c, [c.content, c.previous_content]);
                    f !== false && c.next(f)
                }, 0)
            }
            return this
        },
        wait: function () {
            this.waiting = true
        },
        next: function (a) {
            this.waiting = false;
            if (typeof a !== "undefined") {
                this.previous_content = this.content;
                this.content = a
            }
            this.callbacks.length > 0 && this.then(this.callbacks.shift())
        },
        load: function (a, b, c) {
            var f = this;
            return this.then(function () {
                var m, l, p;
                if (j(b)) {
                    c = b;
                    b = {}
                } else b = d.extend({}, b);
                c && this.then(c);
                if (typeof a === "string") {
                    m = (p = a.match(/\.json$/) || b.json) && b.cache === true || b.cache !== false;
                    f.next_engine = f.event_context.engineFor(a);
                    delete b.cache;
                    delete b.json;
                    if (b.engine) {
                        f.next_engine = b.engine;
                        delete b.engine
                    }
                    if (m && (l = this.event_context.app.templateCache(a))) return l;
                    this.wait();
                    d.ajax(d.extend({
                        url: a,
                        data: {},
                        dataType: p ? "json" : null,
                        type: "get",
                        success: function (v) {
                            m && f.event_context.app.templateCache(a, v);
                            f.next(v)
                        }
                    }, b));
                    return false
                } else {
                    if (a.nodeType) return a.innerHTML;
                    if (a.selector) {
                        f.next_engine = a.attr("data-engine");
                        return b.clone === false ? a.remove()[0].innerHTML.toString() : a[0].innerHTML.toString()
                    }
                }
            })
        },
        render: function (a, b, c) {
            return j(a) && !b ? this.then(a) : this.load(a).interpolate(b, a).then(c)
        },
        partial: function (a, b) {
            return this.render(a, b).swap()
        },
        send: function () {
            var a = this,
                b = i(arguments),
                c = b.shift();
            if (E(b[0])) b = b[0];
            return this.then(function () {
                b.push(function (f) {
                    a.next(f)
                });
                a.wait();
                c.apply(c, b);
                return false
            })
        },
        collect: function (a, b, c) {
            var f = this,
                m = function () {
                    if (j(a)) {
                        b = a;
                        a = this.content
                    }
                    var l = [],
                        p = false;
                    d.each(a, function (v, x) {
                        var q = b.apply(f, [v, x]);
                        if (q.jquery && q.length == 1) {
                            q = q[0];
                            p = true
                        }
                        l.push(q);
                        return q
                    });
                    return p ? l : l.join("")
                };
            return c ? m() : this.then(m)
        },
        renderEach: function (a, b, c, f) {
            if (E(b)) {
                f = c;
                c = b;
                b = null
            }
            return this.load(a).then(function (m) {
                var l = this;
                c || (c = E(this.previous_content) ? this.previous_content : []);
                if (f) d.each(c, function (p, v) {
                    var x = {},
                        q = this.next_engine || a;
                    b ? x[b] = v : x = v;
                    f(v, l.event_context.interpolate(m, x, q))
                });
                else return this.collect(c, function (p, v) {
                    var x = {},
                        q = this.next_engine || a;
                    b ? x[b] = v : x = v;
                    return this.event_context.interpolate(m, x, q)
                }, true)
            })
        },
        interpolate: function (a, b, c) {
            var f = this;
            return this.then(function (m, l) {
                if (!a && l) a = l;
                if (this.next_engine) {
                    b = this.next_engine;
                    this.next_engine = false
                }
                var p = f.event_context.interpolate(m, a, b);
                return c ? l + p : p
            })
        },
        swap: function () {
            return this.then(function (a) {
                this.event_context.swap(a)
            }).trigger("changed", {})
        },
        appendTo: function (a) {
            return this.then(function (b) {
                d(a).append(b)
            }).trigger("changed", {})
        },
        prependTo: function (a) {
            return this.then(function (b) {
                d(a).prepend(b)
            }).trigger("changed", {})
        },
        replace: function (a) {
            return this.then(function (b) {
                d(a).html(b)
            }).trigger("changed", {})
        },
        trigger: function (a, b) {
            return this.then(function (c) {
                if (typeof b == "undefined") b = {
                    content: c
                };
                this.event_context.trigger(a, b)
            })
        }
    });
    h.EventContext = function (a, b, c, f, m) {
        this.app = a;
        this.verb = b;
        this.path = c;
        this.params = new h.Object(f);
        this.target = m
    };
    h.EventContext.prototype = d.extend({}, h.Object.prototype, {
        $element: function () {
            return this.app.$element(i(arguments).shift())
        },
        engineFor: function (a) {
            var b;
            if (j(a)) return a;
            a = (a || this.app.template_engine).toString();
            if (b = a.match(/\.([^\.]+)$/)) a = b[1];
            if (a && j(this[a])) return this[a];
            if (this.app.template_engine) return this.engineFor(this.app.template_engine);
            return function (c) {
                return c
            }
        },
        interpolate: function (a, b, c) {
            return this.engineFor(c).apply(this, [a, b])
        },
        render: function (a, b, c) {
            return (new h.RenderContext(this)).render(a, b, c)
        },
        renderEach: function (a, b, c, f) {
            return (new h.RenderContext(this)).renderEach(a, b, c, f)
        },
        load: function (a, b, c) {
            return (new h.RenderContext(this)).load(a, b, c)
        },
        partial: function (a, b) {
            return (new h.RenderContext(this)).partial(a, b)
        },
        send: function () {
            var a = new h.RenderContext(this);
            return a.send.apply(a, arguments)
        },
        redirect: function () {
            var a;
            a = i(arguments);
            var b = this.app.getLocation();
            if (a.length > 1) {
                a.unshift("/");
                a = this.join.apply(this, a)
            } else a = a[0];
            this.trigger("redirect", {
                to: a
            });
            this.app.last_location = [this.verb, this.path];
            this.app.setLocation(a);
            b == a && this.app.trigger("location-changed")
        },
        trigger: function (a, b) {
            if (typeof b == "undefined") b = {};
            if (!b.context) b.context = this;
            return this.app.trigger(a, b)
        },
        eventNamespace: function () {
            return this.app.eventNamespace()
        },
        swap: function (a) {
            return this.app.swap(a)
        },
        notFound: function () {
            return this.app.notFound(this.verb, this.path)
        },
        json: function (a) {
            return d.parseJSON(a)
        },
        toString: function () {
            return "Sammy.EventContext: " + [this.verb, this.path, this.params].join(" ")
        }
    });
    d.sammy = o.Sammy = h
})(jQuery, window);
(function (d, o, h) {
    function s(g) {
        if (!ja) {
            H = g;
            j(d.extend(e, d.data(H, r)));
            z = d(H);
            A = 0;
            e.rel !== "nofollow" && (z = d("." + ba).filter(function () {
                return (d.data(this, r).rel || this.rel) === e.rel
            }), A = z.index(H), A === -1 && (z = z.add(H), A = z.length - 1));
            if (!O) {
                O = Z = true;
                q.show();
                if (e.returnFocus) try {
                    H.blur();
                    d(H).one(f, function () {
                        try {
                            this.focus()
                        } catch (t) {}
                    })
                } catch (n) {}
                x.css({
                    opacity: +e.opacity,
                    cursor: e.overlayClose ? "pointer" : "auto"
                }).show();
                e.w = w(e.initialWidth, "x");
                e.h = w(e.initialHeight, "y");
                u.position(0);
                p && J.bind("resize." + v + " scroll." + v, function () {
                    x.css({
                        width: J.width(),
                        height: J.height(),
                        top: J.scrollTop(),
                        left: J.scrollLeft()
                    })
                }).trigger("resize." + v);
                i(L, e.onOpen);
                ma.add(na).hide();
                oa.html(e.close).show()
            }
            u.load(true)
        }
    }
    function D() {
        var g, n = y + "Slideshow_",
            t = "click." + y,
            C, I;
        e.slideshow && z[1] && (C = function () {
            ca.text(e.slideshowStop).unbind(t).bind(b, function () {
                if (A < z.length - 1 || e.loop) g = setTimeout(u.next, e.slideshowSpeed)
            }).bind(a, function () {
                clearTimeout(g)
            }).one(t + " " + c, I);
            q.removeClass(n + "off").addClass(n + "on");
            g = setTimeout(u.next, e.slideshowSpeed)
        }, I = function () {
            clearTimeout(g);
            ca.text(e.slideshowStart).unbind([b, a, c, t].join(" ")).one(t, C);
            q.removeClass(n + "on").addClass(n + "off")
        }, e.slideshowAuto ? C() : I())
    }
    function i(g, n) {
        n && n.call(H);
        d.event.trigger(g)
    }
    function j(g) {
        for (var n in g) d.isFunction(g[n]) && n.substring(0, 2) !== "on" && (g[n] = g[n].call(H));
        g.rel = g.rel || H.rel || "nofollow";
        g.href = d.trim(g.href || d(H).attr("href"));
        g.title = g.title || H.title
    }
    function E(g) {
        return e.photo || /\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i.test(g)
    }

    function w(g, n) {
        n = n === "x" ? J.width() : J.height();
        return typeof g == "string" ? Math.round(/%/.test(g) ? n / 100 * parseInt(g, 10) : parseInt(g, 10)) : g
    }
    function k(g, n) {
        var t = o.createElement("div");
        t.id = g ? y + g : false;
        t.style.cssText = n || false;
        return d(t)
    }
    var N = {
        transition: "elastic",
        speed: 300,
        width: false,
        initialWidth: "600",
        innerWidth: false,
        maxWidth: false,
        height: false,
        initialHeight: "450",
        innerHeight: false,
        maxHeight: false,
        scalePhotos: true,
        scrolling: true,
        inline: false,
        html: false,
        iframe: false,
        fastIframe: true,
        photo: false,
        href: false,
        title: false,
        rel: false,
        opacity: 0.9,
        preloading: true,
        current: "image {current} of {total}",
        previous: "previous",
        next: "next",
        close: "close",
        open: false,
        returnFocus: true,
        loop: true,
        slideshow: false,
        slideshowAuto: true,
        slideshowSpeed: 2500,
        slideshowStart: "start slideshow",
        slideshowStop: "stop slideshow",
        onOpen: false,
        onLoad: false,
        onComplete: false,
        onCleanup: false,
        onClosed: false,
        overlayClose: true,
        escKey: true,
        arrowKey: true
    },
        r = "colorbox",
        y = "cbox",
        L = y + "_open",
        a = y + "_load",
        b = y + "_complete",
        c = y + "_cleanup",
        f = y + "_closed",
        m = y + "_purge",
        l = d.browser.msie && !d.support.opacity,
        p = l && d.browser.version < 7,
        v = y + "_IE6",
        x, q, M, G, Y, aa, K, Q, z, J, F, da, ea, na, pa, ca, fa, ga, oa, ma, e = {},
        U, V, R, S, H, A, B, O, Z, ja = false,
        u, ba = y + "Element";
    u = d.fn[r] = d[r] = function (g, n) {
        var t = this,
            C;
        if (!t[0] && t.selector) return t;
        g = g || {};
        n && (g.onComplete = n);
        if (!t[0] || t.selector === undefined) {
            t = d("<a/>");
            g.open = true
        }
        t.each(function () {
            d.data(this, r, d.extend({}, d.data(this, r) || N, g));
            d(this).addClass(ba)
        });
        C = g.open;
        d.isFunction(C) && (C = C.call(t));
        C && s(t[0]);
        return t
    };
    u.init = function () {
        J = d(h);
        q = k().attr({
            id: r,
            "class": l ? y + (p ? "IE6" : "IE") : ""
        });
        x = k("Overlay", p ? "position:absolute" : "").hide();
        M = k("Wrapper");
        G = k("Content").append(F = k("LoadedContent", "width:0; height:0; overflow:hidden"), ea = k("LoadingOverlay").add(k("LoadingGraphic")), na = k("Title"), pa = k("Current"), fa = k("Next"), ga = k("Previous"), ca = k("Slideshow").bind(L, D), oa = k("Close"));
        M.append(k().append(k("TopLeft"), Y = k("TopCenter"), k("TopRight")), k(false, "clear:left").append(aa = k("MiddleLeft"), G, K = k("MiddleRight")), k(false, "clear:left").append(k("BottomLeft"), Q = k("BottomCenter"), k("BottomRight"))).children().children().css({
            "float": "left"
        });
        da = k(false, "position:absolute; width:9999px; visibility:hidden; display:none");
        d("body").prepend(x, q.append(M, da));
        G.children().hover(function () {
            d(this).addClass("hover")
        }, function () {
            d(this).removeClass("hover")
        }).addClass("hover");
        U = Y.height() + Q.height() + G.outerHeight(true) - G.height();
        V = aa.width() + K.width() + G.outerWidth(true) - G.width();
        R = F.outerHeight(true);
        S = F.outerWidth(true);
        q.css({
            "padding-bottom": U,
            "padding-right": V
        }).hide();
        fa.click(function () {
            u.next()
        });
        ga.click(function () {
            u.prev()
        });
        oa.click(function () {
            u.close()
        });
        ma = fa.add(ga).add(pa).add(ca);
        G.children().removeClass("hover");
        d("." + ba).live("click", function (g) {
            g.button !== 0 && typeof g.button != "undefined" || g.ctrlKey || g.shiftKey || g.altKey || (g.preventDefault(), s(this))
        });
        x.click(function () {
            e.overlayClose && u.close()
        });
        d(o).bind("keydown", function (g) {
            O && e.escKey && g.keyCode === 27 && (g.preventDefault(), u.close());
            O && e.arrowKey && !Z && z[1] && (g.keyCode === 37 && (A || e.loop) ? (g.preventDefault(), ga.click()) : g.keyCode === 39 && (A < z.length - 1 || e.loop) && (g.preventDefault(), fa.click()))
        })
    };
    u.remove = function () {
        q.add(x).remove();
        d("." + ba).die("click").removeData(r).removeClass(ba)
    };
    u.position = function (g, n) {
        function t(P) {
            Y[0].style.width = Q[0].style.width = G[0].style.width = P.style.width;
            ea[0].style.height = ea[1].style.height = G[0].style.height = aa[0].style.height = K[0].style.height = P.style.height
        }
        var C, I = Math.max(o.documentElement.clientHeight - e.h - R - U, 0) / 2 + J.scrollTop(),
            ha = Math.max(J.width() - e.w - S - V, 0) / 2 + J.scrollLeft();
        C = q.width() === e.w + S && q.height() === e.h + R ? 0 : g;
        M[0].style.width = M[0].style.height = "9999px";
        q.dequeue().animate({
            width: e.w + S,
            height: e.h + R,
            top: I,
            left: ha
        }, {
            duration: C,
            complete: function () {
                t(this);
                Z = false;
                M[0].style.width = e.w + S + V + "px";
                M[0].style.height = e.h + R + U + "px";
                n && n()
            },
            step: function () {
                t(this)
            }
        })
    };
    u.resize = function (g) {
        if (O) {
            g = g || {};
            g.width && (e.w = w(g.width, "x") - S - V);
            g.innerWidth && (e.w = w(g.innerWidth, "x"));
            F.css({
                width: e.w
            });
            g.height && (e.h = w(g.height, "y") - R - U);
            g.innerHeight && (e.h = w(g.innerHeight, "y"));
            if (!g.innerHeight && !g.height) {
                g = F.wrapInner("<div style='overflow:auto'></div>").children();
                e.h = g.height();
                g.replaceWith(g.children())
            }
            F.css({
                height: e.h
            });
            u.position(e.transition === "none" ? 0 : e.speed)
        }
    };
    u.prep = function (g) {
        function n(ha) {
            u.position(ha, function () {
                var P, W, ka, X, ia = z.length,
                    T, la;
                !O || (la = function () {
                    ea.hide();
                    i(b, e.onComplete)
                }, l && B && F.fadeIn(100), na.html(e.title).add(F).show(), ia > 1 ? (typeof e.current == "string" && pa.html(e.current.replace(/\{current\}/, A + 1).replace(/\{total\}/, ia)).show(), fa[e.loop || A < ia - 1 ? "show" : "hide"]().html(e.next), ga[e.loop || A ? "show" : "hide"]().html(e.previous), P = A ? z[A - 1] : z[ia - 1], ka = A < ia - 1 ? z[A + 1] : z[0], e.slideshow && ca.show(), e.preloading && (X = d.data(ka, r).href || ka.href, W = d.data(P, r).href || P.href, X = d.isFunction(X) ? X.call(ka) : X, W = d.isFunction(W) ? W.call(P) : W, E(X) && (d("<img/>")[0].src = X), E(W) && (d("<img/>")[0].src = W))) : ma.hide(), e.iframe ? (T = d("<iframe frameborder=0/>").addClass(y + "Iframe")[0], e.fastIframe ? la() : d(T).load(la), T.name = y + +new Date, T.src = e.href, e.scrolling || (T.scrolling = "no"), l && (T.allowTransparency = "true"), d(T).appendTo(F).one(m, function () {
                    T.src = "//about:blank"
                })) : la(), e.transition === "fade" ? q.fadeTo(I, 1, function () {
                    q[0].style.filter = ""
                }) : q[0].style.filter = "", J.bind("resize." + y, function () {
                    u.position(0)
                }))
            })
        }
        function t() {
            e.h = e.h || F.height();
            e.h = e.mh && e.mh < e.h ? e.mh : e.h;
            return e.h
        }
        function C() {
            e.w = e.w || F.width();
            e.w = e.mw && e.mw < e.w ? e.mw : e.w;
            return e.w
        }
        if (O) {
            var I = e.transition === "none" ? 0 : e.speed;
            J.unbind("resize." + y);
            F.remove();
            F = k("LoadedContent").html(g);
            F.hide().appendTo(da.show()).css({
                width: C(),
                overflow: e.scrolling ? "auto" : "hidden"
            }).css({
                height: t()
            }).prependTo(G);
            da.hide();
            d(B).css({
                "float": "none"
            });
            p && d("select").not(q.find("select")).filter(function () {
                return this.style.visibility !== "hidden"
            }).css({
                visibility: "hidden"
            }).one(c, function () {
                this.style.visibility = "inherit"
            });
            e.transition === "fade" ? q.fadeTo(I, 0, function () {
                n(0)
            }) : n(I)
        }
    };
    u.load = function (g) {
        var n, t, C = u.prep;
        Z = true;
        B = false;
        H = z[A];
        g || j(d.extend(e, d.data(H, r)));
        i(m);
        i(a, e.onLoad);
        e.h = e.height ? w(e.height, "y") - R - U : e.innerHeight && w(e.innerHeight, "y");
        e.w = e.width ? w(e.width, "x") - S - V : e.innerWidth && w(e.innerWidth, "x");
        e.mw = e.w;
        e.mh = e.h;
        e.maxWidth && (e.mw = w(e.maxWidth, "x") - S - V, e.mw = e.w && e.w < e.mw ? e.w : e.mw);
        e.maxHeight && (e.mh = w(e.maxHeight, "y") - R - U, e.mh = e.h && e.h < e.mh ? e.h : e.mh);
        n = e.href;
        ea.show();
        e.inline ? (k().hide().insertBefore(d(n)[0]).one(m, function () {
            d(this).replaceWith(F.children())
        }), C(d(n))) : e.iframe ? C(" ") : e.html ? C(e.html) : E(n) ? (d(B = new Image).addClass(y + "Photo").error(function () {
            e.title = false;
            C(k("Error").text("This image could not be loaded"))
        }).load(function () {
            var I;
            B.onload = null;
            e.scalePhotos && (t = function () {
                B.height -= B.height * I;
                B.width -= B.width * I
            }, e.mw && B.width > e.mw && (I = (B.width - e.mw) / B.width, t()), e.mh && B.height > e.mh && (I = (B.height - e.mh) / B.height, t()));
            e.h && (B.style.marginTop = Math.max(e.h - B.height, 0) / 2 + "px");
            z[1] && (A < z.length - 1 || e.loop) && (B.style.cursor = "pointer", B.onclick = function () {
                u.next()
            });
            l && (B.style.msInterpolationMode = "bicubic");
            setTimeout(function () {
                C(B)
            }, 1)
        }), setTimeout(function () {
            B.src = n
        }, 1)) : n && da.load(n, function (I, ha, P) {
            C(ha === "error" ? k("Error").text("Request unsuccessful: " + P.statusText) : d(this).contents())
        })
    };
    u.next = function () {
        Z || (A = A < z.length - 1 ? A + 1 : 0, u.load())
    };
    u.prev = function () {
        Z || (A = A ? A - 1 : z.length - 1, u.load())
    };
    u.close = function () {
        O && !ja && (ja = true, O = false, i(c, e.onCleanup), J.unbind("." + y + " ." + v), x.fadeTo(200, 0), q.stop().fadeTo(300, 0, function () {
            q.add(x).css({
                opacity: 1,
                cursor: "auto"
            }).hide();
            i(m);
            F.remove();
            setTimeout(function () {
                ja = false;
                i(f, e.onClosed)
            }, 1)
        }))
    };
    u.element = function () {
        return d(H)
    };
    u.settings = N;
    d(u.init)
})(jQuery, document, this);

function Slider(d, o, h, s, D) {
    this.element = $(d);
    this.position = o;
    this.width = h;
    this.grid_width = s;
    this.offset = D;
    this._move = function (i, j, E, w) {
        i ? this.element.animate({
            left: j
        }, E) : this.element.css("left", j);
        this.position = w
    };
    this.center = function (i, j) {
        i = typeof i != "undefined" ? i : true;
        j = typeof j != "undefined" ? j : "slow";
        move = $.browser.msie ? (this.width - document.documentElement.clientWidth) / 2 : (this.width - window.innerWidth) / 2;
        this._move(i, "-" + move.toString() + "px", j, 1)
    };
    this.left = function (i, j) {
        i = typeof i != "undefined" ? i : true;
        j = typeof j != "undefined" ? j : "slow";
        move = $.browser.msie ? (document.documentElement.clientWidth - this.grid_width) / 2 - this.offset : (window.innerWidth - this.grid_width) / 2 - this.offset;
        this._move(i, move.toString() + "px", j, 0)
    };
    this.right = function (i, j) {
        i = typeof i != "undefined" ? i : true;
        j = typeof j != "undefined" ? j : "slow";
        move = $.browser.msie ? (document.documentElement.clientWidth + this.grid_width) / 2 - this.offset : (window.innerWidth + this.grid_width) / 2 - this.offset;
        this._move(i, move.toString() + "px", j, 2)
    };
    this.reposition = function () {
        if (this.position == 0) this.left(false);
        else this.position == 2 ? this.right(false) : this.center(false)
    }
}
var slide_overview = {},
    slide_products = {},
    slide_services = {},
    slide_portfolio = {},
    slide_contact = {};
$(function () {
    slide_overview = new Slider(".overview", 1, 3017, 950, 353);
    slide_products = new Slider(".products", 1, 3017, 950, 2665);
    slide_services = new Slider(".services", 1, 3017, 950, 353);
    slide_portfolio = new Slider(".portfolio", 1, 3017, 950, 2715);
    slide_contact = new Slider(".contact", 1, 3017, 950, 353);
    slide_overview.center(false);
    slide_products.center(false);
    slide_services.center(false);
    slide_portfolio.center(false);
    slide_contact.center(false);
    $("a[rel='portfolio_signage']").colorbox();
    $("a[rel='portfolio_adverts']").colorbox();
    $("a[rel='portfolio_filming']").colorbox();
    $("a[rel='portfolio_web']").colorbox();
    $(window).resize(function () {
        slide_overview.reposition();
        slide_products.reposition();
        slide_services.reposition();
        slide_portfolio.reposition();
        slide_contact.reposition()
    });
    $(window).scroll(function () {
        if ($("body").scrollTop() > 50 || $("html").scrollTop() > 50) $.browser.msie ? $("header").css("background", "white") : $("header").css("background", "rgba(255, 255, 255, 0.9)");
        else $.browser.msie ? $("header").css("background", "none") : $("header").css("background", "rgba(255, 255, 255, 0.0)")
    })
});
var onPage = false,
    delay = function () {
        return onPage === true ? 800 : 0
    },
    doSlide = function () {
        return onPage === true ? true : false
    };
(function (d) {
    var o = function () {
            slide_overview.center();
            slide_products.center();
            slide_services.center();
            slide_portfolio.center()
        },
        h = d.sammy(function () {
            this.get("#!/overview/showcase/", function () {
                slide_overview.left(doSlide())
            });
            this.get("#!/products/", function () {
                d("a.link").removeClass("active");
                d("#products-link").addClass("active");
                d.scrollTo("#products", delay());
                o()
            });
            this.get("#!/products/showcase/", function () {
                slide_products.right(doSlide())
            });
            this.get("#!/portfolio/showcase/", function () {
                slide_portfolio.right(doSlide())
            });
            this.notFound = function () {
                location.href = "/404"
            }
        });

})(jQuery);
