;
(function (jQuery) {
    jQuery.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'], function (i, attr) {
        jQuery.fx.step[attr] = function (fx) {
            if (fx.state == 0) {
                fx.start = getColor(fx.elem, attr);
                fx.end = getRGB(fx.end);
            }
            fx.elem.style[attr] = "rgb(" + [Math.max(Math.min(parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0]), 255), 0), Math.max(Math.min(parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1]), 255), 0), Math.max(Math.min(parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2]), 255), 0)].join(",") + ")";
        }
    });

    function getRGB(color) {
        var result;
        if (color && color.constructor == Array && color.length == 3) return color;
        if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color)) return [parseInt(result[1]), parseInt(result[2]), parseInt(result[3])];
        if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color)) return [parseFloat(result[1]) * 2.55, parseFloat(result[2]) * 2.55, parseFloat(result[3]) * 2.55];
        if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color)) return [parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16)];
        if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color)) return [parseInt(result[1] + result[1], 16), parseInt(result[2] + result[2], 16), parseInt(result[3] + result[3], 16)];
        return colors[jQuery.trim(color).toLowerCase()];
    }

    function getColor(elem, attr) {
        var color;
        do {
            color = jQuery.curCSS(elem, attr);
            if (color != '' && color != 'transparent' || jQuery.nodeName(elem, "body")) break;
            attr = "backgroundColor";
        } while (elem = elem.parentNode);
        return getRGB(color);
    };
    var colors = {
        aqua: [0, 255, 255],
        azure: [240, 255, 255],
        beige: [245, 245, 220],
        black: [0, 0, 0],
        blue: [0, 0, 255],
        brown: [165, 42, 42],
        cyan: [0, 255, 255],
        darkblue: [0, 0, 139],
        darkcyan: [0, 139, 139],
        darkgrey: [169, 169, 169],
        darkgreen: [0, 100, 0],
        darkkhaki: [189, 183, 107],
        darkmagenta: [139, 0, 139],
        darkolivegreen: [85, 107, 47],
        darkorange: [255, 140, 0],
        darkorchid: [153, 50, 204],
        darkred: [139, 0, 0],
        darksalmon: [233, 150, 122],
        darkviolet: [148, 0, 211],
        fuchsia: [255, 0, 255],
        gold: [255, 215, 0],
        green: [0, 128, 0],
        indigo: [75, 0, 130],
        khaki: [240, 230, 140],
        lightblue: [173, 216, 230],
        lightcyan: [224, 255, 255],
        lightgreen: [144, 238, 144],
        lightgrey: [211, 211, 211],
        lightpink: [255, 182, 193],
        lightyellow: [255, 255, 224],
        lime: [0, 255, 0],
        magenta: [255, 0, 255],
        maroon: [128, 0, 0],
        navy: [0, 0, 128],
        olive: [128, 128, 0],
        orange: [255, 165, 0],
        pink: [255, 192, 203],
        purple: [128, 0, 128],
        violet: [128, 0, 128],
        red: [255, 0, 0],
        silver: [192, 192, 192],
        white: [255, 255, 255],
        yellow: [255, 255, 0]
    };
})(jQuery);;;
(function ($) {
    var counter = 0;
    $.fn.comments = function (blnDeep) {
        var blnDeep = (blnDeep || false);
        var jComments = $([]);
        this.each(function (intI, objNode) {
            var objChildNode = objNode.firstChild;
            var strParentID = $(this).attr("id");
            while (objChildNode) {
                if (objChildNode.nodeType === 8) {
                    var split = objChildNode.nodeValue.split("\n");
                    var type = split.shift();
                    if (type.indexOf("/") != -1) {
                        var comment = split.join("\n");
                        if (strParentID == "") {
                            strParentID = "commented-parent-" + counter++;
                        }
                        jComments = jComments.add("<div rel='" + strParentID + "'>" + comment + "</div>");
                    }
                } else if (blnDeep && (objChildNode.nodeType === 1)) {
                    jComments = jComments.add($(objChildNode).comments(true));
                }
                objChildNode = objChildNode.nextSibling;
            }
        });
        return (jComments);
    }
})(jQuery);;;
(function ($) {
    $.fn.shuffle = function () {
        var allElems = this.get(),
            getRandom = function (max) {
                return Math.floor(Math.random() * max);
            },
            shuffled = $.map(allElems, function () {
                var random = getRandom(allElems.length),
                    randEl = $(allElems[random]).clone(true)[0];
                allElems.splice(random, 1);
                return randEl;
            });
        this.each(function (i) {
            $(this).replaceWith($(shuffled[i]));
        });
        return $(shuffled);
    };
})(jQuery);;;
(function ($, window) {
    '$:nomunge';
    var undefined, loc = window.location,
        aps = Array.prototype.slice,
        decode = decodeURIComponent,
        jq_param = $.param,
        jq_param_fragment, jq_deparam, jq_deparam_fragment, jq_bbq = $.bbq = $.bbq || {},
        jq_bbq_pushState, jq_bbq_getState, jq_elemUrlAttr, jq_event_special = $.event.special,
        str_hashchange = 'hashchange',
        str_querystring = 'querystring',
        str_fragment = 'fragment',
        str_elemUrlAttr = 'elemUrlAttr',
        str_href = 'href',
        str_src = 'src',
        re_trim_querystring = /^.*\?|#.*$/g,
        re_trim_fragment = /^.*\#/,
        elemUrlAttr_cache = {};

    function is_string(arg) {
        return typeof arg === 'string';
    };

    function curry(func) {
        var args = aps.call(arguments, 1);
        return function () {
            return func.apply(this, args.concat(aps.call(arguments)));
        };
    };

    function get_fragment(url) {
        return url.replace(/^[^#]*#?(.*)$/, '$1');
    };

    function get_querystring(url) {
        return url.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/, '$1');
    };

    function jq_param_sub(is_fragment, get_func, url, params, merge_mode) {
        var result, qs, matches, url_params, hash;
        if (params !== undefined) {
            matches = url.match(is_fragment ? /^([^#]*)\#?(.*)$/ : /^([^#?]*)\??([^#]*)(#?.*)/);
            hash = matches[3] || '';
            if (merge_mode === 2 && is_string(params)) {
                qs = params.replace(is_fragment ? re_trim_fragment : re_trim_querystring, '');
            } else {
                url_params = jq_deparam(matches[2]);
                params = is_string(params) ? jq_deparam[is_fragment ? str_fragment : str_querystring](params) : params;
                qs = merge_mode === 2 ? params : merge_mode === 1 ? $.extend({}, params, url_params) : $.extend({}, url_params, params);
                qs = jq_param(qs);
            }
            result = matches[1] + (is_fragment ? '#' : qs || !matches[1] ? '?' : '') + qs + hash;
        } else {
            result = get_func(url !== undefined ? url : loc[str_href]);
        }
        return result;
    };
    jq_param[str_querystring] = curry(jq_param_sub, 0, get_querystring);
    jq_param[str_fragment] = jq_param_fragment = curry(jq_param_sub, 1, get_fragment);
    $.deparam = jq_deparam = function (params, coerce) {
        var obj = {},
            coerce_types = {
                'true': !0,
                'false': !1,
                'null': null
            };
        $.each(params.replace(/\+/g, ' ').split('&'), function (j, v) {
            var param = v.split('='),
                key = decode(param[0]),
                val, cur = obj,
                i = 0,
                keys = key.split(']['),
                keys_last = keys.length - 1;
            if (/\[/.test(keys[0]) && /\]$/.test(keys[keys_last])) {
                keys[keys_last] = keys[keys_last].replace(/\]$/, '');
                keys = keys.shift().split('[').concat(keys);
                keys_last = keys.length - 1;
            } else {
                keys_last = 0;
            }
            if (param.length === 2) {
                val = decode(param[1]);
                if (coerce) {
                    val = val && !isNaN(val) ? +val : val === 'undefined' ? undefined : coerce_types[val] !== undefined ? coerce_types[val] : val;
                }
                if (keys_last) {
                    for (; i <= keys_last; i++) {
                        key = keys[i] === '' ? cur.length : keys[i];
                        cur = cur[key] = i < keys_last ? cur[key] || (keys[i + 1] && isNaN(keys[i + 1]) ? {} : []) : val;
                    }
                } else {
                    if ($.isArray(obj[key])) {
                        obj[key].push(val);
                    } else if (obj[key] !== undefined) {
                        obj[key] = [obj[key], val];
                    } else {
                        obj[key] = val;
                    }
                }
            } else if (key) {
                obj[key] = coerce ? undefined : '';
            }
        });
        return obj;
    };

    function jq_deparam_sub(is_fragment, url_or_params, coerce) {
        if (url_or_params === undefined || typeof url_or_params === 'boolean') {
            coerce = url_or_params;
            url_or_params = jq_param[is_fragment ? str_fragment : str_querystring]();
        } else {
            url_or_params = is_string(url_or_params) ? url_or_params.replace(is_fragment ? re_trim_fragment : re_trim_querystring, '') : url_or_params;
        }
        return jq_deparam(url_or_params, coerce);
    };
    jq_deparam[str_querystring] = curry(jq_deparam_sub, 0);
    jq_deparam[str_fragment] = jq_deparam_fragment = curry(jq_deparam_sub, 1);
    $[str_elemUrlAttr] || ($[str_elemUrlAttr] = function (obj) {
        return $.extend(elemUrlAttr_cache, obj);
    })({
        a: str_href,
        base: str_href,
        iframe: str_src,
        img: str_src,
        input: str_src,
        form: 'action',
        link: str_href,
        script: str_src
    });
    jq_elemUrlAttr = $[str_elemUrlAttr];

    function jq_fn_sub(mode, force_attr, params, merge_mode) {
        if (!is_string(params) && typeof params !== 'object') {
            merge_mode = params;
            params = force_attr;
            force_attr = undefined;
        }
        return this.each(function () {
            var that = $(this),
                attr = force_attr || jq_elemUrlAttr()[(this.nodeName || '').toLowerCase()] || '',
                url = attr && that.attr(attr) || '';
            that.attr(attr, jq_param[mode](url, params, merge_mode));
        });
    };
    $.fn[str_querystring] = curry(jq_fn_sub, str_querystring);
    $.fn[str_fragment] = curry(jq_fn_sub, str_fragment);
    jq_bbq.pushState = jq_bbq_pushState = function (params, merge_mode) {
        if (is_string(params) && /^#/.test(params) && merge_mode === undefined) {
            merge_mode = 2;
        }
        var has_args = params !== undefined,
            url = jq_param_fragment(loc[str_href], has_args ? params : {}, has_args ? merge_mode : 2);
        loc[str_href] = url + (/#/.test(url) ? '' : '#');
    };
    jq_bbq.getState = jq_bbq_getState = function (key, coerce) {
        return key === undefined || typeof key === 'boolean' ? jq_deparam_fragment(key) : jq_deparam_fragment(coerce)[key];
    };
    jq_bbq.removeState = function (arr) {
        var state = {};
        if (arr !== undefined) {
            state = jq_bbq_getState();
            $.each($.isArray(arr) ? arr : arguments, function (i, v) {
                delete state[v];
            });
        }
        jq_bbq_pushState(state, 2);
    };
    jq_event_special[str_hashchange] = $.extend(jq_event_special[str_hashchange], {
        add: function (handler, data, namespaces) {
            return function (e) {
                var hash = e[str_fragment] = jq_param_fragment();
                e.getState = function (key, coerce) {
                    return key === undefined || typeof key === 'boolean' ? jq_deparam(hash, key) : jq_deparam(hash, coerce)[key];
                };
                handler.apply(this, arguments);
            };
        }
    });
})(jQuery, this);
(function ($, window, undefined) {
    '$:nomunge';
    var loc = window.location,
        fake_onhashchange, jq_event_special = $.event.special,
        str_hashchange = 'hashchange',
        browser = $.browser,
        mode = document.documentMode,
        is_old_ie = browser.msie && (mode === undefined || mode < 8),
        supports_onhashchange = 'on' + str_hashchange in window && !is_old_ie;

    function get_fragment(url) {
        url = url || loc.href;
        return url.replace(/^[^#]*#?(.*)$/, '$1');
    };
    $[str_hashchange + 'Delay'] = 100;
    jq_event_special[str_hashchange] = $.extend(jq_event_special[str_hashchange], {
        setup: function () {
            if (supports_onhashchange) {
                return false;
            }
            fake_onhashchange.start();
        },
        teardown: function () {
            if (supports_onhashchange) {
                return false;
            }
            fake_onhashchange.stop();
        }
    });
    fake_onhashchange = (function () {
        var self = {},
            timeout_id, iframe, set_history, get_history;

        function init() {
            set_history = get_history = function (val) {
                return val;
            };
            if (is_old_ie) {
                iframe = $('<iframe src="javascript:0"/>').hide().prependTo('body')[0].contentWindow;
                get_history = function () {
                    return get_fragment(iframe.document.location.href);
                };
                set_history = function (hash, history_hash) {
                    if (hash !== history_hash) {
                        var doc = iframe.document;
                        doc.open().close();
                        doc.location.hash = '#' + hash;
                    }
                };
                set_history(get_fragment());
            }
        };
        self.start = function () {
            if (timeout_id) {
                return;
            }
            var last_hash = get_fragment();
            set_history || init();
            (function loopy() {
                var hash = get_fragment(),
                    history_hash = get_history(last_hash);
                if (hash !== last_hash) {
                    set_history(last_hash = hash, history_hash);
                    $(window).trigger(str_hashchange);
                } else if (history_hash !== last_hash) {
                    loc.href = loc.href.replace(/#.*/, '') + '#' + history_hash;
                }
                timeout_id = setTimeout(loopy, $[str_hashchange + 'Delay']);
            })();
        };
        self.stop = function () {
            if (!iframe) {
                timeout_id && clearTimeout(timeout_id);
                timeout_id = 0;
            }
        };
        return self;
    })();
})(jQuery, this);;;
(function (window, undefined) {
    '$:nomunge';
    var $ = window.jQuery || window.Cowboy || (window.Cowboy = {}),
        jq_getObject;
    $.getObject = jq_getObject = function (parts, create, obj) {
        if (typeof parts === 'string') {
            parts = parts.split('.');
        }
        if (typeof create !== 'boolean') {
            obj = create;
            create = undefined;
        }
        obj = obj || window;
        var p;
        while (obj && parts.length) {
            p = parts.shift();
            if (obj[p] === undefined && create) {
                obj[p] = {};
            }
            obj = obj[p];
        }
        return obj;
    };
    $.setObject = function (name, value, context) {
        var parts = name.split('.'),
            prop = parts.pop(),
            obj = jq_getObject(parts, true, context);
        return obj && typeof obj === 'object' && prop ? (obj[prop] = value) : undefined;
    };
    $.exists = function (name, context) {
        return jq_getObject(name, context) !== undefined;
    };
})(this);;;
(function ($) {
    '$:nomunge';
    var undefined, TRUE = !0,
        FALSE = !1,
        loc = window.location,
        aps = Array.prototype.slice,
        matches = loc.href.match(/^((https?:\/\/.*?\/)?[^#]*)#?.*$/),
        loc_fragbase = matches[1] + '#',
        loc_hostbase = matches[2],
        jq_elemUrlAttr, jq_urlInternalHost, jq_urlInternalRegExp, jq_isUrlInternal, jq_isUrlExternal, jq_isUrlFragment, str_elemUrlAttr = 'elemUrlAttr',
        str_href = 'href',
        str_src = 'src',
        str_urlInternal = 'urlInternal',
        str_urlExternal = 'urlExternal',
        str_urlFragment = 'urlFragment',
        url_regexp, elemUrlAttr_cache = {};

    function curry(func) {
        var args = aps.call(arguments, 1);
        return function () {
            return func.apply(this, args.concat(aps.call(arguments)));
        };
    };
    $.isUrlInternal = jq_isUrlInternal = function (url) {
        if (!url || jq_isUrlFragment(url)) {
            return undefined;
        }
        if (url_regexp.test(url)) {
            return TRUE;
        }
        if (/^(?:https?:)?\/\//i.test(url)) {
            return FALSE;
        }
        if (/^[a-z\d.-]+:/i.test(url)) {
            return undefined;
        }
        return TRUE;
    };
    $.isUrlExternal = jq_isUrlExternal = function (url) {
        var result = jq_isUrlInternal(url);
        return typeof result === 'boolean' ? !result : result;
    };
    $.isUrlFragment = jq_isUrlFragment = function (url) {
        var matches = (url || '').match(/^([^#]?)([^#]*#).*$/);
        return !!matches && (matches[2] === '#' || url.indexOf(loc_fragbase) === 0 || (matches[1] === '/' ? loc_hostbase + matches[2] === loc_fragbase : !/^https?:\/\//i.test(url) && $('<a href="' + url + '"/>')[0].href.indexOf(loc_fragbase) === 0));
    };

    function fn_filter(str, attr) {
        return this.filter(':' + str + (attr ? '(' + attr + ')' : ''));
    };
    $.fn[str_urlInternal] = curry(fn_filter, str_urlInternal);
    $.fn[str_urlExternal] = curry(fn_filter, str_urlExternal);
    $.fn[str_urlFragment] = curry(fn_filter, str_urlFragment);

    function fn_selector(func, elem, i, match) {
        var a = match[3] || jq_elemUrlAttr()[(elem.nodeName || '').toLowerCase()] || '';
        return a ? !! func(elem.getAttribute(a)) : FALSE;
    };
    $.expr[':'][str_urlInternal] = curry(fn_selector, jq_isUrlInternal);
    $.expr[':'][str_urlExternal] = curry(fn_selector, jq_isUrlExternal);
    $.expr[':'][str_urlFragment] = curry(fn_selector, jq_isUrlFragment);
    $[str_elemUrlAttr] || ($[str_elemUrlAttr] = function (obj) {
        return $.extend(elemUrlAttr_cache, obj);
    })({
        a: str_href,
        base: str_href,
        iframe: str_src,
        img: str_src,
        input: str_src,
        form: 'action',
        link: str_href,
        script: str_src
    });
    jq_elemUrlAttr = $[str_elemUrlAttr];
    $.urlInternalHost = jq_urlInternalHost = function (alt_hostname) {
        alt_hostname = alt_hostname ? '(?:(?:' + Array.prototype.join.call(arguments, '|') + ')\\.)?' : '';
        var re = new RegExp('^' + alt_hostname + '(.*)', 'i'),
            pattern = '^(?:' + loc.protocol + ')?//' + loc.hostname.replace(re, alt_hostname + '$1').replace(/\\?\./g, '\\.') + (loc.port ? ':' + loc.port : '') + '/';
        return jq_urlInternalRegExp(pattern);
    };
    $.urlInternalRegExp = jq_urlInternalRegExp = function (re) {
        if (re) {
            url_regexp = typeof re === 'string' ? new RegExp(re, 'i') : re;
        }
        return url_regexp;
    };
    jq_urlInternalHost('www');
})(jQuery);;;
(function ($) {
    var plugins = new Array();
    $.extend({
        create: function (classpath) {
            return function () {
                return plugins[classpath].apply(this, arguments);
            }
        },
        UIClass: function (classpath, extnds) {
            var superClass, cls;
            cls = $.setObject(classpath, function ($this, settings) {
                var args = $.makeArray(arguments);
                this.$ = args.shift();
                var o = this;
                this.init.apply(this, args);
            }, $);
            plugins[classpath] = function (settings) {
                if (typeof (settings) == "string") {
                    var args = $.makeArray(arguments);
                    var method = args.shift();
                    return this.each(function (i) {
                        var cls = $(this).data(classpath);
                        if (cls != null) {
                            cls[method].apply(cls, args);
                        }
                    });
                } else {
                    return this.each(function (i) {
                        var $this = $(this);
                        $this.data(classpath, new cls($this, settings));
                    });
                }
            };
            if (extnds != null) {
                if ($.isFunction(extnds)) {
                    superClass = extnds;
                } else {
                    superClass = $.getObject(extnds, $)
                }
                cls.prototype = new superClass();
            }
            cls.prototype.toString = function () {
                return "[object " + classpath + "]";
            }
            return cls.prototype;
        }
    });
    $.extend($.UIClass, {
        destroy: function () {}
    });
})(jQuery);;;
(function ($) {
    var qn = "net.code28.net.AjaxNavigation";
    var dirty = "hashdirty";
    var clean = "hashclean";
    $.event.special[dirty] = {
        setup: function () {},
        teardown: function () {},
        _default: function (e) {
            if (!e.isDefaultPrevented()) {
                $(window).trigger(clean);
            }
        }
    };
    $.event.special[clean] = {
        setup: function () {},
        teardown: function () {}
    };
    $.extend($.UIClass(qn), {
        init: function (ready) {
            this._ready = ready;
            $(this._ready);
            var o = this;
            this.$.bind("hashclean." + qn, $.proxy(this, "_hashClean")).bind("hashchange." + qn, $.proxy(this, "_hashChange")).trigger("hashchange." + qn);
            var $links = $("a:urlInternal:not([rel^=lightbox]):not([target^=_blank])");
            $links.live("click", $.proxy(this, "_click"));
        },
        _click: function (e) {
            e.preventDefault();
            var href = $(e.currentTarget).attr("href").replace(/http:\/\/[^\/]+/i, "");
            if (href == "./" || href == null) {
                href = "";
            }
            if (href.charAt(0) == "/") {
                href = href.substr(1);
            }
            $.bbq.pushState("#/" + href);
        },
        _hashChange: function (e) {
            var fragment = $.param.fragment()
            if (fragment != "" && fragment != null) {
                $.ajax({
                    url: fragment,
                    complete: $.proxy(this, "_complete")
                });
            }
        },
        _complete: function (res, status) {
            if (status === "success" || status === "notmodified") {
                var txt = res.responseText.replace(/<script(.|\s)*?\/script>/gi, "");
                var $html = this.$html = $("<div />").append(txt.replace("<body", "<div").replace("</body>", "</div>"));
                $(window).trigger(dirty);
            } else {
                location.href = $.param.fragment();
            }
        },
        _hashClean: function (e) {
            var $_body = this.$html.find("#body").html();
            var body = this.$html.find(">div");
            if (body.length < 1) {
                location.href = $.param.fragment();
            }
            var cls = body.attr("class").replace(/no-js/, 'js');
            var id = this.$html.find(">div").attr("id");
            var o = this;
            $("#body").html($_body);
            $("body").attr("id", id);
            $("body").attr("class", cls);
            $(window).scrollTop(0);
            $.proxy(this._ready)();
        }
    });
})(jQuery);;;
(function ($) {
    var qn = "net.code28.projects.everywhere.MainMenu";
    $.extend($.UIClass(qn), {
        init: function () {
            this.$.css({
                position: "relative"
            });
            this.$.prepend('<div id="menu-icon" />');
            this.$icon = $("#menu-icon", this.$)
            this.$icon.css({
                backgroundImage: "url(/images/icons/yellow-arrow-up-24.png)",
                backgroundPosition: "0 2px",
                backgroundRepeat: "no-repeat",
                position: "absolute",
                top: 0,
                left: 0,
                width: 16,
                height: 12
            });
            var o = this;
            $a = $("a", this.$).bind("mousedown." + qn, $.proxy(this, "_click")).bind("click." + qn, $.proxy(this, "_clean")).bind("mouseleave." + qn, function () {
                o.$icon.css({
                    opacity: 1
                });
            });
            $(window).bind("hashclean." + qn, $.proxy(this, "_clean"));
            $("li", this.$).css({
                backgroundImage: "none"
            });
        },
        _click: function (e) {
            this.$icon.css({
                opacity: .1
            });
        },
        _clean: function (e) {
            var $a;
            if (e.type == "click") {
                $a = $(e.currentTarget);
            } else {
                var id = $("body").attr("id");
                switch (id) {
                case "page-news":
                    $a = $(".news a", this.$);
                    break;
                case "page-about-us":
                    $a = $(".about-us a", this.$);
                    break;
                case "page-contact":
                    $a = $(".contact a", this.$);
                    break;
                case "page-index":
                    $a = $(".news a", this.$);
                    break;
                default:
                    $a = $(".work a", this.$);
                }
            }
            this.$icon.animate({
                top: $a.position().top,
                opacity: 1
            }, {
                duration: 300
            });
        }
    });
})(jQuery);;;
(function ($) {
    var qn = "net.code28.projects.everywhere.DropMenu";
    $.extend($.UIClass(qn), {
        init: function (firstIsTitle) {
            this.firstIsTitle = firstIsTitle || false;
            $("div", this.$).bind("mouseenter." + qn, $.proxy(this, "open"));
            $("div", this.$).bind("mouseleave." + qn, $.proxy(this, "close"));
            $("a", this.$).bind("click." + qn, $.proxy(this, "select"));
        },
        check: function () {
            if (this.$.css("display") == "none") {
                return;
            }
            var id = $("body").attr("id");
            var page = id.substr(id.indexOf("-") + 1);
            var $a = $(".selected a", this.$);
            if ($a.attr("href").indexOf(page + ".html") == -1) {
                var $old = $a.parent();
                $old.removeClass("selected").css({
                    display: "none"
                });
                var $li = $("a[href$=" + page + ".html]", this.$).parent();
                $li.css({
                    display: "block"
                }).addClass("selected");
                $li.detach();
                $("ul", this.$).prepend($li);
            }
        },
        open: function () {
            if (this.height == null) {
                this.height = this.$.height();
            }
            var $subs = $("li:not(.selected)", this.$);
            $subs.stop().css({
                display: "block",
                opacity: 0
            });
            var newH = $("ul", this.$).height();
            var o = this;
            $("div", this.$).css({
                height: this.height
            }).animate({
                height: newH
            }, {
                duration: 200,
                complete: function () {
                    o.$.css({
                        height: o.height
                    })
                }
            });
            $subs.delay(100).each(function (i) {
                $(this).delay(i * 50).animate({
                    opacity: 1
                }, {
                    duration: 100
                });
            });
            var $li = $("li", this.$);
            var len = $li.length - 1;
            var b = -(len * $li.height());
            this.$.css({
                bottom: b
            });
        },
        close: function () {
            $("li:not(.selected)", this.$).stop().css({
                display: "none"
            });
            $("div", this.$).stop().animate({
                height: this.height
            }, {
                duration: 300
            });
        },
        select: function (e) {
            var $a = $(event.currentTarget);
            var $li = $a.parent();
            var $ul = $li.parent();
            if ($li.hasClass("selected")) {
                return this.open();
            }
            if (!this.firstIsTitle) {
                $(".selected", this.$).removeClass("selected");
                $li.addClass("selected");
                $li.detach();
                $ul.prepend($li);
            }
            this.close();
        }
    });
})(jQuery);;;
(function ($) {
    var qn = "net.code28.projects.everywhere.Slideshow";
    $.extend($.UIClass(qn), {
        init: function (pause) {
            this.pause = pause || 5000;
            if (this.$.hasClass("random")) {
                $("ul li", this.$).shuffle();
                $("ul li", this.$).removeClass("first").removeClass("last");
                $("ul li:eq(0)", this.$).addClass("first");
            }
            this.$ul = $("ul", this.$);
            var $header = $(".header", this.$);
            var $currentProjects = this.$.closest(".current-projects");
            var o = this;
            if ($header.length > 0) {
                if ($currentProjects.length > 0) {
                    this.$.css({
                        cursor: "pointer"
                    });
                    var $img = $("img", this.$ul).eq(0);
                    var w = ($img.width() / 2) - ($header.width() / 2);
                    var h = ($img.height() / 2) - ($header.height() / 2);
                    var $h2 = $("h2", $header);
                    $header.css({
                        left: w,
                        top: h,
                        marginTop: 0,
                        display: "none"
                    });
                    this.$.bind("mouseenter", function () {
                        $header.css({
                            display: "none"
                        }).fadeIn();
                        $img.stop().animate({
                            opacity: .3
                        });
                    });
                    this.$.bind("mouseleave", function () {
                        $header.css({
                            display: "block"
                        }).fadeOut();
                        $img.stop().animate({
                            opacity: 1
                        });
                    });
                    this.$ul.add($h2).bind("click", function () {
                        var href = $("a:first", $h2.parent()).attr("href").replace(/http:\/\/[^\/]+/i, "");
                        if (href.charAt(0) == "/") {
                            href = href.substr(1);
                        }
                        location.href = "#/" + href;
                    });
                }
            }
            if ($("li", this.$ul).length > 1) {}
        },
        start: function () {
            if ($("li", this.$ul).length > 1) {
                clearInterval(this.t);
                this.t = setTimeout($.proxy(this, "autoChange"), this.pause);
            }
        },
        next: function (reset) {
            if (reset) {
                this.start();
            }
            var $next = $("li:eq(1) img", this.$ul);
            if ($next[0].complete) {
                var top = $("li:eq(0)", this.$ul).detach();
                this.$ul.append(top);
                $("li:eq(0)", this.$ul).fadeIn(function () {
                    top.css({
                        display: "none",
                        position: "absolute"
                    });
                    $(this).css({
                        position: "static"
                    });
                });
            }
        },
        previous: function (reset) {
            if (reset) {
                this.start();
            }
            var $next = $("li:last img", this.$ul);
            if ($next[0].complete) {
                var top = $("li:eq(0)", this.$ul);
                var $last = $("li:last", this.$ul).detach();
                $last.parent().css({
                    display: "none",
                    position: "absolute"
                });
                this.$ul.prepend($last);
                $last.fadeIn(function () {
                    top.css({
                        position: "absolute",
                        display: "none"
                    });
                    $(this).css({
                        position: "static"
                    });
                });
            }
        },
        change: function ($next) {},
        autoChange: function () {
            this.next(false);
            this.start();
        },
        destroy: function () {
            this.$.removeData(qn);
            clearInterval(this.t);
        }
    });
})(jQuery);;;
(function ($) {
    var qn = "net.code28.projects.everywhere.ProjectList";
    $.fn.extend({
        toCanvas: function () {
            return this.each(function () {
                var $this = $(this);
                var $canvas = $("<canvas />");
                var ctx = $canvas.get(0).getContext("2d");
                var img = new Image();
                img.src = $this.attr("src");
                $canvas.attr({
                    width: $this.attr("width"),
                    height: $this.attr("height")
                });
                $this.parent().append($canvas);
                img.onload = function () {
                    ctx.drawImage(img, 0, 0);
                    $canvas.trigger("load");
                };
            });
        },
        grayscaleCanvas: function () {
            return this.each(function () {
                var ctx = this.getContext("2d");
                var width = this.width;
                var height = this.height;
                var data = ctx.getImageData(0, 0, width, height);
                var grayscale = function (r, g, b) {
                        return parseInt((0.2125 * r) + (0.7154 * g) + (0.0721 * b), 10);
                    };
                for (var y = 0; y < height; y++) {
                    for (var x = 0; x < width; x++) {
                        var i = (y * width + x) * 4;
                        data.data[i] = data.data[i + 1] = data.data[i + 2] = grayscale(data.data[i], data.data[i + 1], data.data[i + 2]);
                    }
                }
                ctx.putImageData(data, 0, 0, 0, 0, width, height);
            });
        },
        grayscale: function () {
            return this.each(function () {
                var $this = $(this);
                if (document.createElement('canvas').getContext) {
                    $("canvas", $this.toCanvas().parent()).bind("load", function () {
                        $(this).grayscaleCanvas();
                        $this.attr("src", this.toDataURL());
                        $(this).remove();
                    });
                } else {
                    this.style.filter += "progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)";
                    this.style.zoom = 1;
                }
            });
        }
    });
    $.extend($.UIClass(qn), {
        init: function () {
            this.$li = $("li", this.$);
            this.$.css({
                display: "block"
            });
            var $a = $("a", this.$li);
            $("h3", this.$li).each(function (i) {
                var $img = $("img", this);
                $(this).css({
                    width: $img.width() + 20,
                    paddingRight: 20
                });
                $img.css({
                    marginLeft: 20
                });
            });
            this.$li.css({
                display: "none"
            });
            this.$.css({
                display: "block"
            });
            this.$li.css({
                position: "relative",
                width: 232,
                height: 143
            });
            $("h3", this.$li).css({
                position: "relative",
                zIndex: 1000,
                display: "none",
                opacity: 0
            });
            $("img", $a).each(function () {
                var $this = $(this);
                $this.parent().append($this.clone());
                $this.css({
                    opacity: 0.1
                }).grayscale().addClass("grayscaled");
            });
            $("img", $a).css({
                position: "absolute",
                top: 0,
                left: 0,
                zIndex: 2
            });
            $("img:not(.grayscaled)", $a).css({
                display: "none",
                zIndex: 1,
                opacity: 0.2
            })
            this.$li.bind("mouseenter", function () {
                $("a img:not(.grayscaled)", this).css({
                    opacity: .2
                }).fadeIn(300);
                $("h3", this).css({
                    display: "block",
                    opacity: 0
                }).delay(200).stop().animate({
                    opacity: 0.99
                }, {
                    duration: 500
                });
            }).bind("mouseleave", function () {
                $("a img:not(.grayscaled), h3", this).stop().delay(100).fadeOut();
            }).bind("click", function (e) {
                if (e.currentTarget.nodeName.toLowerCase() != "a") {
                    var href = $("a:first", this).attr("href").replace(/http:\/\/[^\/]+/i, "");
                    if (href.charAt(0) == "/") {
                        href = href.substr(1);
                    }
                    location.href = "#/" + href;
                }
            });
            this.transitionIn({});
        },
        transitionIn: function (e) {
            this.$li.each(function (i) {
                $(this).delay(i * 150).fadeIn();
            });
        }
    });
})(jQuery);;;
(function ($) {
    var qn = "net.code28.projects.everywhere.NewsTeaser";
    $.extend($.UIClass(qn), {
        init: function () {
            this.shouldFade = ($("#footer").css("position") == "fixed");
            this.$textWrapper = $(".text-wrapper", this.$);
            this.$content = $(".header, .body", this.$textWrapper);
            var h = parseInt(this.$.height());
            this.$textWrapper.css({
                height: h
            });
            if (this.shouldFade) {
                this.$.css({
                    opacity: 0.05
                })
            }
            this.$imageWrapper = $(".image-wrapper", this.$);
            this.$imageWrapper.css({
                height: h
            });
            var $img = $("img", this.$imageWrapper);
            $img.css({
                display: "none"
            });
            if ($img.get(0).complete) {
                $img.fadeIn();
            } else {
                $img.bind("load", function () {
                    $img.fadeIn();
                });
            }
        },
        scroll: function (topMargin, scrollTop, windowHeight) {
            if (this.shouldFade) {
                var y = Math.abs(this.$.position().top - scrollTop - topMargin);
                var opacity = 1.1 - (y * 0.005);
                opacity = Math.max(0.05, Math.min(opacity, 1));
                this.$.css({
                    opacity: opacity
                });
            }
        }
    });
})(jQuery);;;
(function ($) {
    $.fn.extend({
        newsTeasers: $.create("net.code28.projects.everywhere.NewsTeaser")
    });
    var qn = "net.code28.projects.everywhere.NewsList";
    $.extend($.UIClass(qn), {
        init: function () {
            this.$.css({
                display: "block"
            });
            this.$teasers = $(".article", this.$).newsTeasers();
            this.$window = $(window);
            if (this.$teasers.length > 0) {
                this.$lastArticle = $(".article:last", this.$);
                this.topMargin = parseInt($("#body").css("padding-top"));
                this.$window.bind("hashdirty." + qn, $.proxy(this, "transitionOut")).bind("scroll." + qn, $.proxy(this, "scroll")).bind("resize." + qn, $.proxy(this, "resize")).trigger("scroll." + qn).trigger("resize." + qn);
                $("img", this.$teasers).bind("click", $.proxy(this, "jump"));
            }
            this.transitionIn({});
        },
        transitionIn: function (e) {
            this.$.css({
                display: "none"
            }).fadeIn();
        },
        transitionOut: function (e) {
            e.preventDefault();
            this.$.css({
                display: "block"
            }).fadeOut($.proxy(this, "destroy"));
        },
        scroll: function (e) {
            var scrollTop = $(document).scrollTop();
            var windowHeight = this.$window.height();
            this.$teasers.newsTeasers("scroll", this.topMargin, scrollTop, windowHeight);
        },
        jump: function (e) {
            var $closest = $(e.currentTarget);
            $("html, body").animate({
                scrollTop: $closest.offset().top - this.topMargin
            });
        },
        resize: function (e) {
            var padding = this.$window.height() - this.topMargin - this.$lastArticle.height() - 50;
            this.$.css({
                paddingBottom: padding + "px"
            });
        },
        destroy: function () {
            this.$window.unbind("." + qn);
            this.$window.trigger("hashclean");
        }
    });
})(jQuery);;;
(function ($) {
    var qn = "net.code28.projects.everywhere.CaseStudy";
    $.extend($.UIClass(qn), {
        init: function () {
            var comment = this.$.comments(true)
            if (comment.length > 0) {
                var html = $(".slideshow", comment).add($(".slideshow", this.$)).shuffle().eq(0);
                $(".article>.header", this.$).empty().append(html);
            }
            this.$slideshow = $(".slideshow", this.$).slideshow();
            $(window).bind("hashdirty." + qn, $.proxy(this, "transitionOut"));
            this.$slideshow.css({
                display: "none"
            });
            $(".article .header h2", this.$).css({
                opacity: 0
            });
            $(".image-3-columns .body", this.$).css({
                opacity: 0
            });
            var $first = $("li:eq(0) img", this.$slideshow);
            if ($first[0].complete) {
                this.transitionIn({});
            } else {
                $first.bind("load", $.proxy(this, "transitionIn"));
            }
        },
        transitionIn: function (e) {
            var o = this;
            this.$slideshow.fadeIn(function () {
                o.$slideshow.slideshow("start");
                $(".project-list", o.$).projectList();
            });
            $(".article .header h2", this.$).delay(100).animate({
                opacity: 1
            });
            $(".image-3-columns .body", this.$).delay(200).animate({
                opacity: 1
            });
        },
        transitionOut: function (e) {
            this.$slideshow.slideshow("destroy");
        }
    });
})(jQuery);;
jQuery(function () {
    $.fn.extend({
        slideshow: $.create("net.code28.projects.everywhere.Slideshow"),
        newsList: $.create("net.code28.projects.everywhere.NewsList"),
        caseStudy: $.create("net.code28.projects.everywhere.CaseStudy"),
        projectList: $.create("net.code28.projects.everywhere.ProjectList"),
        dropMenu: $.create("net.code28.projects.everywhere.DropMenu"),
        mainMenu: $.create("net.code28.projects.everywhere.MainMenu"),
        navigateUsingAjax: $.create("net.code28.net.AjaxNavigation")
    });
    (function ($) {
	
		var handheld = false;
		
		if ($(window).width() <= 480) {
			handheld = true;
		}
	
        $("#header,#body,#footer").css({
            display: "none"
        });
        $("#wrapper").css({
            display: "block"
        });
        var done = false;
        $("html,body").css({
            height: "100%",
            backgroundColor: "#FFFFFF"
        }).animate({
            backgroundColor: "#0a0a0a"
        }, {
            complete: function () {
                if (done) {
                    return;
                }
                done = true;
                $("html,body").css({
                    backgroundColor: "#0a0a0a"
                });
                $("#header,#footer").fadeIn();
                if ($.param.fragment() == "") {
                    $("#body").fadeIn();
                } else {
                    $(window).one("hashclean", function () {
                        $("#body").fadeIn();
                    });
                }
                $(window).navigateUsingAjax(function () {
                    $(".news-list").show();
					

					if(handheld){
                    
						$(".case-study, .info-page, .current-projects").show();
                    	$(".archived-projects .project-list").show();
					
					} else {
					
						newsListMasonry();
						$(".case-study, .info-page, .current-projects").caseStudy();
                        $(".archived-projects .project-list").projectList();
					
					}

                    $("#category-menu").dropMenu("check");
                    $(".type-text").each(function () {
                        var $span = $("span", this);
                        var $input = $("input", this);
                        var label = $span.text();
                        $input.val(label)
                        $input.data("defaultValue", $input.attr('value'));
                        $input.focus(function () {
                            if ($input.attr('value') == $input.data("defaultValue")) {
                                $input.val("");
                            }
                            $input.select();
                        });
                        $input.blur(function () {
                            if ($input.val() == '') {
                                $input.val($input.data("defaultValue"));
                            }
                        });
                        $span.remove();
                    });
                    $("a[href$=#join]").bind("click", function (e) {
                        e.preventDefault();
                        $("#thankyou").slideUp(300);
                        $("#join").delay(400).slideDown();
                        $("input", $("#join")).each(function () {
                            var $input = $(this);
                            $input.val($input.data("defaultValue"));
                        });
                    });
                    $("form").bind("submit", function (e) {
                        e.preventDefault();
                        var error = false;
                        $("input").each(function () {
                            var $input = $(this);
                            if ($input.attr('value') == $input.data("defaultValue")) {
                                $input.parent().addClass("error");
                                error = true;
                            } else {
                                $input.parent().removeClass("error");
                            }
                        });
                        var $email = $("#email input");
                        var val = $email.val();
                        if (val.indexOf("@") == -1) {
                            $email.parent().addClass("error");
                            error = true;
                        } else if (val.indexOf(".") == -1) {
                            $email.parent().addClass("error");
                            error = true;
                        } else {
                            $email.parent().removeClass("error");
                        }
                        if (!error) {
                            var data = {};
                            var $name = $("#name input", this);
                            data[$name.attr("name")] = $name.val();
                            data[$email.attr("name")] = $email.val();
                            $.post($(this).attr("action"), data);
                            $("#join").slideUp(300);
                            $("#thankyou").delay(400).slideDown();
                        }
                    });
					if(handheld) {
						load_mobile_init();
					}
                });
                $("#main-menu").mainMenu();
            }
        });
        $("#category-menu").dropMenu();
        $(".project-menu").dropMenu(true);
    })(jQuery.noConflict());
});
