(function (a) {
    var b = function (b, c) {
        var d = a.extend({}, a.fn.nivoSlider.defaults, c); var e = { currentSlide: 0, currentImage: "", totalSlides: 0, randAnim: "", running: false, paused: false, stop: false }; var f = a(b); f.data("nivo:vars", e); f.css({ position: "relative", "-webkit-border-radius": "" + d.borderRadius + "px " + "" + d.borderRadius + "px " + "0px 0px", "-moz-border-radius": "" + d.borderRadius + "px " + "" + d.borderRadius + "px " + "0px 0px", "border-radius": "" + d.borderRadius + "px " + "" + d.borderRadius + "px " + "0px 0px" }); f.addClass("nivoSlider"); var g = f.children(); g.each(function () { var b = a(this); var c = ""; if (!b.is("img")) { if (b.is("a")) { b.addClass("nivo-imageLink"); c = b } b = b.find("img:first") } var d = b.width(); if (d == 0) d = b.attr("width"); var g = b.height(); if (g == 0) g = b.attr("height"); if (d > f.width()) { f.width(d) } if (g > f.height()) { f.height(g) } if (c != "") { c.css("display", "none") } b.css("display", "none"); e.totalSlides++ }); if (d.startSlide > 0) { if (d.startSlide >= e.totalSlides) d.startSlide = e.totalSlides - 1; e.currentSlide = d.startSlide } if (a(g[e.currentSlide]).is("img")) { e.currentImage = a(g[e.currentSlide]) } else { e.currentImage = a(g[e.currentSlide]).find("img:first") } if (a(g[e.currentSlide]).is("a")) { a(g[e.currentSlide]).css("display", "block") } f.css("background", 'url("' + e.currentImage.attr("src") + '") no-repeat'); f.append(a('<div class="nivo-caption"><p></p></div>').css({ display: "none", opacity: d.captionOpacity, "-webkit-border-bottom-right-radius": "0px", "-webkit-border-bottom-left-radius": "0px", "-moz-border-radius-bottomright": "0px", "-moz-border-radius-bottomleft": "0px", "border-bottom-right-radius": "0px", "border-bottom-left-radius": "0px" })); var h = function (b) {
            var c = a(".nivo-caption", f); if (e.currentImage.attr("title") != "" && e.currentImage.attr("title") != undefined) { if (e.currentImage.hasClass("toLeft")) { a(".nivo-caption").addClass("toLeft"); a(".nivo-caption").removeClass("toRight") } else { a(".nivo-caption").addClass("toRight"); a(".nivo-caption").removeClass("toLeft") } var d = e.currentImage.attr("title"); if (d.substr(0, 1) == "#") d = a(d).html(); if (c.css("display") == "block") { c.hide(); c.find("p").html(d); c.fadeIn(b.animSpeed + 2000) } else { c.find("p").html(d) } c.fadeIn(b.animSpeed + 2000) } else { c.fadeOut(b.animSpeed) }
            c.find('a').click(function () {
                //if (a(this).parent(".light-box-content-no-style").length == 0 && a(this).attr("href").indexOf("~") == 0) {
                  //  var url = a(this).attr("href").substr(1);
                  //  window.location = url;
                // }
                var index = a(this).attr("href").indexOf("~");
                var url = a(this).attr("href");
                if (index >-1) {
                    url = a(this).attr("href").substr(0, index) + a(this).attr("href").substr(index + 2);
                }
                window.location = url;
                return false;
            }); c.find(".light-box-content-no-style").find("a").unbind("click").click(function () { CreatePopup(this); return false; }); c.find('.light-box-content-no-style').find('a').showLightBox(genericLightBoxId);
        }; h(d); var i = 0; if (!d.manualAdvance && g.length > 1) { i = setInterval(function () { n(f, g, d, false) }, d.pauseTime) } if (d.directionNav) { f.append('<div class="nivo-directionNav"><a class="nivo-prevNav">' + d.prevText + '</a><a class="nivo-nextNav">' + d.nextText + "</a></div>"); if (d.directionNavHide) { a(".nivo-directionNav", f).hide(); f.hover(function () { a(".nivo-directionNav", f).show() }, function () { a(".nivo-directionNav", f).hide() }) } a("a.nivo-prevNav", f).live("click", function () { if (e.running) return false; clearInterval(i); i = ""; e.currentSlide -= 2; n(f, g, d, "prev") }); a("a.nivo-nextNav", f).live("click", function () { if (e.running) return false; clearInterval(i); i = ""; n(f, g, d, "next") }) } if (d.controlNav) { var j = a('<div class="nivo-controlNav"></div>'); f.append(j); for (var k = 0; k < g.length; k++) { if (d.controlNavThumbs) { var l = g.eq(k); if (!l.is("img")) { l = l.find("img:first") } if (d.controlNavThumbsFromRel) { j.append('<a class="nivo-control" rel="' + k + '"><img src="' + l.attr("rel") + '" alt="" /></a>') } else { j.append('<a class="nivo-control" rel="' + k + '"><img src="' + l.attr("src").replace(d.controlNavThumbsSearch, d.controlNavThumbsReplace) + '" alt="" /></a>') } } else { j.append('<a class="nivo-control" rel="' + k + '">' + (k + 1) + "</a>") } } a(".nivo-controlNav a:eq(" + e.currentSlide + ")", f).addClass("active"); a(".nivo-controlNav a", f).live("click", function () { if (e.running) return false; if (a(this).hasClass("active")) return false; clearInterval(i); i = ""; f.css("background", 'url("' + e.currentImage.attr("src") + '") no-repeat'); e.currentSlide = a(this).attr("rel") - 1; n(f, g, d, "control") }) } if (d.pauseOnHover) { f.hover(function () { e.paused = true; clearInterval(i); i = "" }, function () { e.paused = false; if (i == "" && !d.manualAdvance) { i = setInterval(function () { n(f, g, d, false) }, d.pauseTime) } }) } f.bind("nivo:animFinished", function () { e.running = false; a(g).each(function () { if (a(this).is("a")) { a(this).css("display", "none") } }); if (a(g[e.currentSlide]).is("a")) { a(g[e.currentSlide]).css("display", "block") } if (i == "" && !e.paused && !d.manualAdvance) { i = setInterval(function () { n(f, g, d, false) }, d.pauseTime) } d.afterChange.call(this) }); var m = function (b, c, d) { for (var e = 0; e < c.slices; e++) { var f = Math.round(b.width() / c.slices); if (e == c.slices - 1) { b.append(a('<div class="nivo-slice"></div>').css({ left: f * e + "px", width: b.width() - f * e + "px", height: "0px", opacity: "0", background: 'url("' + d.currentImage.attr("src") + '") no-repeat -' + (f + e * f - f) + "px 0%" })) } else { b.append(a('<div class="nivo-slice"></div>').css({ left: f * e + "px", width: f + "px", height: "0px", opacity: "0", background: 'url("' + d.currentImage.attr("src") + '") no-repeat -' + (f + e * f - f) + "px 0%" })) } } var g = a(".nivo-slice:eq(0)", b); var h = a(".nivo-slice:eq(" + (c.slices - 1) + ")", b); g.css({ "-webkit-border-top-left-radius": c.borderRadius + "px", "-webkit-border-bottom-left-radius": "0px", "-moz-border-radius-topleft": c.borderRadius + "px", "-moz-border-radius-bottomleft": "0px", "border-top-left-radius": c.borderRadius + "px", "border-bottom-left-radius": "0px" }); h.css({ "-webkit-border-top-right-radius": c.borderRadius + "px", "-webkit-border-bottom-right-radius": "0px", "-moz-border-radius-topright": c.borderRadius + "px", "-moz-border-radius-bottomright": "0px", "border-top-right-radius": c.borderRadius + "px", "border-bottom-right-radius": "0px" }) }; var n = function (b, c, d, e) { var f = b.data("nivo:vars"); if (f && f.currentSlide == f.totalSlides - 1) { d.lastSlide.call(this) } if ((!f || f.stop) && !e) return false; d.beforeChange.call(this); if (!e) { b.css("background", 'url("' + f.currentImage.attr("src") + '") no-repeat') } else { if (e == "prev") { b.css("background", 'url("' + f.currentImage.attr("src") + '") no-repeat') } if (e == "next") { b.css("background", 'url("' + f.currentImage.attr("src") + '") no-repeat') } } f.currentSlide++; if (f.currentSlide == f.totalSlides) { f.currentSlide = 0; d.slideshowEnd.call(this) } if (f.currentSlide < 0) f.currentSlide = f.totalSlides - 1; if (a(c[f.currentSlide]).is("img")) { f.currentImage = a(c[f.currentSlide]) } else { f.currentImage = a(c[f.currentSlide]).find("img:first") } if (d.controlNav) { a(".nivo-controlNav a", b).removeClass("active"); a(".nivo-controlNav a:eq(" + f.currentSlide + ")", b).addClass("active") } h(d); a(".nivo-slice", b).remove(); a(".nivo-box", b).remove(); if (d.effect.indexOf(",") != -1) { var g = d.effect.split(","); f.randAnim = g[Math.floor(Math.random() * g.length)]; if (f.randAnim == undefined) f.randAnim = "fade" } f.running = true; if (d.effect == "slideInRight" || f.randAnim == "slideInRight") { m(b, d, f); var i = a(".nivo-slice:first", b); i.css({ height: "100%", width: "0px", opacity: "1", "-webkit-border-radius": "" + d.borderRadius + "px " + "" + d.borderRadius + "px " + "0px 0px", "-moz-border-radius": "" + d.borderRadius + "px " + "" + d.borderRadius + "px " + "0px 0px", "border-radius": "" + d.borderRadius + "px " + "" + d.borderRadius + "px " + "0px 0px" }); i.animate({ width: b.width() + "px" }, d.animSpeed * 2, "", function () { b.trigger("nivo:animFinished") }) } else if (d.effect == "slideInLeft" || f.randAnim == "slideInLeft") { m(b, d, f); var i = a(".nivo-slice:first", b); i.css({ height: "100%", width: "0px", opacity: "1", left: "", right: "0px", "-webkit-border-radius": "" + d.borderRadius + "px " + "" + d.borderRadius + "px " + "0px 0px", "-moz-border-radius": "" + d.borderRadius + "px " + "" + d.borderRadius + "px " + "0px 0px", "border-radius": "" + d.borderRadius + "px " + "" + d.borderRadius + "px " + "0px 0px" }); i.animate({ width: b.width() + "px" }, d.animSpeed * 2, "", function () { i.css({ left: "0px", right: "" }); b.trigger("nivo:animFinished") }) } }; this.stop = function () { if (!a(b).data("nivo:vars").stop) { a(b).data("nivo:vars").stop = true } }; this.start = function () { if (a(b).data("nivo:vars").stop) { a(b).data("nivo:vars").stop = false } }; d.afterLoad.call(this); return this
    }; a.fn.nivoSlider = function (c) { return this.each(function (d, e) { var f = a(this); if (f.data("nivoslider")) return f.data("nivoslider"); var g = new b(this, c); f.data("nivoslider", g) }) }; a.fn.nivoSlider.defaults = { effect: "slideInLeft", slices: 1, boxCols: 0, boxRows: 0, animSpeed: 350, pauseTime: 2e3, startSlide: 0, borderRadius: 6, directionNav: false, directionNavHide: true, controlNav: true, controlNavThumbs: false, controlNavThumbsFromRel: false, controlNavThumbsSearch: ".jpg", controlNavThumbsReplace: "_thumb.jpg", keyboardNav: false, pauseOnHover: true, manualAdvance: false, captionOpacity: .8, prevText: "Prev", nextText: "Next", beforeChange: function () { }, afterChange: function () { }, slideshowEnd: function () { }, lastSlide: function () { }, afterLoad: function () { } }; a.fn._reverse = [].reverse
})(jQuery)
