(function (b, j) {
    if (b.cleanData) {
        var k = b.cleanData;
        b.cleanData = function (a) {
            for (var c = 0, d;
            (d = a[c]) != null; c++) b(d).triggerHandler("remove");
            k(a)
        }
    } else {
        var l = b.fn.remove;
        b.fn.remove = function (a, c) {
            return this.each(function () {
                if (!c) if (!a || b.filter(a, [this]).length) b("*", this).add([this]).each(function () {
                    b(this).triggerHandler("remove")
                });
                return l.call(b(this), a, c)
            })
        }
    }
    b.widget = function (a, c, d) {
        var e = a.split(".")[0],
            f;
        a = a.split(".")[1];
        f = e + "-" + a;
        if (!d) {
            d = c;
            c = b.Widget
        }
        b.expr[":"][f] = function (h) {
            return !!b.data(h, a)
        };
        b[e] = b[e] || {};
        b[e][a] = function (h, g) {
            arguments.length && this._createWidget(h, g)
        };
        c = new c;
        c.options = b.extend(true, {}, c.options);
        b[e][a].prototype = b.extend(true, c, {
            namespace: e,
            widgetName: a,
            widgetEventPrefix: b[e][a].prototype.widgetEventPrefix || a,
            widgetBaseClass: f
        }, d);
        b.widget.bridge(a, b[e][a])
    };
    b.widget.bridge = function (a, c) {
        b.fn[a] = function (d) {
            var e = typeof d === "string",
                f = Array.prototype.slice.call(arguments, 1),
                h = this;
            d = !e && f.length ? b.extend.apply(null, [true, d].concat(f)) : d;
            if (e && d.charAt(0) === "_") return h;
            e ? this.each(function () {
                var g = b.data(this, a),
                    i = g && b.isFunction(g[d]) ? g[d].apply(g, f) : g;
                if (i !== g && i !== j) {
                    h = i;
                    return false
                }
            }) : this.each(function () {
                var g = b.data(this, a);
                g ? g.option(d || {})._init() : b.data(this, a, new c(d, this))
            });
            return h
        }
    };
    b.Widget = function (a, c) {
        arguments.length && this._createWidget(a, c)
    };
    b.Widget.prototype = {
        widgetName: "widget",
        widgetEventPrefix: "",
        options: {
            disabled: false
        },
        _createWidget: function (a, c) {
            b.data(c, this.widgetName, this);
            this.element = b(c);
            this.options = b.extend(true, {}, this.options, this._getCreateOptions(), a);
            var d = this;
            this.element.bind("remove." + this.widgetName, function () {
                d.destroy()
            });
            this._create();
            this._trigger("create");
            this._init()
        },
        _getCreateOptions: function () {
            return b.metadata && b.metadata.get(this.element[0])[this.widgetName]
        },
        _create: function () {},
        _init: function () {},
        destroy: function () {
            this.element.unbind("." + this.widgetName).removeData(this.widgetName);
            this.widget().unbind("." + this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass + "-disabled ui-state-disabled")
        },
        widget: function () {
            return this.element
        },
        option: function (a, c) {
            var d = a;
            if (arguments.length === 0) return b.extend({}, this.options);
            if (typeof a === "string") {
                if (c === j) return this.options[a];
                d = {};
                d[a] = c
            }
            this._setOptions(d);
            return this
        },
        _setOptions: function (a) {
            var c = this;
            b.each(a, function (d, e) {
                c._setOption(d, e)
            });
            return this
        },
        _setOption: function (a, c) {
            this.options[a] = c;
            if (a === "disabled") this.widget()[c ? "addClass" : "removeClass"](this.widgetBaseClass + "-disabled ui-state-disabled").attr("aria-disabled", c);
            return this
        },
        enable: function () {
            return this._setOption("disabled", false)
        },
        disable: function () {
            return this._setOption("disabled", true)
        },
        _trigger: function (a, c, d) {
            var e = this.options[a];
            c = b.Event(c);
            c.type = (a === this.widgetEventPrefix ? a : this.widgetEventPrefix + a).toLowerCase();
            d = d || {};
            if (c.originalEvent) {
                a = b.event.props.length;
                for (var f; a;) {
                    f = b.event.props[--a];
                    c[f] = c.originalEvent[f]
                }
            }
            this.element.trigger(c, d);
            return !(b.isFunction(e) && e.call(this.element[0], c, d) === false || c.isDefaultPrevented())
        }
    }
})(jQuery);;
(function (b) {
    b.widget("ui.mouse", {
        options: {
            cancel: ":input,option",
            distance: 1,
            delay: 0
        },
        _mouseInit: function () {
            var a = this;
            this.element.bind("mousedown." + this.widgetName, function (c) {
                return a._mouseDown(c)
            }).bind("click." + this.widgetName, function (c) {
                if (true === b.data(c.target, a.widgetName + ".preventClickEvent")) {
                    b.removeData(c.target, a.widgetName + ".preventClickEvent");
                    c.stopImmediatePropagation();
                    return false
                }
            });
            this.started = false
        },
        _mouseDestroy: function () {
            this.element.unbind("." + this.widgetName)
        },
        _mouseDown: function (a) {
            a.originalEvent = a.originalEvent || {};
            if (!a.originalEvent.mouseHandled) {
                this._mouseStarted && this._mouseUp(a);
                this._mouseDownEvent = a;
                var c = this,
                    e = a.which == 1,
                    f = typeof this.options.cancel == "string" ? b(a.target).parents().add(a.target).filter(this.options.cancel).length : false;
                if (!e || f || !this._mouseCapture(a)) return true;
                this.mouseDelayMet = !this.options.delay;
                if (!this.mouseDelayMet) this._mouseDelayTimer = setTimeout(function () {
                    c.mouseDelayMet = true
                }, this.options.delay);
                if (this._mouseDistanceMet(a) && this._mouseDelayMet(a)) {
                    this._mouseStarted = this._mouseStart(a) !== false;
                    if (!this._mouseStarted) {
                        a.preventDefault();
                        return true
                    }
                }
                true === b.data(a.target, this.widgetName + ".preventClickEvent") && b.removeData(a.target, this.widgetName + ".preventClickEvent");
                this._mouseMoveDelegate = function (d) {
                    return c._mouseMove(d)
                };
                this._mouseUpDelegate = function (d) {
                    return c._mouseUp(d)
                };
                b(document).bind("mousemove." + this.widgetName, this._mouseMoveDelegate).bind("mouseup." + this.widgetName, this._mouseUpDelegate);
                a.preventDefault();
                return a.originalEvent.mouseHandled = true
            }
        },
        _mouseMove: function (a) {
            if (b.browser.msie && !(document.documentMode >= 9) && !a.button) return this._mouseUp(a);
            if (this._mouseStarted) {
                this._mouseDrag(a);
                return a.preventDefault()
            }
            if (this._mouseDistanceMet(a) && this._mouseDelayMet(a))(this._mouseStarted = this._mouseStart(this._mouseDownEvent, a) !== false) ? this._mouseDrag(a) : this._mouseUp(a);
            return !this._mouseStarted
        },
        _mouseUp: function (a) {
            b(document).unbind("mousemove." + this.widgetName, this._mouseMoveDelegate).unbind("mouseup." + this.widgetName, this._mouseUpDelegate);
            if (this._mouseStarted) {
                this._mouseStarted = false;
                a.target == this._mouseDownEvent.target && b.data(a.target, this.widgetName + ".preventClickEvent", true);
                this._mouseStop(a)
            }
            return false
        },
        _mouseDistanceMet: function (a) {
            return Math.max(Math.abs(this._mouseDownEvent.pageX - a.pageX), Math.abs(this._mouseDownEvent.pageY - a.pageY)) >= this.options.distance
        },
        _mouseDelayMet: function () {
            return this.mouseDelayMet
        },
        _mouseStart: function () {},
        _mouseDrag: function () {},
        _mouseStop: function () {},
        _mouseCapture: function () {
            return true
        }
    })
})(jQuery);;
(function (d) {
    d.widget("ui.sortable", d.ui.mouse, {
        widgetEventPrefix: "sort",
        options: {
            appendTo: "parent",
            axis: false,
            connectWith: false,
            containment: false,
            cursor: "auto",
            cursorAt: false,
            dropOnEmpty: true,
            forcePlaceholderSize: false,
            forceHelperSize: false,
            grid: false,
            handle: false,
            helper: "original",
            items: "> *",
            opacity: false,
            placeholder: false,
            revert: false,
            scroll: true,
            scrollSensitivity: 20,
            scrollSpeed: 20,
            scope: "default",
            tolerance: "intersect",
            zIndex: 1E3
        },
        _create: function () {
            this.containerCache = {};
            this.element.addClass("ui-sortable");
            this.refresh();
            this.floating = this.items.length ? /left|right/.test(this.items[0].item.css("float")) || /inline|table-cell/.test(this.items[0].item.css("display")) : false;
            this.offset = this.element.offset();
            this._mouseInit()
        },
        destroy: function () {
            this.element.removeClass("ui-sortable ui-sortable-disabled").removeData("sortable").unbind(".sortable");
            this._mouseDestroy();
            for (var a = this.items.length - 1; a >= 0; a--) this.items[a].item.removeData("sortable-item");
            return this
        },
        _setOption: function (a, b) {
            if (a === "disabled") {
                this.options[a] = b;
                this.widget()[b ? "addClass" : "removeClass"]("ui-sortable-disabled")
            } else d.Widget.prototype._setOption.apply(this, arguments)
        },
        _mouseCapture: function (a, b) {
            if (this.reverting) return false;
            if (this.options.disabled || this.options.type == "static") return false;
            this._refreshItems(a);
            var c = null,
                e = this;
            d(a.target).parents().each(function () {
                if (d.data(this, "sortable-item") == e) {
                    c = d(this);
                    return false
                }
            });
            if (d.data(a.target, "sortable-item") == e) c = d(a.target);
            if (!c) return false;
            if (this.options.handle && !b) {
                var f = false;
                d(this.options.handle, c).find("*").andSelf().each(function () {
                    if (this == a.target) f = true
                });
                if (!f) return false
            }
            this.currentItem = c;
            this._removeCurrentsFromItems();
            return true
        },
        _mouseStart: function (a, b, c) {
            b = this.options;
            var e = this;
            this.currentContainer = this;
            this.refreshPositions();
            this.helper = this._createHelper(a);
            this._cacheHelperProportions();
            this._cacheMargins();
            this.scrollParent = this.helper.scrollParent();
            this.offset = this.currentItem.offset();
            this.offset = {
                top: this.offset.top - this.margins.top,
                left: this.offset.left - this.margins.left
            };
            this.helper.css("position", "absolute");
            this.cssPosition = this.helper.css("position");
            d.extend(this.offset, {
                click: {
                    left: a.pageX - this.offset.left,
                    top: a.pageY - this.offset.top
                },
                parent: this._getParentOffset(),
                relative: this._getRelativeOffset()
            });
            this.originalPosition = this._generatePosition(a);
            this.originalPageX = a.pageX;
            this.originalPageY = a.pageY;
            b.cursorAt && this._adjustOffsetFromHelper(b.cursorAt);
            this.domPosition = {
                prev: this.currentItem.prev()[0],
                parent: this.currentItem.parent()[0]
            };
            this.helper[0] != this.currentItem[0] && this.currentItem.hide();
            this._createPlaceholder();
            b.containment && this._setContainment();
            if (b.cursor) {
                if (d("body").css("cursor")) this._storedCursor = d("body").css("cursor");
                d("body").css("cursor", b.cursor)
            }
            if (b.opacity) {
                if (this.helper.css("opacity")) this._storedOpacity = this.helper.css("opacity");
                this.helper.css("opacity", b.opacity)
            }
            if (b.zIndex) {
                if (this.helper.css("zIndex")) this._storedZIndex = this.helper.css("zIndex");
                this.helper.css("zIndex", b.zIndex)
            }
            if (this.scrollParent[0] != document && this.scrollParent[0].tagName != "HTML") this.overflowOffset = this.scrollParent.offset();
            this._trigger("start", a, this._uiHash());
            this._preserveHelperProportions || this._cacheHelperProportions();
            if (!c) for (c = this.containers.length - 1; c >= 0; c--) this.containers[c]._trigger("activate", a, e._uiHash(this));
            if (d.ui.ddmanager) d.ui.ddmanager.current = this;
            d.ui.ddmanager && !b.dropBehaviour && d.ui.ddmanager.prepareOffsets(this, a);
            this.dragging = true;
            this.helper.addClass("ui-sortable-helper");
            this._mouseDrag(a);
            return true
        },
        _mouseDrag: function (a) {
            this.position = this._generatePosition(a);
            this.positionAbs = this._convertPositionTo("absolute");
            if (!this.lastPositionAbs) this.lastPositionAbs = this.positionAbs;
            if (this.options.scroll) {
                var b = this.options,
                    c = false;
                if (this.scrollParent[0] != document && this.scrollParent[0].tagName != "HTML") {
                    if (this.overflowOffset.top + this.scrollParent[0].offsetHeight - a.pageY < b.scrollSensitivity) this.scrollParent[0].scrollTop = c = this.scrollParent[0].scrollTop + b.scrollSpeed;
                    else if (a.pageY - this.overflowOffset.top < b.scrollSensitivity) this.scrollParent[0].scrollTop = c = this.scrollParent[0].scrollTop - b.scrollSpeed;
                    if (this.overflowOffset.left + this.scrollParent[0].offsetWidth - a.pageX < b.scrollSensitivity) this.scrollParent[0].scrollLeft = c = this.scrollParent[0].scrollLeft + b.scrollSpeed;
                    else if (a.pageX - this.overflowOffset.left < b.scrollSensitivity) this.scrollParent[0].scrollLeft = c = this.scrollParent[0].scrollLeft - b.scrollSpeed
                } else {
                    if (a.pageY - d(document).scrollTop() < b.scrollSensitivity) c = d(document).scrollTop(d(document).scrollTop() - b.scrollSpeed);
                    else if (d(window).height() - (a.pageY - d(document).scrollTop()) < b.scrollSensitivity) c = d(document).scrollTop(d(document).scrollTop() + b.scrollSpeed);
                    if (a.pageX - d(document).scrollLeft() < b.scrollSensitivity) c = d(document).scrollLeft(d(document).scrollLeft() - b.scrollSpeed);
                    else if (d(window).width() - (a.pageX - d(document).scrollLeft()) < b.scrollSensitivity) c = d(document).scrollLeft(d(document).scrollLeft() + b.scrollSpeed)
                }
                c !== false && d.ui.ddmanager && !b.dropBehaviour && d.ui.ddmanager.prepareOffsets(this, a)
            }
            this.positionAbs = this._convertPositionTo("absolute");
            if (!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left + "px";
            if (!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top + "px";
            for (b = this.items.length - 1; b >= 0; b--) {
                c = this.items[b];
                var e = c.item[0],
                    f = this._intersectsWithPointer(c);
                if (f) if (e != this.currentItem[0] && this.placeholder[f == 1 ? "next" : "prev"]()[0] != e && !d.ui.contains(this.placeholder[0], e) && (this.options.type == "semi-dynamic" ? !d.ui.contains(this.element[0], e) : true)) {
                    this.direction = f == 1 ? "down" : "up";
                    if (this.options.tolerance == "pointer" || this._intersectsWithSides(c)) this._rearrange(a, c);
                    else break;
                    this._trigger("change", a, this._uiHash());
                    break
                }
            }
            this._contactContainers(a);
            d.ui.ddmanager && d.ui.ddmanager.drag(this, a);
            this._trigger("sort", a, this._uiHash());
            this.lastPositionAbs = this.positionAbs;
            return false
        },
        _mouseStop: function (a, b) {
            if (a) {
                d.ui.ddmanager && !this.options.dropBehaviour && d.ui.ddmanager.drop(this, a);
                if (this.options.revert) {
                    var c = this;
                    b = c.placeholder.offset();
                    c.reverting = true;
                    d(this.helper).animate({
                        left: b.left - this.offset.parent.left - c.margins.left + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft),
                        top: b.top - this.offset.parent.top - c.margins.top + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop)
                    }, parseInt(this.options.revert, 10) || 500, function () {
                        c._clear(a)
                    })
                } else this._clear(a, b);
                return false
            }
        },
        cancel: function () {
            var a = this;
            if (this.dragging) {
                this._mouseUp({
                    target: null
                });
                this.options.helper == "original" ? this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper") : this.currentItem.show();
                for (var b = this.containers.length - 1; b >= 0; b--) {
                    this.containers[b]._trigger("deactivate", null, a._uiHash(this));
                    if (this.containers[b].containerCache.over) {
                        this.containers[b]._trigger("out", null, a._uiHash(this));
                        this.containers[b].containerCache.over = 0
                    }
                }
            }
            if (this.placeholder) {
                this.placeholder[0].parentNode && this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
                this.options.helper != "original" && this.helper && this.helper[0].parentNode && this.helper.remove();
                d.extend(this, {
                    helper: null,
                    dragging: false,
                    reverting: false,
                    _noFinalSort: null
                });
                this.domPosition.prev ? d(this.domPosition.prev).after(this.currentItem) : d(this.domPosition.parent).prepend(this.currentItem)
            }
            return this
        },
        serialize: function (a) {
            var b = this._getItemsAsjQuery(a && a.connected),
                c = [];
            a = a || {};
            d(b).each(function () {
                var e = (d(a.item || this).attr(a.attribute || "id") || "").match(a.expression || /(.+)[-=_](.+)/);
                if (e) c.push((a.key || e[1] + "[]") + "=" + (a.key && a.expression ? e[1] : e[2]))
            });
            !c.length && a.key && c.push(a.key + "=");
            return c.join("&")
        },
        toArray: function (a) {
            var b = this._getItemsAsjQuery(a && a.connected),
                c = [];
            a = a || {};
            b.each(function () {
                c.push(d(a.item || this).attr(a.attribute || "id") || "")
            });
            return c
        },
        _intersectsWith: function (a) {
            var b = this.positionAbs.left,
                c = b + this.helperProportions.width,
                e = this.positionAbs.top,
                f = e + this.helperProportions.height,
                g = a.left,
                h = g + a.width,
                i = a.top,
                k = i + a.height,
                j = this.offset.click.top,
                l = this.offset.click.left;
            j = e + j > i && e + j < k && b + l > g && b + l < h;
            return this.options.tolerance == "pointer" || this.options.forcePointerForContainers || this.options.tolerance != "pointer" && this.helperProportions[this.floating ? "width" : "height"] > a[this.floating ? "width" : "height"] ? j : g < b + this.helperProportions.width / 2 && c - this.helperProportions.width / 2 < h && i < e + this.helperProportions.height / 2 && f - this.helperProportions.height / 2 < k
        },
        _intersectsWithPointer: function (a) {
            var b = d.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, a.top, a.height);
            a = d.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, a.left, a.width);
            b = b && a;
            a = this._getDragVerticalDirection();
            var c = this._getDragHorizontalDirection();
            if (!b) return false;
            return this.floating ? c && c == "right" || a == "down" ? 2 : 1 : a && (a == "down" ? 2 : 1)
        },
        _intersectsWithSides: function (a) {
            var b = d.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, a.top + a.height / 2, a.height);
            a = d.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, a.left + a.width / 2, a.width);
            var c = this._getDragVerticalDirection(),
                e = this._getDragHorizontalDirection();
            return this.floating && e ? e == "right" && a || e == "left" && !a : c && (c == "down" && b || c == "up" && !b)
        },
        _getDragVerticalDirection: function () {
            var a = this.positionAbs.top - this.lastPositionAbs.top;
            return a != 0 && (a > 0 ? "down" : "up")
        },
        _getDragHorizontalDirection: function () {
            var a = this.positionAbs.left - this.lastPositionAbs.left;
            return a != 0 && (a > 0 ? "right" : "left")
        },
        refresh: function (a) {
            this._refreshItems(a);
            this.refreshPositions();
            return this
        },
        _connectWith: function () {
            var a = this.options;
            return a.connectWith.constructor == String ? [a.connectWith] : a.connectWith
        },
        _getItemsAsjQuery: function (a) {
            var b = [],
                c = [],
                e = this._connectWith();
            if (e && a) for (a = e.length - 1; a >= 0; a--) for (var f = d(e[a]), g = f.length - 1; g >= 0; g--) {
                var h = d.data(f[g], "sortable");
                if (h && h != this && !h.options.disabled) c.push([d.isFunction(h.options.items) ? h.options.items.call(h.element) : d(h.options.items, h.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), h])
            }
            c.push([d.isFunction(this.options.items) ? this.options.items.call(this.element, null, {
                options: this.options,
                item: this.currentItem
            }) : d(this.options.items, this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), this]);
            for (a = c.length - 1; a >= 0; a--) c[a][0].each(function () {
                b.push(this)
            });
            return d(b)
        },
        _removeCurrentsFromItems: function () {
            for (var a = this.currentItem.find(":data(sortable-item)"), b = 0; b < this.items.length; b++) for (var c = 0; c < a.length; c++) a[c] == this.items[b].item[0] && this.items.splice(b, 1)
        },
        _refreshItems: function (a) {
            this.items = [];
            this.containers = [this];
            var b = this.items,
                c = [
                    [d.isFunction(this.options.items) ? this.options.items.call(this.element[0], a, {
                        item: this.currentItem
                    }) : d(this.options.items, this.element), this]
                ],
                e = this._connectWith();
            if (e) for (var f = e.length - 1; f >= 0; f--) for (var g = d(e[f]), h = g.length - 1; h >= 0; h--) {
                var i = d.data(g[h], "sortable");
                if (i && i != this && !i.options.disabled) {
                    c.push([d.isFunction(i.options.items) ? i.options.items.call(i.element[0], a, {
                        item: this.currentItem
                    }) : d(i.options.items, i.element), i]);
                    this.containers.push(i)
                }
            }
            for (f = c.length - 1; f >= 0; f--) {
                a = c[f][1];
                e = c[f][0];
                h = 0;
                for (g = e.length; h < g; h++) {
                    i = d(e[h]);
                    i.data("sortable-item", a);
                    b.push({
                        item: i,
                        instance: a,
                        width: 0,
                        height: 0,
                        left: 0,
                        top: 0
                    })
                }
            }
        },
        refreshPositions: function (a) {
            if (this.offsetParent && this.helper) this.offset.parent = this._getParentOffset();
            for (var b = this.items.length - 1; b >= 0; b--) {
                var c = this.items[b],
                    e = this.options.toleranceElement ? d(this.options.toleranceElement, c.item) : c.item;
                if (!a) {
                    c.width = e.outerWidth();
                    c.height = e.outerHeight()
                }
                e = e.offset();
                c.left = e.left;
                c.top = e.top
            }
            if (this.options.custom && this.options.custom.refreshContainers) this.options.custom.refreshContainers.call(this);
            else for (b = this.containers.length - 1; b >= 0; b--) {
                e = this.containers[b].element.offset();
                this.containers[b].containerCache.left = e.left;
                this.containers[b].containerCache.top = e.top;
                this.containers[b].containerCache.width = this.containers[b].element.outerWidth();
                this.containers[b].containerCache.height = this.containers[b].element.outerHeight()
            }
            return this
        },
        _createPlaceholder: function (a) {
            var b = a || this,
                c = b.options;
            if (!c.placeholder || c.placeholder.constructor == String) {
                var e = c.placeholder;
                c.placeholder = {
                    element: function () {
                        var f = d(document.createElement(b.currentItem[0].nodeName)).addClass(e || b.currentItem[0].className + " ui-sortable-placeholder").removeClass("ui-sortable-helper")[0];
                        if (!e) f.style.visibility = "hidden";
                        return f
                    },
                    update: function (f, g) {
                        if (!(e && !c.forcePlaceholderSize)) {
                            g.height() || g.height(b.currentItem.innerHeight() - parseInt(b.currentItem.css("paddingTop") || 0, 10) - parseInt(b.currentItem.css("paddingBottom") || 0, 10));
                            g.width() || g.width(b.currentItem.innerWidth() - parseInt(b.currentItem.css("paddingLeft") || 0, 10) - parseInt(b.currentItem.css("paddingRight") || 0, 10))
                        }
                    }
                }
            }
            b.placeholder = d(c.placeholder.element.call(b.element, b.currentItem));
            b.currentItem.after(b.placeholder);
            c.placeholder.update(b, b.placeholder)
        },
        _contactContainers: function (a) {
            for (var b = null, c = null, e = this.containers.length - 1; e >= 0; e--) if (!d.ui.contains(this.currentItem[0], this.containers[e].element[0])) if (this._intersectsWith(this.containers[e].containerCache)) {
                if (!(b && d.ui.contains(this.containers[e].element[0], b.element[0]))) {
                    b = this.containers[e];
                    c = e
                }
            } else if (this.containers[e].containerCache.over) {
                this.containers[e]._trigger("out", a, this._uiHash(this));
                this.containers[e].containerCache.over = 0
            }
            if (b) if (this.containers.length === 1) {
                this.containers[c]._trigger("over", a, this._uiHash(this));
                this.containers[c].containerCache.over = 1
            } else if (this.currentContainer != this.containers[c]) {
                b = 1E4;
                e = null;
                for (var f = this.positionAbs[this.containers[c].floating ? "left" : "top"], g = this.items.length - 1; g >= 0; g--) if (d.ui.contains(this.containers[c].element[0], this.items[g].item[0])) {
                    var h = this.items[g][this.containers[c].floating ? "left" : "top"];
                    if (Math.abs(h - f) < b) {
                        b = Math.abs(h - f);
                        e = this.items[g]
                    }
                }
                if (e || this.options.dropOnEmpty) {
                    this.currentContainer = this.containers[c];
                    e ? this._rearrange(a, e, null, true) : this._rearrange(a, null, this.containers[c].element, true);
                    this._trigger("change", a, this._uiHash());
                    this.containers[c]._trigger("change", a, this._uiHash(this));
                    this.options.placeholder.update(this.currentContainer, this.placeholder);
                    this.containers[c]._trigger("over", a, this._uiHash(this));
                    this.containers[c].containerCache.over = 1
                }
            }
        },
        _createHelper: function (a) {
            var b = this.options;
            a = d.isFunction(b.helper) ? d(b.helper.apply(this.element[0], [a, this.currentItem])) : b.helper == "clone" ? this.currentItem.clone() : this.currentItem;
            a.parents("body").length || d(b.appendTo != "parent" ? b.appendTo : this.currentItem[0].parentNode)[0].appendChild(a[0]);
            if (a[0] == this.currentItem[0]) this._storedCSS = {
                width: this.currentItem[0].style.width,
                height: this.currentItem[0].style.height,
                position: this.currentItem.css("position"),
                top: this.currentItem.css("top"),
                left: this.currentItem.css("left")
            };
            if (a[0].style.width == "" || b.forceHelperSize) a.width(this.currentItem.width());
            if (a[0].style.height == "" || b.forceHelperSize) a.height(this.currentItem.height());
            return a
        },
        _adjustOffsetFromHelper: function (a) {
            if (typeof a == "string") a = a.split(" ");
            if (d.isArray(a)) a = {
                left: +a[0],
                top: +a[1] || 0
            };
            if ("left" in a) this.offset.click.left = a.left + this.margins.left;
            if ("right" in a) this.offset.click.left = this.helperProportions.width - a.right + this.margins.left;
            if ("top" in a) this.offset.click.top = a.top + this.margins.top;
            if ("bottom" in a) this.offset.click.top = this.helperProportions.height - a.bottom + this.margins.top
        },
        _getParentOffset: function () {
            this.offsetParent = this.helper.offsetParent();
            var a = this.offsetParent.offset();
            if (this.cssPosition == "absolute" && this.scrollParent[0] != document && d.ui.contains(this.scrollParent[0], this.offsetParent[0])) {
                a.left += this.scrollParent.scrollLeft();
                a.top += this.scrollParent.scrollTop()
            }
            if (this.offsetParent[0] == document.body || this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == "html" && d.browser.msie) a = {
                top: 0,
                left: 0
            };
            return {
                top: a.top + (parseInt(this.offsetParent.css("borderTopWidth"), 10) || 0),
                left: a.left + (parseInt(this.offsetParent.css("borderLeftWidth"), 10) || 0)
            }
        },
        _getRelativeOffset: function () {
            if (this.cssPosition == "relative") {
                var a = this.currentItem.position();
                return {
                    top: a.top - (parseInt(this.helper.css("top"), 10) || 0) + this.scrollParent.scrollTop(),
                    left: a.left - (parseInt(this.helper.css("left"), 10) || 0) + this.scrollParent.scrollLeft()
                }
            } else return {
                top: 0,
                left: 0
            }
        },
        _cacheMargins: function () {
            this.margins = {
                left: parseInt(this.currentItem.css("marginLeft"), 10) || 0,
                top: parseInt(this.currentItem.css("marginTop"), 10) || 0
            }
        },
        _cacheHelperProportions: function () {
            this.helperProportions = {
                width: this.helper.outerWidth(),
                height: this.helper.outerHeight()
            }
        },
        _setContainment: function () {
            var a = this.options;
            if (a.containment == "parent") a.containment = this.helper[0].parentNode;
            if (a.containment == "document" || a.containment == "window") this.containment = [0 - this.offset.relative.left - this.offset.parent.left, 0 - this.offset.relative.top - this.offset.parent.top, d(a.containment == "document" ? document : window).width() - this.helperProportions.width - this.margins.left, (d(a.containment == "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top];
            if (!/^(document|window|parent)$/.test(a.containment)) {
                var b = d(a.containment)[0];
                a = d(a.containment).offset();
                var c = d(b).css("overflow") != "hidden";
                this.containment = [a.left + (parseInt(d(b).css("borderLeftWidth"), 10) || 0) + (parseInt(d(b).css("paddingLeft"), 10) || 0) - this.margins.left, a.top + (parseInt(d(b).css("borderTopWidth"), 10) || 0) + (parseInt(d(b).css("paddingTop"), 10) || 0) - this.margins.top, a.left + (c ? Math.max(b.scrollWidth, b.offsetWidth) : b.offsetWidth) - (parseInt(d(b).css("borderLeftWidth"), 10) || 0) - (parseInt(d(b).css("paddingRight"), 10) || 0) - this.helperProportions.width - this.margins.left, a.top + (c ? Math.max(b.scrollHeight, b.offsetHeight) : b.offsetHeight) - (parseInt(d(b).css("borderTopWidth"), 10) || 0) - (parseInt(d(b).css("paddingBottom"), 10) || 0) - this.helperProportions.height - this.margins.top]
            }
        },
        _convertPositionTo: function (a, b) {
            if (!b) b = this.position;
            a = a == "absolute" ? 1 : -1;
            var c = this.cssPosition == "absolute" && !(this.scrollParent[0] != document && d.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
                e = /(html|body)/i.test(c[0].tagName);
            return {
                top: b.top + this.offset.relative.top * a + this.offset.parent.top * a - (d.browser.safari && this.cssPosition == "fixed" ? 0 : (this.cssPosition == "fixed" ? -this.scrollParent.scrollTop() : e ? 0 : c.scrollTop()) * a),
                left: b.left + this.offset.relative.left * a + this.offset.parent.left * a - (d.browser.safari && this.cssPosition == "fixed" ? 0 : (this.cssPosition == "fixed" ? -this.scrollParent.scrollLeft() : e ? 0 : c.scrollLeft()) * a)
            }
        },
        _generatePosition: function (a) {
            var b = this.options,
                c = this.cssPosition == "absolute" && !(this.scrollParent[0] != document && d.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
                e = /(html|body)/i.test(c[0].tagName);
            if (this.cssPosition == "relative" && !(this.scrollParent[0] != document && this.scrollParent[0] != this.offsetParent[0])) this.offset.relative = this._getRelativeOffset();
            var f = a.pageX,
                g = a.pageY;
            if (this.originalPosition) {
                if (this.containment) {
                    if (a.pageX - this.offset.click.left < this.containment[0]) f = this.containment[0] + this.offset.click.left;
                    if (a.pageY - this.offset.click.top < this.containment[1]) g = this.containment[1] + this.offset.click.top;
                    if (a.pageX - this.offset.click.left > this.containment[2]) f = this.containment[2] + this.offset.click.left;
                    if (a.pageY - this.offset.click.top > this.containment[3]) g = this.containment[3] + this.offset.click.top
                }
                if (b.grid) {
                    g = this.originalPageY + Math.round((g - this.originalPageY) / b.grid[1]) * b.grid[1];
                    g = this.containment ? !(g - this.offset.click.top < this.containment[1] || g - this.offset.click.top > this.containment[3]) ? g : !(g - this.offset.click.top < this.containment[1]) ? g - b.grid[1] : g + b.grid[1] : g;
                    f = this.originalPageX + Math.round((f - this.originalPageX) / b.grid[0]) * b.grid[0];
                    f = this.containment ? !(f - this.offset.click.left < this.containment[0] || f - this.offset.click.left > this.containment[2]) ? f : !(f - this.offset.click.left < this.containment[0]) ? f - b.grid[0] : f + b.grid[0] : f
                }
            }
            return {
                top: g - this.offset.click.top - this.offset.relative.top - this.offset.parent.top + (d.browser.safari && this.cssPosition == "fixed" ? 0 : this.cssPosition == "fixed" ? -this.scrollParent.scrollTop() : e ? 0 : c.scrollTop()),
                left: f - this.offset.click.left - this.offset.relative.left - this.offset.parent.left + (d.browser.safari && this.cssPosition == "fixed" ? 0 : this.cssPosition == "fixed" ? -this.scrollParent.scrollLeft() : e ? 0 : c.scrollLeft())
            }
        },
        _rearrange: function (a, b, c, e) {
            c ? c[0].appendChild(this.placeholder[0]) : b.item[0].parentNode.insertBefore(this.placeholder[0], this.direction == "down" ? b.item[0] : b.item[0].nextSibling);
            this.counter = this.counter ? ++this.counter : 1;
            var f = this,
                g = this.counter;
            window.setTimeout(function () {
                g == f.counter && f.refreshPositions(!e)
            }, 0)
        },
        _clear: function (a, b) {
            this.reverting = false;
            var c = [];
            !this._noFinalSort && this.currentItem[0].parentNode && this.placeholder.before(this.currentItem);
            this._noFinalSort = null;
            if (this.helper[0] == this.currentItem[0]) {
                for (var e in this._storedCSS) if (this._storedCSS[e] == "auto" || this._storedCSS[e] == "static") this._storedCSS[e] = "";
                this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper")
            } else this.currentItem.show();
            this.fromOutside && !b && c.push(function (f) {
                this._trigger("receive", f, this._uiHash(this.fromOutside))
            });
            if ((this.fromOutside || this.domPosition.prev != this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent != this.currentItem.parent()[0]) && !b) c.push(function (f) {
                this._trigger("update", f, this._uiHash())
            });
            if (!d.ui.contains(this.element[0], this.currentItem[0])) {
                b || c.push(function (f) {
                    this._trigger("remove", f, this._uiHash())
                });
                for (e = this.containers.length - 1; e >= 0; e--) if (d.ui.contains(this.containers[e].element[0], this.currentItem[0]) && !b) {
                    c.push(function (f) {
                        return function (g) {
                            f._trigger("receive", g, this._uiHash(this))
                        }
                    }.call(this, this.containers[e]));
                    c.push(function (f) {
                        return function (g) {
                            f._trigger("update", g, this._uiHash(this))
                        }
                    }.call(this, this.containers[e]))
                }
            }
            for (e = this.containers.length - 1; e >= 0; e--) {
                b || c.push(function (f) {
                    return function (g) {
                        f._trigger("deactivate", g, this._uiHash(this))
                    }
                }.call(this, this.containers[e]));
                if (this.containers[e].containerCache.over) {
                    c.push(function (f) {
                        return function (g) {
                            f._trigger("out", g, this._uiHash(this))
                        }
                    }.call(this, this.containers[e]));
                    this.containers[e].containerCache.over = 0
                }
            }
            this._storedCursor && d("body").css("cursor", this._storedCursor);
            this._storedOpacity && this.helper.css("opacity", this._storedOpacity);
            if (this._storedZIndex) this.helper.css("zIndex", this._storedZIndex == "auto" ? "" : this._storedZIndex);
            this.dragging = false;
            if (this.cancelHelperRemoval) {
                if (!b) {
                    this._trigger("beforeStop", a, this._uiHash());
                    for (e = 0; e < c.length; e++) c[e].call(this, a);
                    this._trigger("stop", a, this._uiHash())
                }
                return false
            }
            b || this._trigger("beforeStop", a, this._uiHash());
            this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
            this.helper[0] != this.currentItem[0] && this.helper.remove();
            this.helper = null;
            if (!b) {
                for (e = 0; e < c.length; e++) c[e].call(this, a);
                this._trigger("stop", a, this._uiHash())
            }
            this.fromOutside = false;
            return true
        },
        _trigger: function () {
            d.Widget.prototype._trigger.apply(this, arguments) === false && this.cancel()
        },
        _uiHash: function (a) {
            var b = a || this;
            return {
                helper: b.helper,
                placeholder: b.placeholder || d([]),
                position: b.position,
                originalPosition: b.originalPosition,
                offset: b.positionAbs,
                item: b.currentItem,
                sender: a ? a.element : null
            }
        }
    });
    d.extend(d.ui.sortable, {
        version: "1.8.11"
    })
})(jQuery);;
(function (d) {
    d.widget("ui.slider", d.ui.mouse, {
        widgetEventPrefix: "slide",
        options: {
            animate: false,
            distance: 0,
            max: 100,
            min: 0,
            orientation: "horizontal",
            range: false,
            step: 1,
            value: 0,
            values: null
        },
        _create: function () {
            var b = this,
                a = this.options;
            this._mouseSliding = this._keySliding = false;
            this._animateOff = true;
            this._handleIndex = null;
            this._detectOrientation();
            this._mouseInit();
            this.element.addClass("ui-slider ui-slider-" + this.orientation + " ui-widget ui-widget-content ui-corner-all");
            a.disabled && this.element.addClass("ui-slider-disabled ui-disabled");
            this.range = d([]);
            if (a.range) {
                if (a.range === true) {
                    this.range = d("<div></div>");
                    if (!a.values) a.values = [this._valueMin(), this._valueMin()];
                    if (a.values.length && a.values.length !== 2) a.values = [a.values[0], a.values[0]]
                } else this.range = d("<div></div>");
                this.range.appendTo(this.element).addClass("ui-slider-range");
                if (a.range === "min" || a.range === "max") this.range.addClass("ui-slider-range-" + a.range);
                this.range.addClass("ui-widget-header")
            }
            d(".ui-slider-handle", this.element).length === 0 && d("<a href='#'></a>").appendTo(this.element).addClass("ui-slider-handle");
            if (a.values && a.values.length) for (; d(".ui-slider-handle", this.element).length < a.values.length;) d("<a href='#'></a>").appendTo(this.element).addClass("ui-slider-handle");
            this.handles = d(".ui-slider-handle", this.element).addClass("ui-state-default ui-corner-all");
            this.handle = this.handles.eq(0);
            this.handles.add(this.range).filter("a").click(function (c) {
                c.preventDefault()
            }).hover(function () {
                a.disabled || d(this).addClass("ui-state-hover")
            }, function () {
                d(this).removeClass("ui-state-hover")
            }).focus(function () {
                if (a.disabled) d(this).blur();
                else {
                    d(".ui-slider .ui-state-focus").removeClass("ui-state-focus");
                    d(this).addClass("ui-state-focus")
                }
            }).blur(function () {
                d(this).removeClass("ui-state-focus")
            });
            this.handles.each(function (c) {
                d(this).data("index.ui-slider-handle", c)
            });
            this.handles.keydown(function (c) {
                var e = true,
                    f = d(this).data("index.ui-slider-handle"),
                    h, g, i;
                if (!b.options.disabled) {
                    switch (c.keyCode) {
                    case d.ui.keyCode.HOME:
                    case d.ui.keyCode.END:
                    case d.ui.keyCode.PAGE_UP:
                    case d.ui.keyCode.PAGE_DOWN:
                    case d.ui.keyCode.UP:
                    case d.ui.keyCode.RIGHT:
                    case d.ui.keyCode.DOWN:
                    case d.ui.keyCode.LEFT:
                        e = false;
                        if (!b._keySliding) {
                            b._keySliding = true;
                            d(this).addClass("ui-state-active");
                            h = b._start(c, f);
                            if (h === false) return
                        }
                        break
                    }
                    i = b.options.step;
                    h = b.options.values && b.options.values.length ? (g = b.values(f)) : (g = b.value());
                    switch (c.keyCode) {
                    case d.ui.keyCode.HOME:
                        g = b._valueMin();
                        break;
                    case d.ui.keyCode.END:
                        g = b._valueMax();
                        break;
                    case d.ui.keyCode.PAGE_UP:
                        g = b._trimAlignValue(h + (b._valueMax() - b._valueMin()) / 5);
                        break;
                    case d.ui.keyCode.PAGE_DOWN:
                        g = b._trimAlignValue(h - (b._valueMax() - b._valueMin()) / 5);
                        break;
                    case d.ui.keyCode.UP:
                    case d.ui.keyCode.RIGHT:
                        if (h === b._valueMax()) return;
                        g = b._trimAlignValue(h + i);
                        break;
                    case d.ui.keyCode.DOWN:
                    case d.ui.keyCode.LEFT:
                        if (h === b._valueMin()) return;
                        g = b._trimAlignValue(h - i);
                        break
                    }
                    b._slide(c, f, g);
                    return e
                }
            }).keyup(function (c) {
                var e = d(this).data("index.ui-slider-handle");
                if (b._keySliding) {
                    b._keySliding = false;
                    b._stop(c, e);
                    b._change(c, e);
                    d(this).removeClass("ui-state-active")
                }
            });
            this._refreshValue();
            this._animateOff = false
        },
        destroy: function () {
            this.handles.remove();
            this.range.remove();
            this.element.removeClass("ui-slider ui-slider-horizontal ui-slider-vertical ui-slider-disabled ui-widget ui-widget-content ui-corner-all").removeData("slider").unbind(".slider");
            this._mouseDestroy();
            return this
        },
        _mouseCapture: function (b) {
            var a = this.options,
                c, e, f, h, g;
            if (a.disabled) return false;
            this.elementSize = {
                width: this.element.outerWidth(),
                height: this.element.outerHeight()
            };
            this.elementOffset = this.element.offset();
            c = this._normValueFromMouse({
                x: b.pageX,
                y: b.pageY
            });
            e = this._valueMax() - this._valueMin() + 1;
            h = this;
            this.handles.each(function (i) {
                var j = Math.abs(c - h.values(i));
                if (e > j) {
                    e = j;
                    f = d(this);
                    g = i
                }
            });
            if (a.range === true && this.values(1) === a.min) {
                g += 1;
                f = d(this.handles[g])
            }
            if (this._start(b, g) === false) return false;
            this._mouseSliding = true;
            h._handleIndex = g;
            f.addClass("ui-state-active").focus();
            a = f.offset();
            this._clickOffset = !d(b.target).parents().andSelf().is(".ui-slider-handle") ? {
                left: 0,
                top: 0
            } : {
                left: b.pageX - a.left - f.width() / 2,
                top: b.pageY - a.top - f.height() / 2 - (parseInt(f.css("borderTopWidth"), 10) || 0) - (parseInt(f.css("borderBottomWidth"), 10) || 0) + (parseInt(f.css("marginTop"), 10) || 0)
            };
            this.handles.hasClass("ui-state-hover") || this._slide(b, g, c);
            return this._animateOff = true
        },
        _mouseStart: function () {
            return true
        },
        _mouseDrag: function (b) {
            var a = this._normValueFromMouse({
                x: b.pageX,
                y: b.pageY
            });
            this._slide(b, this._handleIndex, a);
            return false
        },
        _mouseStop: function (b) {
            this.handles.removeClass("ui-state-active");
            this._mouseSliding = false;
            this._stop(b, this._handleIndex);
            this._change(b, this._handleIndex);
            this._clickOffset = this._handleIndex = null;
            return this._animateOff = false
        },
        _detectOrientation: function () {
            this.orientation = this.options.orientation === "vertical" ? "vertical" : "horizontal"
        },
        _normValueFromMouse: function (b) {
            var a;
            if (this.orientation === "horizontal") {
                a = this.elementSize.width;
                b = b.x - this.elementOffset.left - (this._clickOffset ? this._clickOffset.left : 0)
            } else {
                a = this.elementSize.height;
                b = b.y - this.elementOffset.top - (this._clickOffset ? this._clickOffset.top : 0)
            }
            a = b / a;
            if (a > 1) a = 1;
            if (a < 0) a = 0;
            if (this.orientation === "vertical") a = 1 - a;
            b = this._valueMax() - this._valueMin();
            return this._trimAlignValue(this._valueMin() + a * b)
        },
        _start: function (b, a) {
            var c = {
                handle: this.handles[a],
                value: this.value()
            };
            if (this.options.values && this.options.values.length) {
                c.value = this.values(a);
                c.values = this.values()
            }
            return this._trigger("start", b, c)
        },
        _slide: function (b, a, c) {
            var e;
            if (this.options.values && this.options.values.length) {
                e = this.values(a ? 0 : 1);
                if (this.options.values.length === 2 && this.options.range === true && (a === 0 && c > e || a === 1 && c < e)) c = e;
                if (c !== this.values(a)) {
                    e = this.values();
                    e[a] = c;
                    b = this._trigger("slide", b, {
                        handle: this.handles[a],
                        value: c,
                        values: e
                    });
                    this.values(a ? 0 : 1);
                    b !== false && this.values(a, c, true)
                }
            } else if (c !== this.value()) {
                b = this._trigger("slide", b, {
                    handle: this.handles[a],
                    value: c
                });
                b !== false && this.value(c)
            }
        },
        _stop: function (b, a) {
            var c = {
                handle: this.handles[a],
                value: this.value()
            };
            if (this.options.values && this.options.values.length) {
                c.value = this.values(a);
                c.values = this.values()
            }
            this._trigger("stop", b, c)
        },
        _change: function (b, a) {
            if (!this._keySliding && !this._mouseSliding) {
                var c = {
                    handle: this.handles[a],
                    value: this.value()
                };
                if (this.options.values && this.options.values.length) {
                    c.value = this.values(a);
                    c.values = this.values()
                }
                this._trigger("change", b, c)
            }
        },
        value: function (b) {
            if (arguments.length) {
                this.options.value = this._trimAlignValue(b);
                this._refreshValue();
                this._change(null, 0)
            }
            return this._value()
        },
        values: function (b, a) {
            var c, e, f;
            if (arguments.length > 1) {
                this.options.values[b] = this._trimAlignValue(a);
                this._refreshValue();
                this._change(null, b)
            }
            if (arguments.length) if (d.isArray(arguments[0])) {
                c = this.options.values;
                e = arguments[0];
                for (f = 0; f < c.length; f += 1) {
                    c[f] = this._trimAlignValue(e[f]);
                    this._change(null, f)
                }
                this._refreshValue()
            } else return this.options.values && this.options.values.length ? this._values(b) : this.value();
            else return this._values()
        },
        _setOption: function (b, a) {
            var c, e = 0;
            if (d.isArray(this.options.values)) e = this.options.values.length;
            d.Widget.prototype._setOption.apply(this, arguments);
            switch (b) {
            case "disabled":
                if (a) {
                    this.handles.filter(".ui-state-focus").blur();
                    this.handles.removeClass("ui-state-hover");
                    this.handles.attr("disabled", "disabled");
                    this.element.addClass("ui-disabled")
                } else {
                    this.handles.removeAttr("disabled");
                    this.element.removeClass("ui-disabled")
                }
                break;
            case "orientation":
                this._detectOrientation();
                this.element.removeClass("ui-slider-horizontal ui-slider-vertical").addClass("ui-slider-" + this.orientation);
                this._refreshValue();
                break;
            case "value":
                this._animateOff = true;
                this._refreshValue();
                this._change(null, 0);
                this._animateOff = false;
                break;
            case "values":
                this._animateOff = true;
                this._refreshValue();
                for (c = 0; c < e; c += 1) this._change(null, c);
                this._animateOff = false;
                break
            }
        },
        _value: function () {
            var b = this.options.value;
            return b = this._trimAlignValue(b)
        },
        _values: function (b) {
            var a, c;
            if (arguments.length) {
                a = this.options.values[b];
                return a = this._trimAlignValue(a)
            } else {
                a = this.options.values.slice();
                for (c = 0; c < a.length; c += 1) a[c] = this._trimAlignValue(a[c]);
                return a
            }
        },
        _trimAlignValue: function (b) {
            if (b <= this._valueMin()) return this._valueMin();
            if (b >= this._valueMax()) return this._valueMax();
            var a = this.options.step > 0 ? this.options.step : 1,
                c = (b - this._valueMin()) % a;
            alignValue = b - c;
            if (Math.abs(c) * 2 >= a) alignValue += c > 0 ? a : -a;
            return parseFloat(alignValue.toFixed(5))
        },
        _valueMin: function () {
            return this.options.min
        },
        _valueMax: function () {
            return this.options.max
        },
        _refreshValue: function () {
            var b = this.options.range,
                a = this.options,
                c = this,
                e = !this._animateOff ? a.animate : false,
                f, h = {},
                g, i, j, l;
            if (this.options.values && this.options.values.length) this.handles.each(function (k) {
                f = (c.values(k) - c._valueMin()) / (c._valueMax() - c._valueMin()) * 100;
                h[c.orientation === "horizontal" ? "left" : "bottom"] = f + "%";
                d(this).stop(1, 1)[e ? "animate" : "css"](h, a.animate);
                if (c.options.range === true) if (c.orientation === "horizontal") {
                    if (k === 0) c.range.stop(1, 1)[e ? "animate" : "css"]({
                        left: f + "%"
                    }, a.animate);
                    if (k === 1) c.range[e ? "animate" : "css"]({
                        width: f - g + "%"
                    }, {
                        queue: false,
                        duration: a.animate
                    })
                } else {
                    if (k === 0) c.range.stop(1, 1)[e ? "animate" : "css"]({
                        bottom: f + "%"
                    }, a.animate);
                    if (k === 1) c.range[e ? "animate" : "css"]({
                        height: f - g + "%"
                    }, {
                        queue: false,
                        duration: a.animate
                    })
                }
                g = f
            });
            else {
                i = this.value();
                j = this._valueMin();
                l = this._valueMax();
                f = l !== j ? (i - j) / (l - j) * 100 : 0;
                h[c.orientation === "horizontal" ? "left" : "bottom"] = f + "%";
                this.handle.stop(1, 1)[e ? "animate" : "css"](h, a.animate);
                if (b === "min" && this.orientation === "horizontal") this.range.stop(1, 1)[e ? "animate" : "css"]({
                    width: f + "%"
                }, a.animate);
                if (b === "max" && this.orientation === "horizontal") this.range[e ? "animate" : "css"]({
                    width: 100 - f + "%"
                }, {
                    queue: false,
                    duration: a.animate
                });
                if (b === "min" && this.orientation === "vertical") this.range.stop(1, 1)[e ? "animate" : "css"]({
                    height: f + "%"
                }, a.animate);
                if (b === "max" && this.orientation === "vertical") this.range[e ? "animate" : "css"]({
                    height: 100 - f + "%"
                }, {
                    queue: false,
                    duration: a.animate
                })
            }
        }
    });
    d.extend(d.ui.slider, {
        version: "1.8.11"
    })
})(jQuery);;
jQuery.fn.selectToUISlider = function (settings) {
    var selects = jQuery(this);
    var options = jQuery.extend({
        labels: 3,
        tooltip: true,
        tooltipSrc: 'text',
        labelSrc: 'value',
        sliderOptions: null
    }, settings);
    var handleIds = (function () {
        var tempArr = [];
        selects.each(function () {
            tempArr.push('handle_' + jQuery(this).attr('id'));
        });
        return tempArr;
    })();
    var selectOptions = (function () {
        var opts = [];
        selects.eq(0).find('option').each(function () {
            opts.push({
                value: jQuery(this).attr('value'),
                text: jQuery(this).text()
            });
        });
        return opts;
    })();
    var groups = (function () {
        if (selects.eq(0).find('optgroup').size() > 0) {
            var groupedData = [];
            selects.eq(0).find('optgroup').each(function (i) {
                groupedData[i] = {};
                groupedData[i].label = jQuery(this).attr('label');
                groupedData[i].options = [];
                jQuery(this).find('option').each(function () {
                    groupedData[i].options.push({
                        text: jQuery(this).text(),
                        value: jQuery(this).attr('value')
                    });
                });
            });
            return groupedData;
        } else return null;
    })();

    function isArray(obj) {
        return obj.constructor == Array;
    }

    function ttText(optIndex) {
        if (typeof selectOptions[optIndex] != 'undefined') {
            return (options.tooltipSrc == 'text') ? selectOptions[optIndex].text : selectOptions[optIndex].value;
        }
    }
    var sliderOptions = {
        step: 1,
        min: 0,
        orientation: 'horizontal',
        max: selectOptions.length - 1,
        range: selects.length > 1,
        slide: function (e, ui) {
            var thisHandle = jQuery(ui.handle);
            var textval = ttText(ui.value);
            thisHandle.attr('aria-valuetext', textval).attr('aria-valuenow', ui.value).find('.ui-slider-tooltip .ttContent').text(textval);
            currSelect = jQuery('#' + thisHandle.attr('id').split('handle_')[1]);
            currSelect.find('option').eq(ui.value).attr('selected', 'selected');
        },
        stop: function (e, ui) {
            if (typeof currSelect != 'undefined') {
                currSelect.trigger('change');
            }
        },
        start: function (e, ui) {
            jQuery.each(jQuery.browser, function (i, val) {
                if (i == "msie" && jQuery.browser.version.substr(0, 3) == "6.0") {
                    $('.ui-slider-range').css({
                        'top': '2px'
                    });
                }
            });
        },
        values: (function () {
            var values = [];
            selects.each(function () {
                values.push(jQuery(this).get(0).selectedIndex);
            });
            return values;
        })()
    };
    options.sliderOptions = (settings) ? jQuery.extend(sliderOptions, settings.sliderOptions) : sliderOptions;
    selects.bind('change keyup click', function () {
        var thisIndex = jQuery(this).get(0).selectedIndex;
        var thisHandle = jQuery('#handle_' + jQuery(this).attr('id'));
        var handleIndex = thisHandle.data('handleNum');
        thisHandle.parents('.ui-slider:eq(0)').slider("values", handleIndex, thisIndex);
    });
    var sliderComponent = jQuery('<div></div>');
    selects.each(function (i) {
        var hidett = '';
        var myID = jQuery(this).attr('id');
        var thisLabel = jQuery('label[for="' + myID + '"]');
        var labelText = (thisLabel.size() > 0) ? 'Slider control for ' + thisLabel.text() + '' : '';
        var thisLabelId = thisLabel.attr('id') || thisLabel.attr('id', 'label_' + handleIds[i]).attr('id');
        if (options.tooltip == false) {
            hidett = ' style="display: none;"';
        }
        jQuery('<a ' + 'href="#" tabindex="0" ' + 'id="' + handleIds[i] + '" ' + 'class="ui-slider-handle" ' + 'role="slider" ' + 'aria-labelledby="' + thisLabelId + '" ' + 'aria-valuemin="' + options.sliderOptions.min + '" ' + 'aria-valuemax="' + options.sliderOptions.max + '" ' + 'aria-valuenow="' + options.sliderOptions.values[i] + '" ' + 'aria-valuetext="' + ttText(options.sliderOptions.values[i]) + '" ' + '><span class="screenReaderContext">' + labelText + '</span>' + '<span class="ui-slider-tooltip ui-widget-content ui-corner-all"' + hidett + '><span class="ttContent"></span>' + '<span class="ui-tooltip-pointer-down ui-widget-content"><span class="ui-tooltip-pointer-down-inner"></span></span>' + '</span></a>').data('handleNum', i).appendTo(sliderComponent);
    });
    if (groups) {
        var inc = 0;
        var scale = sliderComponent.append('<dl class="ui-slider-scale ui-helper-reset" role="presentation"></dl>').find('.ui-slider-scale:eq(0)');
        jQuery(groups).each(function (h) {
            scale.append('<dt style="width: ' + (100 / groups.length).toFixed(2) + '%' + '; left:' + (h / (groups.length - 1) * 100).toFixed(2) + '%' + '"><span>' + this.label + '</span></dt>');
            var groupOpts = this.options;
            jQuery(this.options).each(function (i) {
                var style = (inc == selectOptions.length - 1 || inc == 0) ? 'style="display: none;"' : '';
                var labelText = (options.labelSrc == 'text') ? groupOpts[i].text : groupOpts[i].value;
                scale.append('<dd style="left:' + leftVal(inc) + '"><span class="ui-slider-label">' + labelText + '</span><span class="ui-slider-tic ui-widget-content"' + style + '></span></dd>');
                inc++;
            });
        });
    } else {
        var scale = sliderComponent.append('<ol class="ui-slider-scale ui-helper-reset" role="presentation"></ol>').find('.ui-slider-scale:eq(0)');
        jQuery(selectOptions).each(function (i) {
            var style = (i == selectOptions.length - 1 || i == 0) ? ' style="display: none;"' : '';
            var labelText = (options.labelSrc == 'text') ? this.text : this.value;
            if (i == 0) {
                scale.append("<li class='first_child' style='left:" + leftVal(i) + "'><span>" + labelText + "</span><span class='ui-slider-tic ui-widget-content'" + style + ">&nbsp;</span></li>");
            } else {
                scale.append('<li style="left:' + leftVal(i) + '"><span>' + labelText + '</span><span class="ui-slider-tic ui-widget-content"' + style + '></span></li>');
            }
        });
    }

    function leftVal(i) {
        return ((i / (selectOptions.length - 1) * 100) - 3).toFixed(2) + "%";
    }
    if (options.labels > 1) sliderComponent.find('.ui-slider-scale li:last span.ui-slider-label, .ui-slider-scale dd:last span.ui-slider-label').addClass('ui-slider-label-show');
    var increm = Math.max(1, Math.round(selectOptions.length / options.labels));
    for (var j = 0; j < selectOptions.length; j += increm) {
        if ((selectOptions.length - j) > increm) {
            sliderComponent.find('.ui-slider-scale li:eq(' + j + ') span.ui-slider-label, .ui-slider-scale dd:eq(' + j + ') span.ui-slider-label').addClass('ui-slider-label-show');
        }
    }
    sliderComponent.find('.ui-slider-scale dt').each(function (i) {
        jQuery(this).css({
            'left': ((100 / (groups.length)) * i).toFixed(2) + '%'
        });
    });
    sliderComponent.insertAfter(jQuery(this).eq(this.length - 1)).slider(options.sliderOptions).attr('role', 'application').find('.ui-slider-label').each(function () {
        jQuery(this).css();
    });
    sliderComponent.find('.ui-tooltip-pointer-down-inner').each(function () {
        var bWidth = jQuery('.ui-tooltip-pointer-down-inner').css('borderTopWidth');
        var bColor = jQuery(this).parents('.ui-slider-tooltip').css('backgroundColor')
        jQuery(this).css('border-top', bWidth + ' solid ' + bColor);
    });
    var values = sliderComponent.slider('values');
    if (isArray(values)) {
        jQuery(values).each(function (i) {
            sliderComponent.find('.ui-slider-tooltip .ttContent').eq(i).text(ttText(this));
        });
    } else {
        sliderComponent.find('.ui-slider-tooltip .ttContent').eq(0).text(ttText(values));
    }
    return this;
};﻿ (function ($) {
    $.fn.hoverIntent = function (f, g) {
        var cfg = {
            sensitivity: 7,
            interval: 100,
            timeout: 0
        };
        cfg = $.extend(cfg, g ? {
            over: f,
            out: g
        } : f);
        var cX, cY, pX, pY;
        var track = function (ev) {
                cX = ev.pageX;
                cY = ev.pageY;
            };
        var compare = function (ev, ob) {
                ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
                if ((Math.abs(pX - cX) + Math.abs(pY - cY)) < cfg.sensitivity) {
                    $(ob).unbind("mousemove", track);
                    ob.hoverIntent_s = 1;
                    return cfg.over.apply(ob, [ev]);
                } else {
                    pX = cX;
                    pY = cY;
                    ob.hoverIntent_t = setTimeout(function () {
                        compare(ev, ob);
                    }, cfg.interval);
                }
            };
        var delay = function (ev, ob) {
                ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
                ob.hoverIntent_s = 0;
                return cfg.out.apply(ob, [ev]);
            };
        var handleHover = function (e) {
                var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget;
                while (p && p != this) {
                    try {
                        p = p.parentNode;
                    } catch (e) {
                        p = this;
                    }
                }
                if (p == this) {
                    return false;
                }
                var ev = jQuery.extend({}, e);
                var ob = this;
                if (ob.hoverIntent_t) {
                    ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
                }
                if (e.type == "mouseover") {
                    pX = ev.pageX;
                    pY = ev.pageY;
                    $(ob).bind("mousemove", track);
                    if (ob.hoverIntent_s != 1) {
                        ob.hoverIntent_t = setTimeout(function () {
                            compare(ev, ob);
                        }, cfg.interval);
                    }
                } else {
                    $(ob).unbind("mousemove", track);
                    if (ob.hoverIntent_s == 1) {
                        ob.hoverIntent_t = setTimeout(function () {
                            delay(ev, ob);
                        }, cfg.timeout);
                    }
                }
            };
        return this.mouseover(handleHover).mouseout(handleHover);
    };
})(jQuery);
eval(function (p, a, c, k, e, r) {
    e = function (c) {
        return (c < a ? '' : e(parseInt(c / a))) + ((c = c % a) > 35 ? String.fromCharCode(c + 29) : c.toString(36))
    };
    if (!''.replace(/^/, String)) {
        while (c--) r[e(c)] = k[c] || e(c);
        k = [function (e) {
            return r[e]
        }];
        e = function () {
            return '\\w+'
        };
        c = 1
    };
    while (c--) if (k[c]) p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]);
    return p
}('(5($){$.6.j.4={L:5(){9 b=$.6.j.4.i;7($.8.f)$(2).o(\'y.4\',5(a){$.d(2,\'h\',{x:a.x,l:a.l,s:a.s,r:a.r})});7(2.q)2.q(($.8.f?\'v\':\'4\'),b,n);m 2.w=b},D:5(){9 a=$.6.j.4.i;$(2).k(\'y.4\');7(2.u)2.u(($.8.f?\'v\':\'4\'),a,n);m 2.w=5(){};$.A(2,\'h\')},i:5(a){9 c=U.T.S.P(O,1);a=$.6.N(a||M.6);$.t(a,$.d(2,\'h\')||{});9 b=0,K=J;7(a.e)b=a.e/I;7(a.p)b=-a.p/3;7($.8.H)b=-a.e;a.d=a.d||{};a.G="4";c.z(b);c.z(a);g $.6.F.E(2,c)}};$.Q.t({4:5(a){g a?2.o("4",a):2.R("4")},C:5(a){g 2.k("4",a)}})})(B);', 57, 57, '||this||mousewheel|function|event|if|browser|var||||data|wheelDelta|mozilla|return|mwcursorposdata|handler|special|unbind|pageY|else|false|bind|detail|addEventListener|clientY|clientX|extend|removeEventListener|DOMMouseScroll|onmousewheel|pageX|mousemove|unshift|removeData|jQuery|unmousewheel|teardown|apply|handle|type|opera|120|true|returnValue|setup|window|fix|arguments|call|fn|trigger|slice|prototype|Array'.split('|'), 0, {}));
jQuery.easing['jswing'] = jQuery.easing['swing'];
jQuery.extend(jQuery.easing, {
    def: 'easeOutQuad',
    swing: function (x, t, b, c, d) {
        return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
    },
    easeInQuad: function (x, t, b, c, d) {
        return c * (t /= d) * t + b;
    },
    easeOutQuad: function (x, t, b, c, d) {
        return -c * (t /= d) * (t - 2) + b;
    },
    easeInOutQuad: function (x, t, b, c, d) {
        if ((t /= d / 2) < 1) return c / 2 * t * t + b;
        return -c / 2 * ((--t) * (t - 2) - 1) + b;
    },
    easeInCubic: function (x, t, b, c, d) {
        return c * (t /= d) * t * t + b;
    },
    easeOutCubic: function (x, t, b, c, d) {
        return c * ((t = t / d - 1) * t * t + 1) + b;
    },
    easeInOutCubic: function (x, t, b, c, d) {
        if ((t /= d / 2) < 1) return c / 2 * t * t * t + b;
        return c / 2 * ((t -= 2) * t * t + 2) + b;
    },
    easeInQuart: function (x, t, b, c, d) {
        return c * (t /= d) * t * t * t + b;
    },
    easeOutQuart: function (x, t, b, c, d) {
        return -c * ((t = t / d - 1) * t * t * t - 1) + b;
    },
    easeInOutQuart: function (x, t, b, c, d) {
        if ((t /= d / 2) < 1) return c / 2 * t * t * t * t + b;
        return -c / 2 * ((t -= 2) * t * t * t - 2) + b;
    },
    easeInQuint: function (x, t, b, c, d) {
        return c * (t /= d) * t * t * t * t + b;
    },
    easeOutQuint: function (x, t, b, c, d) {
        return c * ((t = t / d - 1) * t * t * t * t + 1) + b;
    },
    easeInOutQuint: function (x, t, b, c, d) {
        if ((t /= d / 2) < 1) return c / 2 * t * t * t * t * t + b;
        return c / 2 * ((t -= 2) * t * t * t * t + 2) + b;
    },
    easeInSine: function (x, t, b, c, d) {
        return -c * Math.cos(t / d * (Math.PI / 2)) + c + b;
    },
    easeOutSine: function (x, t, b, c, d) {
        return c * Math.sin(t / d * (Math.PI / 2)) + b;
    },
    easeInOutSine: function (x, t, b, c, d) {
        return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b;
    },
    easeInExpo: function (x, t, b, c, d) {
        return (t == 0) ? b : c * Math.pow(2, 10 * (t / d - 1)) + b;
    },
    easeOutExpo: function (x, t, b, c, d) {
        return (t == d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b;
    },
    easeInOutExpo: function (x, t, b, c, d) {
        if (t == 0) return b;
        if (t == d) return b + c;
        if ((t /= d / 2) < 1) return c / 2 * Math.pow(2, 10 * (t - 1)) + b;
        return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b;
    },
    easeInCirc: function (x, t, b, c, d) {
        return -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b;
    },
    easeOutCirc: function (x, t, b, c, d) {
        return c * Math.sqrt(1 - (t = t / d - 1) * t) + b;
    },
    easeInOutCirc: function (x, t, b, c, d) {
        if ((t /= d / 2) < 1) return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b;
        return c / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + b;
    },
    easeInElastic: function (x, t, b, c, d) {
        var s = 1.70158;
        var p = 0;
        var a = c;
        if (t == 0) return b;
        if ((t /= d) == 1) return b + c;
        if (!p) p = d * .3;
        if (a < Math.abs(c)) {
            a = c;
            var s = p / 4;
        } else var s = p / (2 * Math.PI) * Math.asin(c / a);
        return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
    },
    easeOutElastic: function (x, t, b, c, d) {
        var s = 1.70158;
        var p = 0;
        var a = c;
        if (t == 0) return b;
        if ((t /= d) == 1) return b + c;
        if (!p) p = d * .3;
        if (a < Math.abs(c)) {
            a = c;
            var s = p / 4;
        } else var s = p / (2 * Math.PI) * Math.asin(c / a);
        return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b;
    },
    easeInOutElastic: function (x, t, b, c, d) {
        var s = 1.70158;
        var p = 0;
        var a = c;
        if (t == 0) return b;
        if ((t /= d / 2) == 2) return b + c;
        if (!p) p = d * (.3 * 1.5);
        if (a < Math.abs(c)) {
            a = c;
            var s = p / 4;
        } else var s = p / (2 * Math.PI) * Math.asin(c / a);
        if (t < 1) return -.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
        return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p) * .5 + c + b;
    },
    easeInBack: function (x, t, b, c, d, s) {
        if (s == undefined) s = 1.70158;
        return c * (t /= d) * t * ((s + 1) * t - s) + b;
    },
    easeOutBack: function (x, t, b, c, d, s) {
        if (s == undefined) s = 1.70158;
        return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
    },
    easeInOutBack: function (x, t, b, c, d, s) {
        if (s == undefined) s = 1.70158;
        if ((t /= d / 2) < 1) return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
        return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
    },
    easeInBounce: function (x, t, b, c, d) {
        return c - jQuery.easing.easeOutBounce(x, d - t, 0, c, d) + b;
    },
    easeOutBounce: function (x, t, b, c, d) {
        if ((t /= d) < (1 / 2.75)) {
            return c * (7.5625 * t * t) + b;
        } else if (t < (2 / 2.75)) {
            return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
        } else if (t < (2.5 / 2.75)) {
            return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
        } else {
            return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
        }
    },
    easeInOutBounce: function (x, t, b, c, d) {
        if (t < d / 2) return jQuery.easing.easeInBounce(x, t * 2, 0, c, d) * .5 + b;
        return jQuery.easing.easeOutBounce(x, t * 2 - d, 0, c, d) * .5 + c * .5 + b;
    }
});;




