
appcan.extend(function(a, b, c) {
    var d = appcan.require("dom"),
    e = appcan.require("window"),
    f = appcan.require("locStorage"),
    g = appcan.require("view");
    function h() {
        return "ontouchstart" in window ? void 0 : !0
    }
    function i(a, b, c) {
        d(a).on(h() ? "mousedown": "touchstart",
        function() {
            appcan.touch(b, c)
        })
    }
    function j(a) {
        var b = a.attr("data-checked") || "false";
        b = "false" == b ? "true": "false",
        a.attr("data-checked", b),
        "false" == b ? a.addClass("switch-active") : a.removeClass("switch-active"),
        "false" == b ? a.removeClass("bc-head") : a.addClass("bc-head")
    }
    function k(a, b, c) {
        "function" == typeof b && (c = b, b = null);
        for (var e = d(a), f = 0; f < e.length; f++) {
            var g = d(e[f]).attr("data-checked") || "false";
            "false" == g ? d(e[f]).removeClass(b ? b: "bc-head") : d(e[f]).addClass(b ? b: "bc-head")
        }
        d(a).on("tap",
        function(a) {
            var e = d(a.currentTarget),
            f = e.attr("data-checked") || "false";
            f = "false" == f ? "true": "false",
            e.attr("data-checked", f),
            "false" == f ? e.removeClass(b ? b: "bc-head") : e.addClass(b ? b: "bc-head"),
            c(e, f)
        })
    }
    function l(a, b) {
        d("select", d(a)).on("change",
        function(a) {
            var c = d(a.currentTarget);
            appcan.selectChange(a.currentTarget),
            b && b(c, c.val())
        })
    }
    function m(a, b) {
        var c = window.event.currentTarget || window.event.srcElement,
        e = window.event.type,
        f = "ontouchstart" in window,
        g = d(c),
        h = g.data("inline_event_data");
        h || (h = {},
        h.clickFun = g.attr("onclick"), h.startFun = g.attr("ontouchstart") || g.attr("onmousedown"), h.endFun = g.attr("ontouchend") || g.attr("onmouseup"), h.startClassName = a, h.startCallFun = b, h.endClassName = h.startClassName, h.endCallFun = h.startCallFun, g.data("inline_event_data", h), g.attr("onclick", ""), g.attr("ontouchstart", ""), g.attr("onmousedown", ""), g.attr("ontouchend", ""), g.attr("onmouseup", ""), f ? (g.on("touchstart",
        function() {
            h.startClassName && d(this).addClass(h.startClassName)
        }), g.on("touchend",
        function() {
            h.endClassName && d(this).removeClass(h.endClassName)
        }), g.on("touchcancel",
        function() {
            h.endClassName && d(this).removeClass(h.endClassName)
        }), g.on("tap",
        function() {
            appcan.isFunction(h.startCallFun) && h.startCallFun.apply(this, [].slice.call(arguments));
            var a = new Function(h.clickFun);
            a()
        })) : (g.on("mousedown",
        function() {
            if (h.startClassName) {
                var a = this;
                d(this).addClass(h.startClassName),
                setTimeout(function() {
                    d(a).removeClass(h.endClassName)
                },
                300)
            }
        }), g.on("mouseup",
        function() {
            h.endClassName && d(this).removeClass(h.endClassName)
        }), g.on("click",
        function() {
            appcan.isFunction(h.startCallFun) && h.startCallFun.apply(this, [].slice.call(arguments));
            var a = new Function(h.clickFun);
            a()
        })), g.addClass(h.startClassName), g.on("webkitTransitionEnd",
        function() {}))
    }
    function n(a, b) {
        var c;
        a = a || window.event,
        c = a.currentTarget ? a.currentTarget.previousElementSibling: a.previousElementSibling;
        var e = d(c);
        "INPUT" === e.prop("tagName") && ("checkbox" === e.attr("type") && (c.checked = !c.checked), "radio" !== e.attr("type") || c.checked || (c.checked = "checked")),
        appcan.isFunction(b) && b(a, c.checked)
    }
    function o() {
        var a = window.navigator.platform;
        if (a.toLowerCase().indexOf("win") > -1 || a.toLowerCase().indexOf("wow") > -1) {
            var b = f.getVal("defaultfontsize");
            b && d("body").css("font-size", b)
        }
    }
    var p = function(a) {
        var b = d(a)[0];
        if (b) {
            var c = b.parentElement;
            if (c) {
                var e = c.getElementsByTagName("div")[0],
                f = b.options[b.selectedIndex].text;
                e && d(e).html(f)
            }
        }
    },
    q = function(a, b) {
        a = a || window.event;
        var c = a.currentTarget.nextElementSibling;
        if ("DIV" == c.nodeName) {
            var e = d(c);
            b ? e.removeClass("col-c") : e.addClass("col-c")
        }
    },
    r = function(a) {
        return parseInt(a)
    },
    s = function(a) {
        a.cancelClick || (a.cancelClick = !0, a.addEventListener("click",
        function() {
            event.stopPropagation()
        },
        !0))
    };
    function t(a, b, c, f, g, h) {
        if (a) {
            var i = d("#" + a);
            e.openPopover({
                name: h ? h: a,
                url: b,
                left: c,
                top: f,
                width: i.width(),
                height: i.height(),
                type: g || 0
            })
        }
    }
    var u = function() {
        var a = {
            evaluate: /<%([\s\S]+?)%>/g,
            interpolate: /<%=([\s\S]+?)%>/g,
            escape: /\${([\s\S]+?)}/g
        },
        b = [].slice.call(arguments);
        return b.push(a),
        g.render.apply(this, b)
    },
    v = function() {
        var a = {
            evaluate: /<%([\s\S]+?)%>/g,
            interpolate: /<%=([\s\S]+?)%>/g,
            escape: /\${([\s\S]+?)}/g
        },
        b = [].slice.call(arguments);
        return b.push(a),
        g.appendRender.apply(this, b)
    };
    function w(a, b, c, d, e) {
        a && appcan.window.open({
            name: a,
            data: b,
            aniId: c || 10,
            type: d || 0,
            animDuration: e || 300
        })
    }
    function x(a) {
        a = a || -1,
        e.close(a)
    }
    function y(a, b) {
        return f.setVal(a, b)
    }
    function z(a) {
        return f.getVal(a)
    }
    function A(a, b) {
        a && b && e.evaluateScript({
            name: a,
            scriptContent: b
        })
    }
    function B() {
        e.setBounceType("0", "rgba(255,255,255,0)", 0),
        e.setBounceType("1", "rgba(255,255,255,0)", 0)
    }
    function C(a) {
        var b = 0;
        if (!a) return b;
        if (appcan.isArray(a)) return a.length;
        if (!appcan.isPlainObject(a)) return b;
        for (var c in a) b++;
        return b
    }
    function D(a, b, c, d, e) {
        var f = b.match(/(first:|last:)(\"|\'*)([^\"\']*)(\"|\'*)/);
        if (f) return f[1] == c ? '"' == f[2] || "'" == f[2] ? f[3] : a[f[3]] : f[1] == d && e > 1 ? "": void 0
    }
    function E(a, b, c, d, e) {
        return a.replace(/\$\{([^\}]*)\}/g,
        function(a, f) {
            if (f.match(/index:/)) return c;
            if (f.match(/cb:/) && e) return e(b, f.match(/cb:(.*)/));
            if (0 == c) {
                var g = D(b, f, "first:", "last:", d);
                if (g) return g
            }
            if (c == d - 1) {
                var g = D(b, f, "last:", "first:", d);
                if (g) return g
            }
            var h = f.split("."),
            i = b;
            for (var j in h) i = i[h[j]];
            return i || ""
        })
    }
    var F = function(a, b, c, d, e) {
        var f = "",
        g = 0;
        for (var h in b) {
            e && e(0, h, b[h]);
            var i = E(a, b[h], g, c, d);
            e && e(1, i, b[h]),
            f += i,
            g++
        }
        return f
    };

    function G(a, b, c) {
        return E(a, b, -1, -1, c)
    }
    d(document).ready(function() {
        o()
    }),
    c.exports = {
        elementFor: n,
        touch: m,
        initFontsize: o,
        openPopoverByEle: t,
        resizePopoverByEle: e.resizePopoverByEle,
        tmpl: u,
        tmplAppend: v,
        openWinWithUrl: w,
        closeWin: x,
        closePopover: e.closePopover,
        setLocVal: y,
        getLocVal: z,
        execScriptInWin: A,
        bringPopoverToFront: e.bringPopoverToFront,
        initBounce: B,
        evaluatePopoverScript: e.evaluatePopoverScript,
        alert: e.alert,
        getObjLength: C,
        getTempCallback: D,
        temp: E,
        tempRenderList: F,
        tempRender: G,
        stopPropagation: s,
        toInt: r,
        selectChange: p,
        fold: q,
        button: i,
        select: l,
        "switch": k,
        switchBtn: k,
        updateSwitch: j
    }
}),
appcan.ready(function() {
    var a = uexWidgetOne.iOS7Style; ("1" == a && "1" != uexWidgetOne.isFullScreen) && $("body").addClass("uh_ios7")
});