var ceva = "ceva";
var currNr = -1;
(function ($) {
    $.fn.kenBurns = function (_1) {
        var _2 = 0;
        var _3 = 700;
        var _4 = 420;
        var _5 = 700;
        var _6 = 420;
        var _7 = 0;
        var _8 = 0;
        var _9 = 20;
        var _a = 25;
        var _b = 5;
        var _c = "custom";
        var _d = "navCustom";
        var _e = [];
        var _f = [];
        var _10 = [];
        var _11 = [];
        var _12 = "";
        var _13 = "";
        var _14;
        var _15 = 0;
        var _16 = 99;
        var _17 = 0;
        var _18 = 800;
        var _19 = "linear";
        var _1a;
        var _1b;
        var _1c = 0;
        var _1d = false;
        var _1e = 3000;
        var _1f = "";
        var _20 = "off";
        var _21 = "";
        var _22 = {
            imageWidth: 700,
            imageHeight: 420,
            thumbWidth: 20,
            thumbHeight: 25,
            thumbSpace: 5,
            navigationType: "custom",
            navigationDivId: "navCustom",
            hideOnCue: "off",
            buttonsAlign: "right",
            basePath: ""
        },
            _1 = $.extend(_22, _1);
        this.each(function () {
            var _23 = $(this)[0].getAttribute("id");
            ceva = _23;
            var _24 = $(this);
            _5 = _1.imageWidth;
            _6 = _1.imageHeight;
            _c = _1.navigationType;
            _d = _1.navigationDivId;
            _20 = _1.hideOnCue;
            _21 = _1.buttonsAlign;
            _9 = _1.thumbWidth;
            _a = _1.thumbHeight;
            _b = _1.thumbSpace;
            _1f = _1.basePath;
            _2 = $(this).children().length;
            jQuery(this).css({
                "position": "relative",
                "width": _5,
                "height": _6,
                "overflow": "hidden"
            });
            $(this).append("<div id='" + _23 + "-imgCon' style='height:345px !important; overflow:hidden; border: solid 1px #9ab829;'></div>");
            $(this).append("<div id='" + _23 + "-descCon'></div>");
            $(this).append("<div id='" + _23 + "-navCon' class='ie6'></div>");
            var _25 = jQuery(this).find("#" + _23 + "-imgCon");
            var _26 = jQuery(this).find("#" + _23 + "-navCon");
            var _27 = jQuery(this).find("#" + _23 + "-descCon");
            _27.css({
                "position": "relative",
                "z-index": 4
            });
            _25.css({
                "position": "relative",
                "z-index": "3"
            });
            for (i = 0; i < _2; i++) {
                _25.append($(this).children().eq(i).clone());
            }
            _14 = _25.children();
            var _28 = "<div id='" + _23 + "-descriptionBg' ";
            var _29 = "<div class=descriptionText";
            for (i = 0; i < _2; i++) {
                _28 = "<div id='" + _23 + "-descriptionBg' class='rounded' ";
                _29 = "<div class='descriptionText'";
                _27.append("<div id='" + _23 + "-description' style='position:absolute; top:0px; left:0px;'></div>");
                _10[i] = _27.children().eq(i);
                _10[i].css("visibility", "hidden");
                if (_14.eq(i).attr("data-descriptionText") != undefined) {
                    _28 += "style='position: absolute;  left:" + _14.eq(i).attr("data-descriptionX") + "px; top: " + (parseInt(_14.eq(i).attr("data-descriptionY")) - 3) + "px; z-index:98; width:" + _14.eq(i).attr("data-descriptionWidth") + "px; height:" + (parseInt(_14.eq(i).attr("data-descriptionHeight")) + 3) + "px; background-color:" + _14.eq(i).attr("data-descriptionBg") + "; opacity:" + _14.eq(i).attr("data-descriptionOpacity") + "; filter:alpha(opacity=" + _14.eq(i).attr("data-descriptionOpacity") * 100 + ");'></div>";
                    _29 += "style='position: absolute; text-shadow: 2px 2px 2px #000; left:" + _14.eq(i).attr("data-descriptionX") + "px; top: " + _14.eq(i).attr("data-descriptionY") + "px; z-index:98; width:" + _14.eq(i).attr("data-descriptionWidth") + "px; height:" + _14.eq(i).attr("data-descriptionHeight") + "px;  z-index:99; color:" + _14.eq(i).attr("data-descriptionTextColor") + "; text-align:" + _14.eq(i).attr("data-descriptionTextAlign") + "; font-size:16px;'>" + _14.eq(i).attr("data-descriptionText") + "</div>";
                    _10[i].append(_28);
                    _10[i].append(_29);
                    _11[i] = _14.eq(i).attr("data-descriptionOpacity");
                }
            }
            for (i = 0; i < _2; i++) {
                jQuery(this).children().remove(":not(#" + _23 + "-imgCon, #" + _23 + "-navCon, #" + _23 + "-descCon)");
            }
            if (_c == "arrows" || _c == "custom") {
                if (_c == "arrows") {
                    _26.append("<img src='" + _1f + "img/arrow.png' class='ie6' id='" + _23 + "-arrowleft' style='cursor:pointer; position:absolute; top: " + (_6 - 30) + "px; left: " + (_5 - 90) + "px;'/>");
                    _26.append("<img src='" + _1f + "img/pause.png' id='" + _23 + "-pausebtn' style='cursor:pointer; position:absolute; top: " + (_6 - 30) + "px; left: " + (_5 - 60) + "px;'/>");
                    _26.append("<img src='" + _1f + "img/play.png' id='" + _23 + "-playbtn' style='cursor:pointer; position:absolute; top: " + (_6 - 30) + "px; left: " + (_5 - 60) + "px;'/>");
                    if (jQuery.browser.msie || jQuery.browser.opera) {
                        _26.append("<img src='" + _1f + "img/arrowie.png' class='ie6' id='" + _23 + "-arrowright' style='cursor:pointer; position:absolute; margin:auto; top: " + (_6 - 30) + "px; left: " + (_5 - 30) + "px;'/>");
                    } else {
                        _26.append("<img src='" + _1f + "img/arrow.png' class='ie6' class='flipped' id='" + _23 + "-arrowright' style='cursor:pointer; position:absolute; top: " + (_6 - 30) + "px; left: " + (_5 - 30) + "px;'/>");
                    }
                } else {
                    _26.append(jQuery(("#" + _d)));
                }
                $(this).find("#" + _23 + "-arrowleft").css("opacity", "0.5");
                $(this).find("#" + _23 + "-pausebtn").css("opacity", "0.5");
                $(this).find("#" + _23 + "-playbtn").css("opacity", "0.5");
                $(this).find("#" + _23 + "-playbtn").css("visibility", "hidden");
                $(this).find("#" + _23 + "-arrowright").css("opacity", "0.5");
                $(this).find("#" + _23 + "-arrowleft").mouseover(function () {
                    _26.find("#" + _23 + "-arrowleft").css({
                        "opacity": "1"
                    });
                });
                $(this).find("#" + _23 + "-arrowleft").mouseout(function () {
                    _26.find("#" + _23 + "-arrowleft").css({
                        "opacity": "0.5"
                    });
                });
                $(this).find("#" + _23 + "-pausebtn").mouseover(function () {
                    _26.find("#" + _23 + "-pausebtn").css({
                        "opacity": "1"
                    });
                });
                $(this).find("#" + _23 + "-pausebtn").mouseout(function () {
                    _26.find("#" + _23 + "-pausebtn").css({
                        "opacity": "0.5"
                    });
                });
                $(this).find("#" + _23 + "-playbtn").mouseover(function () {
                    _26.find("#" + _23 + "-playbtn").css({
                        "opacity": "1"
                    });
                });
                $(this).find("#" + _23 + "-playbtn").mouseout(function () {
                    _26.find("#" + _23 + "-playbtn").css({
                        "opacity": "0.5"
                    });
                });
                $(this).find("#" + _23 + "-arrowright").mouseover(function () {
                    _26.find("#" + _23 + "-arrowright").css({
                        "opacity": "1"
                    });
                });
                $(this).find("#" + _23 + "-arrowright").mouseout(function () {
                    _26.find("#" + _23 + "-arrowright").css({
                        "opacity": "0.5"
                    });
                });
                $(this).find("#" + _23 + "-arrowleft").click(function () {
                    if (currNr == 0) {
                        _2a(_2 - 1);
                    } else {
                        _2a(currNr - 1);
                    }
                });
                $(this).find("#" + _23 + "-pausebtn").click(function () {
                    if (_1d == true) {
                        _1d = false;
                    } else {
                        _1d = true;
                    }
                    _26.find("#" + _23 + "-pausebtn").css("visibility", "hidden");
                    _26.find("#" + _23 + "-playbtn").css("visibility", "visible");
                });
                $(this).find("#" + _23 + "-playbtn").click(function () {
                    _1d = false;
                    _2b();
                    _26.find("#" + _23 + "-pausebtn").css("visibility", "visible");
                    _26.find("#" + _23 + "-playbtn").css("visibility", "hidden");
                });
                $(this).find("#" + _23 + "-arrowright").click(function () {
                    _2b();
                });
                if (!jQuery.browser.msie) {
                    $(this).mouseover(function () {
                        _26.stop();
                        _26.animate({
                            opacity: 1
                        }, 1000);
                    });
                    $(this).mouseout(function () {
                        _26.stop();
                        _26.animate({
                            opacity: 0
                        }, 1000);
                    });
                }
            }
            var _2c = 0;
            if (_21 == "right") {
                _2c = _5 - (_b + _9) * (_2) - 5;
            }
            if (_21 == "center") {
                _2c = _5 / 2 - ((_b + _9) * (_2)) * 0.5;
            }
            if (_c == "numbers") {
                for (i = 0; i < _2; i++) {
                    _26.append("<div class='rounded' style='position:absolute; cursor:pointer; font-size:11px; background-color: #000000; padding:4px; padding-left:8px; padding-right:8px; left:" + _2c + "px; top:" + (_6 - _a - 5) + "px;'>" + (i + 1) + "</div>");
                    if (i != 0) {
                        _26.children().eq(i).css("opacity", "0.7");
                    }
                    _2c += _9 + _b;
                    _26.children().eq(i).click(function () {
                        _2a(_26.children().index(jQuery(this)));
                    });
                    _26.children().eq(i).mouseout(function () {
                        if (_26.children().index(jQuery(this)) != currNr) {
                            jQuery(this).css("opacity", "0.7");
                        }
                    });
                    _26.children().eq(i).mouseover(function () {
                        if (_26.children().index(jQuery(this)) != currNr) {
                            jQuery(this).css("opacity", "1");
                        }
                    });
                }
            }
            _26.css({
                "position": "absolute",
                "margin": "auto",
                "top": "0px",
                "z-index": "99"
            });
            _14.css({
                "position": "absolute",
                "margin": "auto"
            });
            var _2d = 0;
            var _2e = false;
            for (i = 0; i < _2; i++) {
                _14.eq(i).load(_2f);
            }
            function _2f() {
                _2d++;
                if (_2d >= _14.length) {
                    _30();
                }
            };
            _2d++;
            setTimeout(_31, 5000);

            function _31() {
                if (_2e == false) {
                    _30();
                }
            };

            function _30() {
                for (i = 0; i < _25.children().length; i++) {
                    if (_20 == "on") {
                        _25.children().eq(i).css("opacity", "0");
                    }
                }
                _2e = true;
                _24.css("opacity", 1);
                for (i = 0; i < _2; i++) {
                    _e[i] = _14.eq(i).width();
                    _f[i] = _14.eq(i).height();
                }
                _2a(0);
            };

            function _32() {
                _14.eq(_15).css("visibility", "hidden");
            };

            function _2a(arg) {
                if (arg == currNr) {
                    return;
                }
                if (currNr >= 0) {
                    _15 = currNr;
                    setTimeout(_32, _18);
                    _14.eq(currNr).css("z-index", _16);
                }
                for (i = 0; i < _2; i++) {
                    if (i == currNr || i == arg) {
                        _14.eq(i).css("visibility", "visible");
                    } else {
                        _14.eq(i).css("visibility", "hidden");
                    }
                }
                _14.eq(arg).css("z-index", _16 + 1);
                _16++;
                if (_14.eq(arg).attr("data-slideshowTime") === 0 || _14.eq(arg).attr("data-slideshowTime") == undefined) {
                    _17 = 5;
                } else {
                    _17 = parseFloat(_14.eq(arg).attr("data-slideshowTime"));
                }
                if (_14.eq(arg).attr("data-transitionTime") === 0 || _14.eq(arg).attr("data-transitionTime") == undefined) {
                    _1e = 5;
                } else {
                    _1e = parseFloat(_14.eq(arg).attr("data-transitionTime")) * 1000;
                }
                _12 = _14.eq(arg).attr("data-initialPosition");
                _13 = _14.eq(arg).attr("data-finalPosition");
                _7 = _e[arg];
                _8 = _f[arg];
                if (_7 === 0) {
                    _7 = _5;
                    _8 = _6;
                }
                if (_14.eq(arg).attr("data-link") != undefined) {
                    _14.eq(arg).css("cursor", "pointer");
                    _14.eq(arg).click(function () {
                        location.href = _14.eq(arg).attr("data-link");
                    });
                }
                var _33 = -(_7 * parseFloat(_14.eq(arg).attr("data-initialZoom")) - _5) * 0.5;
                var _34 = _33 * 2;
                var _35 = -(_8 * parseFloat(_14.eq(arg).attr("data-initialZoom")) - _6) * 0.5;
                var _36 = _35 * 2;
                if (_12 == "topLeft") {
                    _14.eq(arg).animate({
                        left: 0,
                        top: 0,
                        width: parseFloat(_14.eq(arg).attr("data-initialZoom")) * _7
                    }, 0);
                }
                if (_12 == "topCenter") {
                    _14.eq(arg).animate({
                        left: _33,
                        top: 0,
                        width: parseFloat(_14.eq(arg).attr("data-initialZoom")) * _7
                    }, 0);
                }
                if (_12 == "topRight") {
                    _14.eq(arg).animate({
                        left: _34,
                        top: 0,
                        width: parseFloat(_14.eq(arg).attr("data-initialZoom")) * _7
                    }, 0);
                }
                if (_12 == "middleLeft") {
                    _14.eq(arg).animate({
                        left: 0,
                        top: _35,
                        width: parseFloat(_14.eq(arg).attr("data-initialZoom")) * _7
                    }, 0);
                }
                if (_12 == "middleCenter") {
                    _14.eq(arg).animate({
                        left: _33,
                        top: _35,
                        width: parseFloat(_14.eq(arg).attr("data-initialZoom")) * _7
                    }, 0);
                }
                if (_12 == "middleRight") {
                    _14.eq(arg).animate({
                        left: _34,
                        top: _35,
                        width: parseFloat(_14.eq(arg).attr("data-initialZoom")) * _7
                    }, 0);
                }
                if (_12 == "bottomLeft") {
                    _14.eq(arg).animate({
                        left: 0,
                        top: _36,
                        width: parseFloat(_14.eq(arg).attr("data-initialZoom")) * _7
                    }, 0);
                }
                if (_12 == "bottomCenter") {
                    _14.eq(arg).animate({
                        left: _33,
                        top: _36,
                        width: parseFloat(_14.eq(arg).attr("data-initialZoom")) * _7
                    }, 0);
                }
                if (_12 == "bottomRight") {
                    _14.eq(arg).animate({
                        left: _34,
                        top: _36,
                        width: parseFloat(_14.eq(arg).attr("data-initialZoom")) * _7
                    }, 0);
                }
                _33 = -(_7 * parseFloat(_14.eq(arg).attr("data-finalZoom")) - _5) * 0.5;
                _34 = _33 * 2;
                _35 = -(_8 * parseFloat(_14.eq(arg).attr("data-finalZoom")) - _6) * 0.5;
                _36 = _35 * 2;
                if (_13 == "topLeft") {
                    _14.eq(arg).animate({
                        left: 0,
                        top: 0,
                        width: parseFloat(_14.eq(arg).attr("data-finalZoom")) * _7
                    }, {
                        duration: _1e,
                        queue: false
                    }, _19);
                }
                if (_13 == "topCenter") {
                    _14.eq(arg).animate({
                        left: _33,
                        top: 0,
                        width: parseFloat(_14.eq(arg).attr("data-finalZoom")) * _7
                    }, {
                        duration: _1e,
                        queue: false
                    }, _19);
                }
                if (_13 == "topRight") {
                    _14.eq(arg).animate({
                        left: _34,
                        top: 0,
                        width: parseFloat(_14.eq(arg).attr("data-finalZoom")) * _7
                    }, {
                        duration: _1e,
                        queue: false
                    }, _19);
                }
                if (_13 == "middleLeft") {
                    _14.eq(arg).animate({
                        left: 0,
                        top: _35,
                        width: parseFloat(_14.eq(arg).attr("data-finalZoom")) * _7
                    }, {
                        duration: _1e,
                        queue: false
                    }, _19);
                }
                if (_13 == "middleCenter") {
                    _14.eq(arg).animate({
                        left: _33,
                        top: _35,
                        width: parseFloat(_14.eq(arg).attr("data-finalZoom")) * _7
                    }, {
                        duration: _1e,
                        queue: false
                    }, _19);
                }
                if (_13 == "middleRight") {
                    _14.eq(arg).animate({
                        left: _34,
                        top: _35,
                        width: parseFloat(_14.eq(arg).attr("data-finalZoom")) * _7
                    }, {
                        duration: _1e,
                        queue: false
                    }, _19);
                }
                if (_13 == "bottomLeft") {
                    _14.eq(arg).animate({
                        left: 0,
                        top: _36,
                        width: parseFloat(_14.eq(arg).attr("data-finalZoom")) * _7
                    }, {
                        duration: _1e,
                        queue: false
                    }, _19);
                }
                if (_13 == "bottomCenter") {
                    _14.eq(arg).animate({
                        left: _33,
                        top: _36,
                        width: parseFloat(_14.eq(arg).attr("data-finalZoom")) * _7
                    }, {
                        duration: _1e,
                        queue: false
                    }, _19);
                }
                if (_13 == "bottomRight") {
                    _14.eq(arg).animate({
                        left: _34,
                        top: _36,
                        width: parseFloat(_14.eq(arg).attr("data-finalZoom")) * _7
                    }, {
                        duration: _1e,
                        queue: false
                    }, _19);
                }
                for (i = 0; i < _14.length; i++) {
                    if (i == currNr || i == arg) {
                        _10[i].css("visibility", "visible");
                    } else {
                        _10[i].css("visibility", "hidden");
                    }
                }
                _10[arg].animate({
                    top: -15
                }, 0).animate({
                    top: 0
                }, 1000);
                if (currNr >= 0) {
                    _10[arg].children().eq(0).stop();
                    _10[arg].children().eq(1).stop();
                    _10[currNr].children().eq(0).animate({
                        opacity: 0
                    }, {
                        queue: false,
                        duration: _18
                    });
                    _10[currNr].children().eq(1).animate({
                        opacity: 0
                    }, {
                        queue: false,
                        duration: _18
                    });
                    _10[arg].children().eq(0).animate({
                        opacity: 0
                    }, 0);
                    _10[arg].children().eq(1).animate({
                        opacity: 0
                    }, 0);
                    _10[arg].children().eq(0).animate({
                        opacity: _11[arg]
                    }, 1000).delay(_17 * 1000 - 2000).animate({
                        opacity: 0
                    }, 1000);
                    _10[arg].children().eq(1).animate({
                        opacity: 1
                    }, 1000).delay(_17 * 1000 - 2000).animate({
                        opacity: 0
                    }, 1000);
                    if (_c == "numbers") {
                        _26.children().eq(currNr).css("opacity", "0.7");
                        _26.children().eq(arg).css("opacity", "1");
                    }
                    if (_c == "bullets") {
                        jQuery("#bullets").children().eq(currNr).css("opacity", "0.5");
                        jQuery("#bullets").children().eq(arg).css("opacity", "1");
                    }
                }
                _14.eq(arg).animate({
                    opacity: 0
                }, {
                    queue: false,
                    duration: 0
                });
                _14.eq(arg).animate({
                    opacity: 1
                }, {
                    queue: false,
                    duration: _18
                });
                currNr = arg;
                _1c = 0;
            };

            function _37() {
                if (_1d == false) {
                    _1c++;
                }
                if (_1c >= _17) {
                    _2b();
                }
            };

            function _2b() {
                if (currNr == _2 - 1) {
                    _2a(0);
                } else {
                    _2a(currNr + 1);
                }
            };
            _1b = setInterval(_37, 1000);
            $.fn.kenBurns.gotoImage = function (arg) {
                _2a(arg);
            };
            return this;
        });
    };
})(jQuery);
