/*!
 * JavaScript Custom Forms
 *
 * Copyright 2014-2015 PSD2HTML - http://psd2html.com/jcf
 * Released under the MIT license (LICENSE.txt)
 *
 * Version: 1.2.0
 */
! function(e, t) {
    "use strict";
    "function" == typeof define && define.amd ? define(["jquery"], t) : "object" == typeof exports ? module.exports = t(require("jquery")) : e.jcf = t(jQuery)
}(this, function(e) {
    "use strict";
    var t = "1.2.0",
        n = [],
        o = {
            optionsKey: "jcf",
            dataKey: "jcf-instance",
            rtlClass: "jcf-rtl",
            focusClass: "jcf-focus",
            pressedClass: "jcf-pressed",
            disabledClass: "jcf-disabled",
            hiddenClass: "jcf-hidden",
            resetAppearanceClass: "jcf-reset-appearance",
            unselectableClass: "jcf-unselectable"
        },
        a = "ontouchstart" in window || window.DocumentTouch && document instanceof window.DocumentTouch,
        i = /Windows Phone/.test(navigator.userAgent);
    o.isMobileDevice = !(!a && !i);
    var r = function() {
        var t = e("<style>").appendTo("head"),
            n = t.prop("sheet") || t.prop("styleSheet"),
            a = function(e, t, o) {
                n.insertRule ? n.insertRule(e + "{" + t + "}", o) : n.addRule(e, t, o)
            };
        a("." + o.hiddenClass, "position:absolute !important;left:-9999px !important;height:1px !important;width:1px !important;margin:0 !important;border-width:0 !important;-webkit-appearance:none;-moz-appearance:none;appearance:none"), a("." + o.rtlClass + " ." + o.hiddenClass, "right:-9999px !important; left: auto !important"), a("." + o.unselectableClass, "-webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; -webkit-tap-highlight-color: rgba(0,0,0,0);"), a("." + o.resetAppearanceClass, "background: none; border: none; -webkit-appearance: none; appearance: none; opacity: 0; filter: alpha(opacity=0);");
        var i = e("html"),
            r = e("body");
        ("rtl" === i.css("direction") || "rtl" === r.css("direction")) && i.addClass(o.rtlClass), i.on("reset", function() {
            setTimeout(function() {
                c.refreshAll()
            }, 0)
        }), o.styleSheetCreated = !0
    };
    ! function() {
        var t, n = navigator.pointerEnabled || navigator.msPointerEnabled,
            o = "ontouchstart" in window || window.DocumentTouch && document instanceof window.DocumentTouch,
            a = {},
            i = "jcf-";
        t = n ? {
            pointerover: navigator.pointerEnabled ? "pointerover" : "MSPointerOver",
            pointerdown: navigator.pointerEnabled ? "pointerdown" : "MSPointerDown",
            pointermove: navigator.pointerEnabled ? "pointermove" : "MSPointerMove",
            pointerup: navigator.pointerEnabled ? "pointerup" : "MSPointerUp"
        } : {
            pointerover: "mouseover",
            pointerdown: "mousedown" + (o ? " touchstart" : ""),
            pointermove: "mousemove" + (o ? " touchmove" : ""),
            pointerup: "mouseup" + (o ? " touchend" : "")
        }, e.each(t, function(t, n) {
            e.each(n.split(" "), function(e, n) {
                a[n] = t
            })
        }), e.each(t, function(t, n) {
            n = n.split(" "), e.event.special[i + t] = {
                setup: function() {
                    var t = this;
                    e.each(n, function(e, n) {
                        t.addEventListener ? t.addEventListener(n, c, !1) : t["on" + n] = c
                    })
                },
                teardown: function() {
                    var t = this;
                    e.each(n, function(e, n) {
                        t.addEventListener ? t.removeEventListener(n, c, !1) : t["on" + n] = null
                    })
                }
            }
        });
        var r = null,
            s = function(e) {
                var t = Math.abs(e.pageX - r.x),
                    n = Math.abs(e.pageY - r.y),
                    o = 25;
                return o >= t && o >= n ? !0 : void 0
            },
            c = function(t) {
                var n = t || window.event,
                    o = null,
                    c = a[n.type];
                if (t = e.event.fix(n), t.type = i + c, n.pointerType) switch (n.pointerType) {
                    case 2:
                        t.pointerType = "touch";
                        break;
                    case 3:
                        t.pointerType = "pen";
                        break;
                    case 4:
                        t.pointerType = "mouse";
                        break;
                    default:
                        t.pointerType = n.pointerType
                } else t.pointerType = n.type.substr(0, 5);
                return t.pageX || t.pageY || (o = n.changedTouches ? n.changedTouches[0] : n, t.pageX = o.pageX, t.pageY = o.pageY), "touchend" === n.type && (r = {
                    x: t.pageX,
                    y: t.pageY
                }), "mouse" === t.pointerType && r && s(t) ? void 0 : (e.event.dispatch || e.event.handle).call(this, t)
            }
    }(),
    function() {
        var t = ("onwheel" in document || document.documentMode >= 9 ? "wheel" : "mousewheel DOMMouseScroll").split(" "),
            n = "jcf-mousewheel";
        e.event.special[n] = {
            setup: function() {
                var n = this;
                e.each(t, function(e, t) {
                    n.addEventListener ? n.addEventListener(t, o, !1) : n["on" + t] = o
                })
            },
            teardown: function() {
                var n = this;
                e.each(t, function(e, t) {
                    n.addEventListener ? n.removeEventListener(t, o, !1) : n["on" + t] = null
                })
            }
        };
        var o = function(t) {
            var o = t || window.event;
            if (t = e.event.fix(o), t.type = n, "detail" in o && (t.deltaY = -o.detail), "wheelDelta" in o && (t.deltaY = -o.wheelDelta), "wheelDeltaY" in o && (t.deltaY = -o.wheelDeltaY), "wheelDeltaX" in o && (t.deltaX = -o.wheelDeltaX), "deltaY" in o && (t.deltaY = o.deltaY), "deltaX" in o && (t.deltaX = o.deltaX), t.delta = t.deltaY || t.deltaX, 1 === o.deltaMode) {
                var a = 16;
                t.delta *= a, t.deltaY *= a, t.deltaX *= a
            }
            return (e.event.dispatch || e.event.handle).call(this, t)
        }
    }();
    var s = {
            fireNativeEvent: function(t, n) {
                e(t).each(function() {
                    var e, t = this;
                    t.dispatchEvent ? (e = document.createEvent("HTMLEvents"), e.initEvent(n, !0, !0), t.dispatchEvent(e)) : document.createEventObject && (e = document.createEventObject(), e.target = t, t.fireEvent("on" + n, e))
                })
            },
            bindHandlers: function() {
                var t = this;
                e.each(t, function(n, o) {
                    0 === n.indexOf("on") && e.isFunction(o) && (t[n] = function() {
                        return o.apply(t, arguments)
                    })
                })
            }
        },
        c = {
            version: t,
            modules: {},
            getOptions: function() {
                return e.extend({}, o)
            },
            setOptions: function(t, n) {
                arguments.length > 1 ? this.modules[t] && e.extend(this.modules[t].prototype.options, n) : e.extend(o, t)
            },
            addModule: function(t) {
                e.isFunction(t) && (t = t(e, window));
                var a = function(t) {
                        t.element.data(o.dataKey) || t.element.data(o.dataKey, this), n.push(this), this.options = e.extend({}, o, this.options, i(t.element), t), this.bindHandlers(), this.init.apply(this, arguments)
                    },
                    i = function(t) {
                        var n = t.data(o.optionsKey),
                            a = t.attr(o.optionsKey);
                        if (n) return n;
                        if (a) try {
                            return e.parseJSON(a)
                        } catch (i) {}
                    };
                a.prototype = t, e.extend(t, s), t.plugins && e.each(t.plugins, function(t, n) {
                    e.extend(n.prototype, s)
                });
                var r = a.prototype.destroy;
                a.prototype.destroy = function() {
                    this.options.element.removeData(this.options.dataKey);
                    for (var e = n.length - 1; e >= 0; e--)
                        if (n[e] === this) {
                            n.splice(e, 1);
                            break
                        }
                    r && r.apply(this, arguments)
                }, this.modules[t.name] = a
            },
            getInstance: function(t) {
                return e(t).data(o.dataKey)
            },
            replace: function(t, n, a) {
                var i, s = this;
                return o.styleSheetCreated || r(), e(t).each(function() {
                    var t, r = e(this);
                    i = r.data(o.dataKey), i ? i.refresh() : (n || e.each(s.modules, function(e, t) {
                        return t.prototype.matchElement.call(t.prototype, r) ? (n = e, !1) : void 0
                    }), n && (t = e.extend({
                        element: r
                    }, a), i = new s.modules[n](t)))
                }), i
            },
            refresh: function(t) {
                e(t).each(function() {
                    var t = e(this).data(o.dataKey);
                    t && t.refresh()
                })
            },
            destroy: function(t) {
                e(t).each(function() {
                    var t = e(this).data(o.dataKey);
                    t && t.destroy()
                })
            },
            replaceAll: function(t) {
                var n = this;
                e.each(this.modules, function(o, a) {
                    e(a.prototype.selector, t).each(function() {
                        this.className.indexOf("jcf-ignore") < 0 && n.replace(this, o)
                    })
                })
            },
            refreshAll: function(t) {
                if (t) e.each(this.modules, function(n, a) {
                    e(a.prototype.selector, t).each(function() {
                        var t = e(this).data(o.dataKey);
                        t && t.refresh()
                    })
                });
                else
                    for (var a = n.length - 1; a >= 0; a--) n[a].refresh()
            },
            destroyAll: function(t) {
                if (t) e.each(this.modules, function(n, a) {
                    e(a.prototype.selector, t).each(function(t, n) {
                        var a = e(n).data(o.dataKey);
                        a && a.destroy()
                    })
                });
                else
                    for (; n.length;) n[0].destroy()
            }
        };
    return window.jcf = c, c
});