(function (a) { var b = { animationType: "fade", animate: true, first_slide: 0, easing: "linear", speed: "normal", type: "sequence", timeout: 2000, startDelay: 0, loop: true, containerHeight: "auto", runningClass: "innerFade", children: null, cancelLink: null, pauseLink: null, prevLink: null, nextLink: null, indexContainer: null, currentItemContainer: null, totalItemsContainer: null, callback_index_update: null }; a.fn.innerFade = function (c) { return this.each(function () { $fade_object = new Object(); $fade_object.container = this; $fade_object.settings = a.extend({}, b, c); $fade_object.elements = ($fade_object.settings.children === null) ? a($fade_object.container).children() : a($fade_object.container).children($fade_object.settings.children); $fade_object.count = 0; a($fade_object.container).data("object", $fade_object); if ($fade_object.elements.length > 1) { a.bindControls($fade_object); if ($fade_object.settings.cancelLink) { a.bindCancel($fade_object); } a($fade_object.container).css({ position: "relative" }).addClass($fade_object.settings.runningClass); if ($fade_object.settings.containerHeight == "auto") { height = a($fade_object.elements).filter(":first").height(); a($fade_object.container).css({ height: height + "px" }); } else { a($fade_object.container).css({ height: $fade_object.settings.containerHeight }); } if ($fade_object.settings.indexContainer) { a.innerFadeIndex($fade_object); } a($fade_object.elements).filter(":gt(0)").hide(0); for (var f = 0; f < $fade_object.elements.length; f++) { a($fade_object.elements[f]).css("z-index", String($fade_object.elements.length - f)).css("position", "absolute"); } var d = ""; var e = ""; if ($fade_object.settings.type == "random") { e = Math.floor(Math.random() * $fade_object.elements.length); do { d = Math.floor(Math.random() * $fade_object.elements.length); } while (e == d); a($fade_object.elements[e]).show(); } else { if ($fade_object.settings.type == "random_start") { $fade_object.settings.type = "sequence"; e = Math.floor(Math.random() * ($fade_object.elements.length)); d = (e + 1) % $fade_object.elements.length; } else { d = $fade_object.settings.first_slide; e = ($fade_object.settings.first_slide == 0) ? $fade_object.elements.length - 1 : $fade_object.settings.first_slide - 1; } } if ($fade_object.settings.animate) { a.fadeTimeout($fade_object, d, e, true); } else { a($fade_object.elements[d]).show(); a($fade_object.elements[e]).hide(); a.updateIndexes($fade_object, d); } a.updateIndexes($fade_object, d); if ($fade_object.settings.type == "random") { a($fade_object.elements[e]).show(); } else { a($fade_object.elements[d]).show(); } if ($fade_object.settings.currentItemContainer) { a.currentItem($fade_object, d); } if ($fade_object.settings.totalItemsContainer) { a.totalItems($fade_object); } if ($fade_object.settings.pauseLink) { a.bind_pause($fade_object); } } }); }; a.fn.innerFadeTo = function (c) { return this.each(function (d) { var f = a(this).data("object"); var g = a(f.elements).filter(":visible"); var e = a(f.elements).index(g); a.stopSlideshow(f); if (c != e) { a.fadeToItem(f, c, e); } }); }; a.fadeToItem = function (e, c, d) { var g = function () { if (e.settings.nextLink || e.settings.prevLink) { a.bindControls(e); } }; if (e.settings.animationType == "slide") { a(e.elements[d]).slideUp(e.settings.speed); a(e.elements[c]).slideDown(e.settings.speed, function () { g(); }); } else { if (e.settings.animationType == "slideOver") { var f = a(e.elements[0]).width(); a(e.container).css({ overflow: "hidden" }); a(e.elements[d]).css({ left: "0px", position: "absolute", right: "auto", top: "0px" }); a(e.elements[c]).css({ left: "auto", position: "absolute", right: "-" + f + "px", top: "0px" }).show(); a(e.elements[d]).animate({ left: "-" + f + "px" }, e.settings.speed, e.settings.easing, function () { a(this).hide(); }); a(e.elements[c]).animate({ right: "0px" }, e.settings.speed, e.settings.easing, function () { g(); }); } else { a(e.elements[d]).fadeOut(e.settings.speed); a(e.elements[c]).fadeIn(e.settings.speed, function () { g(); }); } } if (e.settings.currentItemContainer) { a.currentItem(e, c); } if (e.settings.indexContainer || e.settings.callback_index_update) { a.updateIndexes(e, c); } }; a.fadeTimeout = function (e, c, d, g) { if (g != true) { a.fadeToItem(e, c, d); } e.count++; if (e.settings.loop == false && e.count >= e.elements.length) { a.stopSlideshow(e); return; } if (e.settings.type == "random") { d = c; while (c == d) { c = Math.floor(Math.random() * e.elements.length); } } else { d = (d > c) ? 0 : c; c = (c + 1 >= e.elements.length) ? 0 : c + 1; } var f = (g && e.settings.startDelay) ? e.settings.startDelay : e.settings.timeout; a(e.container).data("current_timeout", setTimeout((function () { a.fadeTimeout(e, c, d, false); }), f)); }; a.fn.innerFadeUnbind = function () { return this.each(function (c) { var d = a(this).data("object"); a.stopSlideshow(d); }); }; a.stopSlideshow = function (c) { clearTimeout(a(c.container).data("current_timeout")); a(c.container).data("current_timeout", null); }; a.bindControls = function (c) { a(c.settings.nextLink).unbind().one("click", function (g) { g.preventDefault(); a.stopSlideshow(c); var e = a(c.elements).filter(":visible"); var h = a(c.elements).index(e); var d = (e.next().length > 0) ? e.next() : a(c.elements).filter(":first"); var f = a(c.elements).index(d); a.fadeToItem(c, f, h); }); a(c.settings.prevLink).unbind().one("click", function (g) { g.preventDefault(); a.stopSlideshow(c); var e = a(c.elements).filter(":visible"); var h = a(c.elements).index(e); var f = (e.prev().length > 0) ? e.prev() : a(c.elements).filter(":last"); var d = a(c.elements).index(f); a.fadeToItem(c, d, h); }); }; a.bind_pause = function (c) { a(c.settings.pauseLink).unbind().click(function (g) { g.preventDefault(); if (a(c.container).data("current_timeout") != null) { a.stopSlideshow(c); } else { var e = a(c.container).children(":first").attr("tagName").toLowerCase(); var d = ""; var f = ""; if (c.settings.type == "random") { f = Math.floor(Math.random() * c.elements.length); do { d = Math.floor(Math.random() * c.elements.length); } while (f == d); } else { if (c.settings.type == "random_start") { f = Math.floor(Math.random() * c.elements.length); d = (f + 1) % c.elements.length; } else { f = a(e, a(c.container)).index(a(e + ":visible", a(c.container))); d = ((f + 1) == c.elements.length) ? 0 : f + 1; } } a.fadeTimeout(c, d, f, false); } }); }; a.bindCancel = function (c) { a(c.settings.cancelLink).unbind().click(function (d) { d.preventDefault(); a.stopSlideshow(c); }); }; a.updateIndexes = function (d, c) { a(d.settings.indexContainer).children().removeClass("active"); a("> :eq(" + c + ")", a(d.settings.indexContainer)).addClass("active"); if (typeof (d.settings.callback_index_update) == "function") { d.settings.callback_index_update.call(this, c); } }; a.createIndexHandler = function (e, d, c) { a(c).click(function (g) { g.preventDefault(); var h = a(e.elements).filter(":visible"); var f = a(e.elements).index(h); a.stopSlideshow(e); if (h.size() <= 1 && d != f) { a.fadeToItem(e, d, f); } }); }; a.createIndexes = function (f) { var c = a(f.settings.indexContainer); for (var e = 0; e < f.elements.length; e++) { var d = a('<li><a href="#">' + (e + 1) + "</a></li>"); a.createIndexHandler(f, e, d); c.append(d); } }; a.linkIndexes = function (g) { var c = a(g.settings.indexContainer); var e = a("> :visible", c); if (e.size() == g.elements.length) { var f = g.elements.length; for (var d = 0; d < f; d++) { a("a", c).click(function (h) { h.preventDefault(); }); a.createIndexHandler(g, d, e[d]); } } else { alert("There is a different number of items in the menu and slides. There needs to be the same number in both.\nThere are " + e.size() + " in the indexContainer.\nThere are " + g.elements.length + " in the slides container."); } }; a.innerFadeIndex = function (d) { var c = a(d.settings.indexContainer); if (a(":visible", c).size() <= 0) { a.createIndexes(d); } else { a.linkIndexes(d); } }; a.currentItem = function (c, d) { var e = a(c.settings.currentItemContainer); e.text(d + 1); }; a.totalItems = function (c) { var d = a(c.settings.totalItemsContainer); d.text(c.elements.length); }; })(jQuery);