var emmezetaFunctionList = {
    init: function () {
        $self = this;
        this.mainNavigation();

    },


    mainNavigation: function () {
        var lists = $('#main_navigation .clear > li'),
            first_list = $('#main_navigation .first_block ul'),
            first_link = $('#main_navigation .first_block span:first-child'),
            first_extras = $('#main_navigation .first_block .extras'),
            first_block_hover = $('#main_navigation .clear ul > li:not(.first_block)');
        $.each(lists, function (k, v) {
            var listItems = $(this).find('ul'),
                extras = $(this).find('.extras'),
                extras_size = $(this).find('.first_block .extras').size();
            $.each(listItems, function (key, value) {
                $(this).parent().attr('rel', $(value).outerHeight());
            });
            $.each(extras, function (key, value) {
                var pre_height = $(this).parent().attr('rel');
                if (pre_height < $(value).height()) {
                    $(this).parent().attr('rel', $(value).height());
                }
            });
            if (extras_size) {
                $(this).find('.first_level').addClass('has_extras');
            }
        });
        first_block_hover.hover(function () {
            first_list.removeClass('active_list');
            first_link.removeClass('over');
            first_extras.removeClass('active_extras');
        });
        $('#main_navigation .clear > li').hoverIntent({
            over: function () {
                var heights = [],
                    master_height = $(this).attr('rel'),
                    list_height = $(this).find('.first_block').attr('rel'),
                    master_nav_width = $('#main_navigation').outerWidth(),
                    list_width = $(this).find('.first_level').outerWidth(),
                    list_pos = $(this).position(),
                    list_pos_left = list_pos.left,
                    main_width = list_width + list_pos_left,
                    left = master_nav_width - main_width - 10;
                if (left < 0) {
                    $(this).find('.first_level').css({
                        left: left
                    });
                    $(this).addClass('inverted');
                }
                heights.push(parseInt(master_height), parseInt(list_height));
                $(this).find('ul ul').height(Math.max.apply(Math, heights));
                $(this).find('.extras').height(Math.max.apply(Math, heights));
                $(this).find('ul:eq(0)').addClass('active').height(Math.max.apply(Math, heights));
            },
            out: function () {
                var klass = $(this).hasClass('inverted');
                if (klass) {
                    $(this).find('.first_level').css({
                        left: '-9999px'
                    });
                }
                $(this).find('ul:eq(0)').removeClass('active');
                first_list.addClass('active_list');
                first_link.addClass('over');
                first_extras.addClass('active_extras');
            },
            timeout: 0
        });
        $('#main_navigation .first_level > li').hover(function () {
            var heights = [],
                master_height = $(this).parent().parent().attr('rel'),
                list_height = $(this).attr('rel'),
                invert = $(this).parent().parent().attr('class'),
                extras = $(this).find('.extras').size();
            if (extras) {
                $(this).parent().addClass('has_extras');
            } else {
                $(this).parent().removeClass('has_extras');
            }
            heights.push(parseInt(master_height), parseInt(list_height));
            $(this).find('ul').height(Math.max.apply(Math, heights));
            $(this).find('.extras').height(Math.max.apply(Math, heights));
            $(this).parent().height(Math.max.apply(Math, heights));
        });
        $('#main_navigation .clear > li > a').hover(function () {
            first_list.addClass('active_list');
            first_link.addClass('over');
            first_extras.addClass('active_extras');
        });
    },
    card_activation: function () {
        var container = $('#activation'),
            yes = container.find('.yes'),
            card_form = $('.activation_wrapper #club_connect');
        card_form.hide();
        yes.click(function (e) {
            container.fadeOut(500, function () {
                card_form.fadeIn(500);
            });
            e.preventDefault();
        });
    },
    fade_region: function () {
        var container = $('#login_register'),
            fade_class = 'fade_region',
            login, register;

        function highlightRegion(highlight, fade, focus) {
            highlight.removeClass(fade_class);
            fade.addClass(fade_class);
            if (focus === true) {
                highlight.find('input:text:first').fieldTipper().focus();
            }
        }
        if (container.length) {
            login = container.find('#login');
            register = container.find('#register');
            if (/emmezeta\-klub/.test(location.pathname)) {
                highlightRegion(login, register, true);
            } else if (/(registracija|profil)/.test(location.pathname)) {
                highlightRegion(register, login, true);
            } else if (/login/.test(location.pathname)) {
                highlightRegion(login, register, true);
            }
            login.bind('click', function () {
                highlightRegion(login, register);
            });
            register.bind('click', function () {
                highlightRegion(register, login);
            });
            container.find('input.fm_text, button').bind('focus', function () {
                if ($(this).closest('.field_region').attr('id') === 'login') {
                    highlightRegion(login, register);
                } else if ($(this).closest('.field_region').attr('id') === 'register') {
                    highlightRegion(register, login);
                }
            });
            $('#register .switch').live('click', function (e) {
                $('#email').val($('#reg_email').val());
                highlightRegion(login, register);
                $('#pwd').focus();
                e.preventDefault();
            });
        }
    },
    share_tools: function () {
        var widget = $('#sharer');
        if (!widget.length) {
            return false;
        }
        var mail_trigger = widget.find('.share_mail'),
            mail_href = mail_trigger.attr('href'),
            send_button = widget.find('.btn'),
            form_holder = widget.find('.pr_h_box_out'),
            form = widget.find('form'),
            recipient = $('#share_recipient'),
            active_class = 'active';

        function closePopup() {
            mail_trigger.removeClass(active_class);
            form_holder.hide();
        }

        function createMail() {
            return 'mailto:' + $.trim(recipient.val()) + mail_href.replace('mailto:', '').replace(/č/ig, 'c').replace(/ć/ig, 'c').replace(/ž/ig, 'z').replace(/đ/g, 'dj').replace(/Đ/g, 'Dj');
        }
        mail_trigger.bind('click', function (e) {
            form_holder.toggle();
            $(this).toggleClass(active_class);
            if ($(this).hasClass(active_class)) {
                recipient.focus();
            }
            e.preventDefault();
        });
        form.bind('submit', function (e) {
            window.location = createMail();
            closePopup();
            e.preventDefault();
        });
        $('a.share_close').bind('click', function (e) {
            closePopup();
            e.preventDefault();
        });
        send_button.bind('click', function (e) {
            form.trigger('submit');
            e.preventDefault();
        });
        $(document).bind('keyup', function (e) {
            if (e.which === 27) {
                closePopup();
            }
        });
    },
    photo_galleries: function () {
        var logged_in = $('#user_toolbar_inn .user_avatar').size();
        if (logged_in > 0) {
            var like = $('#photo_galleries .like'),
                reply = $('#photo_galleries .action_reply');
            like.live('click', function (e) {
                var url = $(this).attr('href'),
                    urlObj = $.deparam.querystring(url),
                    url_part = url.split('?');
                $('#photo_galleries #main_photo').append('<div class="loading"></div>');
                emmezetaFunctionList.ajax('post', url, '', '', function (data) {
                    if (data && parseInt(data) > 0) {
                        $('#user_photos_nav').find('li.structure').removeClass('structure');
                    } else {
                        $('#user_photos_nav').find('li:eq(1)').addClass('structure');
                    }
                });
                $(this).toggleClass('voted');
                if (urlObj.like == 1) {
                    $(this).attr('href', url_part[0] + '?unlike=1');
                } else if (urlObj.unlike == 1) {
                    $(this).attr('href', url_part[0] + '?like=1');
                }
                e.preventDefault();
            });
            reply.live('click', function (e) {
                var url = $(this).attr('href'),
                    urlObj = $.deparam.querystring(url),
                    this_li = $(this).closest('li'),
                    this_li_index = $(this).closest('ul').find('li').index($(this).closest('li')),
                    cancel = $('#comment_form p:last').find('.cancel').size();
                if (this_li_index != 0) {
                    this_li.find('dl').removeClass('brd_t_s');
                }
                $('#comment_form').find('input[name="reply_to"]').val(urlObj.reply_to);
                if (cancel == 0) {
                    $('#comment_form p:last').append('<a href="#" class="right mt_l cancel">Odustani</a>');
                }
                $('#comment_form').prev('h2').html('Napiši odgovor');
                $('.fm_photo_comment').focus();
                this_li.parent().children().not(this_li).slideUp('fast');
                $('#comment_form .cancel').live('click', function (e) {
                    this_li.parent().children().slideDown('fast');
                    $('#comment_form').find('input[name="reply_to"]').val('0');
                    $(this).remove();
                    $('#comment_form').prev('h2').html('Napiši komentar');
                    if (this_li_index != 0) {
                        this_li.find('dl').addClass('brd_t_s');
                    }
                    e.preventDefault();
                });
                e.preventDefault();
            });
        }
        $('#photo_galleries .delete_image').live('click', function () {
            var ays = confirm('Jeste li sigurni da želite trajno obrisati sliku?');
            if (ays) {
                return true;
            } else {
                return false;
            }
        });
        $('#photo_prev a, #photo_next a').live('click', function (e) {
            var href = $(this).attr('href');
            $.bbq.pushState({
                url: href
            });
            e.preventDefault();
        });
        $(window).bind("hashchange", function (e) {
            var url = $.bbq.getState("url");
            if (url) {
                $('#photo_galleries #main_photo').append('<div class="loading"></div>');
                emmezetaFunctionList.ajax('get', url, '', '#photo_galleries', function () {
                    var title = $('html').find('title'),
                        title_content = title.html(),
                        real_title = $('h1 span').html();
                    document.title = real_title + ' - Emmezeta';
                    emmezetaFunctionList.share_tools();
                    $('a.share_fb').facebookShare();
                    $('a.share_tw').twitterShare();
                });
            }
        });
        $(window).trigger("hashchange");
        var isgallery = $('#photo_galleries').size();
        if (isgallery) {
            $(document).bind('keydown', function (e) {
                var code = (e.keyCode ? e.keyCode : e.which),
                    prev = $('#photo_prev a').size(),
                    next = $('#photo_next a').size();
                if (code == 37 && prev > 0) {
                    $('#photo_prev a').trigger('click');
                } else if (code == 39 && next > 0) {
                    $('#photo_next a').trigger('click');
                }
            });
        }
        $('#sort select').change(function () {
            $('#sort').submit();
        });
        $('#photo_galleries #desc').charCounter(180, {
            container: '<span></span>',
            classname: 'desc_counter',
            format: "Preostalo znakova: %1",
            pulse: true,
            delay: 10
        });
    },
    info_pages: function () {
        var services = $('#find_services').size();
        if (services) {
            $(document).ajaxStart(function () {
                $('#popis-servisa .side_by_side').append('<div class="loading">&nbsp;</div>');
            });
            $(document).ajaxStop(function () {
                $('#popis-servisa .side_by_side .loading').remove();
            });
            $('#find_services select').live('change', function () {
                var formData = $('#find_services').serializeArray();
                $.ajax({
                    type: 'post',
                    url: $('#find_services').attr('action'),
                    data: formData,
                    success: function (data) {
                        $('.main_info_content').html(data);
                    }
                });
            });
            $('.main_info_content .pagination a').live('click', function (e) {
                e.preventDefault();
                var formData = $('#find_services').serializeArray();
                $.ajax({
                    type: 'post',
                    url: $(this).attr('href'),
                    data: formData,
                    success: function (data) {
                        $('.main_info_content').html(data);
                    }
                });
            });
        }
        var r1_form = $('.r1').size();
        if (r1_form) {
            $('.r1 .approach :input').change(function (e) {
                if ($('.no_approach').is(':checked')) {
                    $('.no_approach_notice').removeClass('hide');
                } else {
                    $('.no_approach_notice').addClass('hide');
                }
            });
            $('.r1 .add').click(function (e) {
                var next_nr = $('.product').length + 1;
                var tpl = $('.' + $(this).attr('rel')).clone();
                tpl.html(tpl.html().replace(/PRODUCT_NR/g, next_nr));
                tpl.removeClass('template hide').addClass('product').insertBefore('.template');
                e.preventDefault();
            });
        }
        var shipping_montage_cost = $('#shipping_montage_cost');
        if (shipping_montage_cost.size()) {
            $(document).ajaxStart(function () {
                $('#shipping_montage_cost').append('<div class="loading">&nbsp;</div>');
            });
            $(document).ajaxStop(function () {
                var current_step = shipping_montage_cost.find('fieldset[class^="step_"]').size() - 1,
                    steps = shipping_montage_cost.find('fieldset.structural').size(),
                    eye_candy = $('.eye_candy'),
                    truck = eye_candy.find('#truck'),
                    truck_path = truck.width(),
                    truck_segment = truck_path / 3,
                    house = eye_candy.find('#house');
                if (steps == 3) {
                    if (!$.browser.msie) {
                        truck.animate({
                            backgroundPosition: '520px -28px'
                        }, function () {
                            house.addClass('active');
                        });
                    } else {
                        truck.animate({
                            backgroundPositionX: '520px'
                        }, function () {
                            house.addClass('active');
                        });
                    }
                } else {
                    if (!$.browser.msie) {
                        truck.animate({
                            backgroundPosition: (truck_segment * current_step) + 'px -28px'
                        });
                    } else {
                        truck.animate({
                            backgroundPositionX: (truck_segment * current_step) + 'px'
                        });
                    }
                    house.removeClass('active');
                }
                $('#shipping_montage_cost .loading').remove();
            });
            $('#category_title, #option_1, #option_2').live('change', function () {
                var formData = $('#shipping_montage_cost').find('form').serializeArray();
                formData.push({
                    name: 'submit',
                    value: 'Slijedeći korak'
                });
                $.ajax({
                    type: 'post',
                    url: $('#shipping_montage_cost form').attr('action'),
                    data: formData,
                    success: function (data) {
                        var insertData = $(data).find('#shipping_montage_cost_container');
                        $('#shipping_montage_cost_container').replaceWith(insertData);
                    }
                });
            });
            $('#category_id').live('change', function () {
                var required = $(this).find('option:selected').attr('class');
                if (required == 'required_price') {
                    $('#shipping_montage_cost .pr_price').removeClass('structure');
                } else {
                    $('#shipping_montage_cost .pr_price').addClass('structure');
                }
            });
            $('#shipping_montage_cost_container .next_step, #shipping_montage_cost_container .previous_step').live('click', function (e) {
                var formData = $('#shipping_montage_cost').find('form').serializeArray();
                formData.push({
                    name: this.name,
                    value: this.value
                });
                $.ajax({
                    type: 'post',
                    url: $('#shipping_montage_cost form').attr('action'),
                    data: formData,
                    success: function (data) {
                        var insertData = $(data).find('#shipping_montage_cost_container');
                        $('#shipping_montage_cost_container').replaceWith(insertData);
                    }
                });
                e.preventDefault();
            });
        }
        $('#credit_cards').simpletabs({
            tab_navigation: '#credit_cards_nav a',
            tab_content: '#credit_cards_container > div',
            top_anchor: '#container',
            active_class: 'active',
            show: '0'
        });
        $('.crediflex').click(function () {
            $(this).next('.crediflex_container').toggleClass('structural');
        });
    },
    guarantees: function () {
        var guarantee = $('#guarantees .guarantee_inner');
        guarantee.hover(function () {
            var height = $(this).outerHeight(),
                desc = $(this).find('.desc_hover'),
                desc_height = desc.outerHeight(),
                margin = -(desc_height / 2);
            desc.css({
                'margin-top': margin,
                top: '50%',
                left: '-175px'
            });
        }, function () {
            var desc = $(this).find('.desc_hover');
            desc.css({
                top: '-9999px',
                left: '-9999px'
            });
        });
    },
    adminSorter: function () {
        $('#admin_sorter').sortable().disableSelection();
        $('#stop_reorder').click(function (e) {
            var sorted = $('#admin_sorter').sortable('serialize', {
                key: 'sorted[]'
            });
            $.ajax({
                type: 'post',
                url: window.location.href,
                data: 'sort=1&' + sorted,
                success: function (response) {
                    alert('Spremljeno!');
                }
            });
            e.preventDefault();
        });
    },
    zip: function () {
        $("#zip").autocomplete({
            source: function (request, response) {
                $.ajax({
                    url: "/korisnici/zip",
                    data: 'term=' + request.term,
                    success: function (data) {
                        var newdata = eval(data),
                            suggestions = [];
                        $.each(newdata, function (i, val) {
                            suggestions.push({
                                'value': val.title,
                                'id': val.id
                            });
                        });
                        response(suggestions);
                    }
                });
            },
            select: function (e, ui) {
                $('#zip_id').val(ui.item.id);
            }
        });
    },
    buyers_poll: function () {
        var poll = $('#buyers_poll'),
            poll_form = poll.find('form'),
            poll_action = poll_form.attr('action');
        poll_form.live('submit', function (e) {
            var data = poll_form.serialize(),
                input = poll_form.find('textarea').val();
            if (input) {
                $self.ajax('post', poll_action, data, function () {
                    poll.addClass('show_response');
                });
            }
            e.preventDefault();
        });
    }
};
var emmBeforeDOMList = {
    init: function () {
        $base = this;
        this.fivePictures();
        $base.t = setTimeout(this.auto_tabs, 5000);
    },
    fivePictures: function () {
        var mainproductnumber = $('.pr_h_selected_home').size();
        $('#pr_h_home_slider').prepend('<ul id="pr_h_home_slider_nav"/>');
        for (i = 0; i < mainproductnumber; i++) {
            $('#pr_h_home_slider_nav').append('<li><a href="#"><span class="structural"></span></a></li>');
        }
        $('#pr_h_home_slider_nav li').each(function (index) {
            $(this).attr({
                'id': 'product_tabs-' + (index + 1)
            });
        });
        $('#pr_h_home_slider_nav li a').each(function (index) {
            $(this).attr({
                'href': '#tabs-' + (index + 1)
            });
        });
        $('#pr_h_home_slider_nav li a span').each(function (index) {
            $(this).text(index + 1);
        });
        var $hash = window.location.hash;
        var tabContainers = $('.pr_h_selected_home');
        if ($hash && $hash != '#featured-products') {
            tabContainers.hide().filter($hash).show();
            $what = 'a[href*=' + $hash + ']';
        } else {
            tabContainers.hide().filter(':first').show();
            $what = ':first';
        }
        $('#pr_h_home_slider_nav a').bind('click', function (e) {
            tabContainers.hide();
            tabContainers.filter(this.hash).show();
            $('#pr_h_home_slider_nav li').removeClass('ui-tabs-selected');
            $(this).closest('li').addClass('ui-tabs-selected');
            return false;
        }).filter($what).click();
    },
    auto_tabs: function () {
        var active_tab = $('#pr_h_home_slider_nav .ui-tabs-selected').next('li');
        if (typeof (active_tab[0]) == 'undefined') {
            active_tab = $('#pr_h_home_slider_nav li:first');
        }
        active_tab.find('a').trigger('click');
        emmezetaFunctionList.productDescriptionHide();
        $base.t = setTimeout($base.auto_tabs, 5000);
    },
    disable_auto_tabs: function () {
        clearTimeout($base.t);
    },
    enable_auto_tabs: function () {
        $base.t = setTimeout($base.auto_tabs, 5000);
    },
    product_image_slider: function (options) {
        $("#pr_h_image_inn").product_image_slider(options);
    }
};
$(document).ready(function () {
    emmezetaFunctionList.init();
});
