
(function(A) {
    A.fn.jFlow = function(D) {

        $(document).everyTime(7000, "hide", function(i) {
            Next();
            InitialDotes();
        }, 99999);


        var E = A.extend({}, A.fn.jFlow.defaults, D);
        var F = 0;
        var B = A(".jFlowControl").length;

        A(E.slides).before('<div id="jFlowSlide"></div>').appendTo("#jFlowSlide");
        A(E.slides).find("div").each(function() {
            A(this).before('<div class="jFlowSlideContainer"></div>').appendTo(A(this).prev())
        });


        var C = function(G) {
            A("#jFlowSlide").css({ position: "relative", width: E.width, height: E.height, overflow: "hidden" });
            A(E.slides).css({ position: "relative", width: A("#jFlowSlide").width() * A(".jFlowControl").length + "px", height: A("#jFlowSlide").height() + "px", overflow: "hidden" });


            A(E.slides).children().css({ position: "relative", width: A("#jFlowSlide").width() + "px", height: A("#jFlowSlide").height() + "px", "float": "left" }); A(E.slides).css({ marginLeft: "-" + (F * A(E.slides).find(":first-child").width() + "px") })
        } ();

        A(".jFlowPrev").click(function() {
            Prev();
        });
        A(".jFlowNext").click(function() {
            Next();
        })
        A(".jFlowPrev,.jFlowNext").click(function() {

            InitialDotes();
            $(document).stopTime("hide");
        })
        function Prev() {
            if (F > 0) {
                F--
            }
            else {
                F = B - 1
            }
            A(".jFlowControl").removeClass("jFlowSelected");
            A(E.slides).animate(
            {
                marginLeft: "-" + (F * A(E.slides).find(":first-child").width() + "px")
            }, E.duration);

            A(".jFlowControl").eq(F).addClass("jFlowSelected");
        }
        function Next() {
            if (F < B - 1) {
                F++
            } else {
                F = 0
            } A(".jFlowControl").removeClass("jFlowSelected");
            A(E.slides).animate(
            {
                marginLeft: "-" + (F * A(E.slides).find(":first-child").width() + "px")
            }, E.duration);
            A(".jFlowControl").eq(F).addClass("jFlowSelected");
        }
        function InitialDotes() {
            var number = parseInt($(".jFlowSelected").attr("number"), 0);
            var children = $(".dot-nav").children().removeClass("active").eq(number).addClass("active");
        }
    };
    A.fn.jFlow.defaults = { easing: "swing", duration: 500, width: "100%" }
})(jQuery);
