(function (d) { d.fn.nivoSlider = function (l) { function k(a, g, e, i) { var f = a.data("nivo:vars"); if ((!f || f.stop) && !i) return false; if (!i || i == "prev" || i == "next") a.css("background", "url(" + f.currentImage + ") no-repeat"); f.currentSlide++; if (f.currentSlide == f.totalSlides) f.currentSlide = 0; if (f.currentSlide < 0) f.currentSlide = f.totalSlides - 1; f.currentImage = e.images[f.currentSlide]; document.getElementById("slide").title = e.titles[f.currentSlide]; d("#slide_title").fadeOut(e.animSpeed, function () { d(this).html(e.captions[f.currentSlide]); d(this).fadeIn(e.animSpeed) }); document.getElementById("slide_link").href = e.links[f.currentSlide]; var b = 0; d(".nivo-slice", a).each(function () { var j = Math.round(a.width() / e.slices); d(this).css({ height: "0px", opacity: "0", background: "url(" + e.images[f.currentSlide] + ") no-repeat -" + (j + b * j - j) + "px 0%" }); b++ }); f.running = true; var h = 0; b = 0; d(".nivo-slice", a).each(function () { var j = d(this); j.css("top", "0px"); b == e.slices - 1 ? setTimeout(function () { j.animate({ height: "100%", opacity: "1.0" }, e.animSpeed, "", function () { a.trigger("nivo:animFinished") }) }, 100 + h) : setTimeout(function () { j.animate({ height: "100%", opacity: "1.0" }, e.animSpeed) }, 100 + h); h += 50; b++ }) } var c = d.extend({}, d.fn.nivoSlider.defaults, l); return this.each(function () { var a = { currentSlide: 0, currentImage: "", totalSlides: 0, randAnim: "", running: false, paused: false, stop: false }, g = d(this); g.data("nivo:vars", a); g.css("position", "relative"); g.addClass("nivoSlider"); var e = c.images; a.totalSlides = e.length; var i = 0; d("#slide .count").each(function () { var h = d(this); if (h.is("a")) { h.click(function (j) { j.preventDefault(); if (a.running) return false; j = h.attr("id").substring(5); clearInterval(b); b = ""; a.currentSlide = j - 1; k(g, e, c, false) }); i = h.attr("id").substring(5); c.titles[i] = h.attr("title") } }); if (c.startSlide > 0) { if (c.startSlide >= a.totalSlides) c.startSlide = a.totalSlides - 1; a.currentSlide = c.startSlide } a.currentImage = c.images[a.currentSlide]; g.css("background", "url(" + a.currentImage + ") no-repeat"); document.getElementById("slide").title = c.titles[a.currentSlide]; for (i = 0; i < c.slices; i++) { var f = Math.round(g.width() / c.slices); i == c.slices - 1 ? g.append(d('<div class="nivo-slice"></div>').css({ left: f * i + "px", width: g.width() - f * i + "px" })) : g.append(d('<div class="nivo-slice"></div>').css({ left: f * i + "px", width: f + "px" })) } d("#slide_title").html(c.captions[a.currentSlide]); d("#slide_title").fadeIn(c.animSpeed); document.getElementById("slide_link").href = c.links[a.currentSlide]; var b = 0; if (e.length > 1) b = setInterval(function () { k(g, e, c, false) }, c.pauseTime); d("#prev").click(function (h) { h.preventDefault(); if (a.running) return false; clearInterval(b); b = ""; a.currentSlide -= 2; k(g, e, c, "prev") }); d("#next").click(function (h) { h.preventDefault(); if (a.running) return false; clearInterval(b); b = ""; k(g, e, c, "next") }); d("#pause").click(function (h) { h.preventDefault(); if (a.stop) { a.stop = false; b = setInterval(function () { k(g, e, c, false) }, c.pauseTime) } else { a.stop = true; clearInterval(b); b = "" } }); if (c.pauseOnHover) { g.hover(function () { a.paused = true; clearInterval(b); b = "" }, function () { a.paused = false; if (b == "") b = setInterval(function () { k(g, e, c, false) }, c.pauseTime) }); d("#slide_title").hover(function () { a.paused = true; clearInterval(b); b = "" }, function () { a.paused = false; if (b == "") b = setInterval(function () { k(g, e, c, false) }, c.pauseTime) }) } d('a[class!="count"][id!="next"][id!="prev"][id!="pause"]').click(function () { a.stop = true; clearInterval(b); b = "" }); g.bind("nivo:animFinished", function () { a.running = false; if (b == "" && !a.paused) b = setInterval(function () { k(g, e, c, false) }, c.pauseTime) }) }) }; d.fn.nivoSlider.defaults = { slices: 14, animSpeed: 500, pauseTime: 7E3, startSlide: 0, pauseOnHover: true, images: [], captions: [], titles: [], links: [] }; d.fn.reverse = [].reverse })(jQuery);
