/*
* Author: Digital Zoom Studio
* Website: http://digitalzoomstudio.net/
* Portfolio: http://codecanyon.net/user/ZoomIt/portfolio
* This is not free software
* Version: 2.0
*/
(function (t) {
    t.fn.flipbook = function (f) {
        var c = 0, a, p, h = 0, d = 0, m = 0, b = 0, l = !1, u = !1, j = 700, g = 30, r = 0, k = 999, i = "on", G = "on", H = "onf", s = "off", B = !1, I = !1, J = !1, q = 0, o = 0, n = 2, v = !1, C = 0, D = "off", w = "off", x = !0, f = t.extend({ totalWidth: -1, totalHeight: -1, coverPage: void 0, shadowWidth: void 0, miscAction: void 0, settings_zoom: "on", settings_slideshow: "on", settings_resize: "off", settings_slideshow_autoplay: "off", settings_slideshow_time: 5, settings_flip_sound: "off" }, f); this.each(function () {
            function E() {
                a.find(".zoom_page").css({ visibility: "hidden" });
                a.find(".zoom_page").animate({ opacity: 0 }, 500); a.find(".zoom_page").children().remove(); v = !1
            } function t(e) { D = "on"; x = !1; o = e.clientX - a.children(".pages").offset().left; u || (H == "on" && B == !0 && l == !0 && (a.find(".page").eq(b + 1).css("z-index", k++), a.find(".page_left_con").eq(b + 1).stop(), a.find(".page_left_con").eq(b + 1).css({ left: o, width: d - (d / 2 + o / d * d / 2) }), a.find(".page_right_con").eq(b + 1).stop(), a.find(".page_right_con").eq(b + 1).css({ width: d - (d / 2 + o / d * d / 2) }), I = !0), K()) } function K() {
                o > d - g * 2 && x == !1 ? L(b + 1) : o < g * 2 &&
x == !1 ? M() : I != !0 && N()
            } function F() { b < h - 1 && y(b + 1) } function Q() { y(a.find(".pages").children().index(jQuery(this))) } function y(e) {
                if (e != b && u != !0) {
                    L(e); E(); l = u = !0; a.find(".page").eq(e).css("display") == "none" && a.find(".page").eq(e).css("display", "inline"); r = j; e < b && (r = j - 100); a.find(".shadow_left").eq(e).animate({ opacity: 0 }, j); a.find(".shadow_right").eq(e).animate({ opacity: 0 }, j); i == "on" && G == "on" && (e == 0 ? a.children(".pages").animate({ left: -d / 4 }, { queue: !1, duration: j }) : e == h - 1 ? a.children(".pages").animate({ left: d /
4
                    }, { queue: !1, duration: j }) : a.children(".pages").animate({ left: 0 }, { queue: !1, duration: j })); if (i == "on" && e == 0) { for (c = 2; c < h; c++) a.find(".page").eq(c).css("display", "none"); a.find(".page_left").eq(e + 1).animate({ left: -d / 2 + 10 }, { queue: !1, duration: j - 100, complete: z }); a.find(".page_left_con").eq(e + 1).animate({ width: 0, left: d / 2 }, { queue: !1, duration: j - 100 }) } else a.find(".page_left_con").eq(e).animate({ width: d / 2 + 5, left: 0 }, { queue: !1, duration: r, complete: z }); e > b && (r = j - 100); if (i == "on" && e == h - 1) {
                        for (c = 0; c < h - 2; c++) a.find(".page").eq(c).css("display",
"none"); a.find(".page_right").eq(e - 1).animate({ right: -d / 2 + 10 }, { queue: !1, duration: j - 200, complete: z }); a.find(".page_right_con").eq(e - 1).animate({ width: 0, right: d / 2 }, { queue: !1, duration: j - 200 })
                    } else a.find(".page_right_con").eq(e).animate({ width: d / 2, right: 0 }, { queue: !1, duration: r, complete: z }); (jQuery.browser.msie == void 0 || jQuery.browser.msie == !0 && jQuery.browser.version > 8) && f.settings_flip_sound == "on" && jQuery(".flip-sound").length > 0 && jQuery(".flip-sound")[0].play(); C = 0; b = e
                } 
            } function z() {
                l = u = !1; a.find(".shadow_left").eq(b).css("display",
"none"); a.find(".shadow_right").eq(b).css("display", "none"); for (c = 0; c < h; c++) c == b - 1 || c == b || c == b + 1 ? a.find(".page").eq(c).css("display", "inline") : a.find(".page").eq(c).css("display", "none"); K()
            } function O() { a.find(".page").eq(b - 1).css("z-index", k - 100); a.find(".page").eq(b + 1).css("z-index", k - 101) } function N() {
                l != !1 && (l = !1, a.find(".page_left_con").eq(b + 1).stop(), a.find(".page_left_con").eq(b + 1).animate({ left: d, width: 0 }, { queue: !1, duration: 200 }), a.find(".page_right_con").eq(b + 1).animate({ width: 0 }, { queue: !1,
                    duration: 250, complete: O
                }), i == "on" && b == 1 && (a.find(".page_left_con").eq(b).animate({ left: 0 }, { queue: !1, duration: 250 }), a.find(".page_left").eq(b).animate({ left: 0 }, { queue: !1, duration: 250 })), s == "on" && b == h - 2 && (a.find(".page_right_con").eq(b).animate({ right: 0 }, { queue: !1, duration: 250 }), a.find(".page_right").eq(b).animate({ right: 0 }, { queue: !1, duration: 250 })), b > 0 && (a.find(".page_left_con").eq(b - 1).animate({ width: 0 }, { queue: !1, duration: 250, complete: O }), a.find(".page_right_con").eq(b - 1).animate({ width: 0, right: d },
{ queue: !1, duration: 200 })))
            } function M() {
                if (!(b < 1) && !l) if (a.find(".page").eq(b - 1).css("z-index") < k - 50 && a.find(".page").eq(b - 1).css("z-index", k++), a.find(".shadow_left").eq(b - 1).css("display", "inline"), a.find(".shadow_right").eq(b - 1).css("display", "inline"), a.find(".page").eq(b - 1).css("z-index", k++), l = !0, a.find(".shadow_left").eq(b - 1).css({ opacity: 0.4 }), a.find(".shadow_right").eq(b - 1).css({ opacity: 0.4 }), a.find(".page_left_con").eq(b - 1).css({ left: 0, width: 0 }), a.find(".page_right_con").eq(b - 1).css({ right: d,
                    width: 0
                }), i == "on" && b == 1) { a.find(".page_left_con").eq(b).animate({ left: g }, { queue: !1, duration: 250 }); a.find(".page_right_con").eq(b - 1).animate({ width: g, right: d - g * 2 }, { queue: !1, duration: 250 }); a.find(".page_right").eq(b - 1).css({ right: -d / 2 }); a.find(".page_left").eq(b).animate({ left: -g }, { queue: !1, duration: 250 }); for (c = 2; c < h; c++) a.find(".page").eq(c).css("display", "none") } else a.find(".page_left_con").eq(b - 1).animate({ width: g + 1 }, { queue: !1, duration: 200 }), a.find(".page_right_con").eq(b - 1).animate({ width: g, right: d -
g * 2
                }, { queue: !1, duration: 250 }), a.find(".page_right").eq(b - 1).css({ right: 0 })
            } function L(e) {
                p = a.find(".page").eq(e); p.css("z-index") < k - 50 && p.css("z-index", k++); if (!l) if (l = !0, a.find(".shadow_left").eq(e).css("display", "inline"), a.find(".shadow_right").eq(e).css("display", "inline"), a.find(".page").eq(e).css("z-index", k++), a.find(".page").eq(e).css("display", "inline"), a.find(".shadow_left").eq(e).css({ opacity: 0.4 }), a.find(".shadow_right").eq(e).css({ opacity: 0.4 }), a.find(".page_left_con").eq(e).css({ left: d,
                    width: 0
                }), a.find(".page_right_con").eq(e).css({ right: 0, width: 0 }), i == "on" && a.find(".page_left").eq(e).css({ left: 0 }), s == "on" && a.find(".page_right").eq(e).css({ right: 0 }), s == "on" && b == h - 2) { a.find(".page_right_con").eq(b).animate({ right: g }, { queue: !1, duration: 250 }); a.find(".page_right").eq(b).animate({ right: -g }, { queue: !1, duration: 250 }); a.find(".page_left_con").eq(e).animate({ width: g, left: d - g * 2 }, { queue: !1, duration: 250 }); for (c = 0; c < h - 2; c++) a.find(".page").eq(c).css("display", "none") } else a.find(".page_left_con").eq(e).animate({ left: d -
g * 2, width: g
                }, { queue: !1, duration: 250 }), a.find(".page_right_con").eq(e).animate({ width: g + 1 }, { queue: !1, duration: 200 })
            } function R() { var b = []; b.push("zoom"); b.push("flashden"); b.push("activeden"); b.push("envato"); b.push("localhost"); b.push("127.0.0.1"); for (c = 0; c < b.length; c++) window.location.toString().indexOf(b[c]) > -1 && (J = !0); J == !1 && a.css("display", "none") } function A(b) {
                v != !0 && (v = !0, b.children().clone().appendTo(".zoom_page"), a.find(".zoom_page").css({ visibility: "visible", "-moz-transform": "scale(" + n + ")",
                    "-webkit-transform": "scale(" + n + ")", "-o-transform": "scale(" + n + ")"
                }), jQuery.browser.msie ? (a.find(".zoom_page").css({ opacity: 1 }), a.find(".zoom_page").css("zoom", n * 100 + "%")) : (a.find(".zoom_page").css("zoom", 1), a.find(".zoom_page").animate({ opacity: 1 }, 500)), a.find(".zoom_page").mousemove(P))
            } function S() { D != "on" && w == "on" && C++; C >= f.settings_slideshow_time && F() } function P(b) {
                a.children(".pages").offset(); b = b.pageY - a.children(".pages").offset().top; total_width = a.width() * n; total_height = a.height() * n; q = b / (total_height /
n) * -(total_height / n); q > 0 && (q = 0); jQuery.browser.msie == !0 && jQuery.browser.version < 9 && q < -total_height / 4 && (q = -total_height / 4); a.find(".zoom_page").css("top", q)
            } a = jQuery(this); h = a.children().length; d = f.totalWidth != -1 ? f.totalWidth : a.width(); m = f.totalHeight != -1 ? f.totalHeight : a.height; if (f.coverPage != void 0) i = f.coverPage; if (f.shadowWidth != void 0) g = f.shadowWidth; s = i; f.settings_slideshow_autoplay == "on" && (w = "on", jQuery("#flipbook_btn_play").css("display", "none"), jQuery("#flipbook_btn_pause").css("display", "inline-block"));
            a.css("opacity") == 0 && (a.delay(100).animate({ opacity: 1 }, 1E3), jQuery(".flipbook-preloader").delay(100).fadeOut("slow")); f.miscAction != void 0 && R(); (function () {
                a.append('<div class="zoom_page"></div>'); a.append('<div class="pages"></div>'); for (c = 0; c < h; c++) a.find(".pages").append('<div class="page"><div class="page_left_con"><div class="shadow_left"></div><div class="page_left"></div></div><div class="page_right_con"><div class="shadow_right"></div><div class="page_right"></div></div></div>'), f.settings_resize ==
"on" && (a.children().eq(0).width(d), a.children().eq(0).height(m)), i == "on" && c == 0 || a.find(".page_left").eq(c).append(a.children().eq(0).clone()), (s != "on" || c < h - 1) && a.find(".page_right").eq(c).append(a.children().eq(0).clone()), a.children().eq(0).remove(); for (c = 0; c < h; c++) i == "on" && c == 0 ? a.find(".page_right").eq(c).css("right", -d / 2) : a.find(".page_right").eq(c).css("right", 0); a.css({ width: d, height: m }); a.find(".page_left_con").css({ width: 0, height: m }); i == "on" && G == "on" && a.children(".pages").css("left", -d / 4);
                a.find(".page").eq(0).css("z-index", k++); a.find(".page_left").css("width", d); a.find(".page_right").css("width", d); p = a.find(".page"); p.css("width", d); p.css("height", m); a.find(".shadow_left").css({ width: d / 2, height: m }); a.find(".shadow_right").css({ width: d / 2, height: m }); a.find(".page_left_con").css({ left: 0, width: d / 2 }); a.find(".page_right_con").css({ width: d / 2, height: m }); for (c = 1; c < a.find(".page").length; c++) a.find(".page").eq(c).css("display", "none"); a.find(".shadow_left").css("opacity", 0); a.find(".shadow_right").css("opacity",
0); a.children(".pages").mousemove(t); a.find(".zoom_page").mousemove(P); H == "on" && (a.mousedown(function () { B = !0 }), a.mouseup(function () { B = !1; o < d / 2 && F() })); f.settings_zoom == "on" && (a.find(".page_left_con").dblclick(function () { a.find(".zoom_page").css({ left: 0 }); var b = jQuery(this).children().eq(1); A(b) }), a.find(".page_right_con").dblclick(function () { a.find(".zoom_page").css({ left: -d }); i == "on" && b == 0 && a.find(".zoom_page").css({ left: 0 }); var c = jQuery(this).children().eq(1); A(c) }), a.find(".zoom_page").dblclick(function () { E() }));
                a.find(".page").click(Q); a.mouseleave(N); a.mouseleave(function () { D = "off"; x = !0 }); f.settings_slideshow == "on" && (slideshow_intervalId = setInterval(S, 1E3))
            })(); jQuery.fn.flipbook.gotoItem = function (a) { y(a) }; jQuery.fn.flipbook.playSlideshow = function () { w = "on" }; jQuery.fn.flipbook.pauseSlideshow = function () { w = "off" }; jQuery.fn.flipbook.zoom = function () { v ? E() : i && b == 0 ? A(a.find(".page_right_con").eq(b).children().eq(1)) : A(a.find(".page_left_con").eq(b).children().eq(1)) }; jQuery.fn.flipbook.gotoNext = function () { F() };
            jQuery.fn.flipbook.gotoPrev = function () { b > 0 && (M(), y(b - 1)) }; return this
        })
    } 
})(jQuery);
