/*

Title:		jShowOff: a jQuery Content Rotator Plugin
Author:		Erik Kallevig
Version:	0.1.2
Website:	http://ekallevig.com/jshowoff
License: 	Dual licensed under the MIT and GPL licenses.

// UPDATE
afterChange :			called after a slide has changed [function, function() {}]	

*/
(function (a) { a.fn.jshowoff = function (g) { var b = { animatePause: !0, autoPlay: !0, changeSpeed: 600, controls: !0, controlText: { play: "Play", pause: "Pause", next: "Next", previous: "Previous" }, effect: "fade", hoverPause: !0, links: !0, speed: 3E3, afterChange: a.noop }; g && a.extend(!0, b, g); if (b.speed < b.changeSpeed + 20) return alert("jShowOff: Make speed at least 20ms longer than changeSpeed; the fades aren't always right on time."), this; this.each(function () { function e(h, e) { var g = d; d = d >= h.length || e >= h.length ? 0 : d < 0 || e < 0 ? h.length - 1 : e; if (b.effect == "slideLeft") { var k, i, j = function (a) { k = a == "right" ? "left" : "right"; i = a == "left" ? "left" : "right" }; d >= g ? j("left") : j("right"); a(h[d]).clone().appendTo(f).slideIt({ direction: k, changeSpeed: b.changeSpeed }); f.children().length > 1 && f.children().eq(0).css("position", "absolute").slideIt({ direction: i, showHide: "hide", changeSpeed: b.changeSpeed }, function () { a(this).remove(); b.afterChange(d) }) } else b.effect == "fade" ? (a(h[d]).clone().appendTo(f).hide().fadeIn(b.changeSpeed, function () { a.browser.msie && this.style.removeAttribute("filter") }), f.children().length > 1 && f.children().eq(0).css("position", "absolute").fadeOut(b.changeSpeed, function () { a(this).remove(); b.afterChange(d) })) : b.effect == "none" && (a(h[d]).clone().appendTo(f), f.children().length > 1 && (f.children().eq(0).css("position", "absolute").remove(), b.afterChange(d))); b.links && (a("." + c + "-active").removeClass(c + "-active jshowoff-active"), a("." + c + "-slidelinks a").eq(d).addClass(c + "-active jshowoff-active")) } function k() { return a("." + c + "-play").hasClass("jshowoff-paused") ? !1 : !0 } function i(h) { if (!g()) { d++; e(j, d); if (h == "hover" || !k()) n = setInterval(function () { i() }, b.speed); k() || a("." + c + "-play").text(b.controlText.pause).removeClass("jshowoff-paused " + c + "-paused") } } function l(h) { clearInterval(n); (!h || h == "playBtn") && a("." + c + "-play").text(b.controlText.play).addClass("jshowoff-paused " + c + "-paused"); b.animatePause && h == "playBtn" && a('<p class="' + c + '-pausetext jshowoff-pausetext">' + b.controlText.pause + "</p>").css({ fontSize: "62%", textAlign: "center", position: "absolute", top: "40%", lineHeight: "100%", width: "100%" }).appendTo(m).addClass(c + "pauseText").animate({ fontSize: "600%", top: "30%", opacity: 0 }, { duration: 500, complete: function () { a(this).remove() } }) } function g() { return f.children().length > 1 ? !0 : !1 } function o(a) { f.children().stop(!0, !0); if (d != a || d == a && g()) g() && f.children().eq(0).remove(), e(j, a), l() } function p() { m.append('<p class="jshowoff-controls ' + c + '-controls"><a class="jshowoff-play ' + c + '-play" href="#null">' + b.controlText.pause + '</a> <a class="jshowoff-prev ' + c + '-prev" href="#null">' + b.controlText.previous + '</a> <a class="jshowoff-next ' + c + '-next" href="#null">' + b.controlText.next + "</a></p>"); a("." + c + "-controls a").each(function () { a(this).hasClass("jshowoff-play") && a(this).click(function () { k() ? l("playBtn") : i(); return !1 }); a(this).hasClass("jshowoff-prev") && a(this).click(function () { o(d - 1); return !1 }); a(this).hasClass("jshowoff-next") && a(this).click(function () { o(d + 1); return !1 }) }) } function q() { m.append('<p class="jshowoff-slidelinks ' + c + '-slidelinks"></p>'); a.each(j, function (b) { var d = a(this).attr("title") != "" ? a(this).attr("title") : b + 1; a('<a class="jshowoff-slidelink-' + b + " " + c + "-slidelink-" + b + '" href="#null">' + d + "</a>").bind("click", { index: b }, function (a) { o(a.data.index); return !1 }).appendTo("." + c + "-slidelinks") }) } var f = a(this), j = a(this).children().remove(), n = "", d = 0, c = "jshowoff-" + (a(".jshowoff").length + 1), r = b.cssClass !== void 0 ? b.cssClass : ""; f.css("position", "relative").wrap('<div class="jshowoff ' + c + '" />'); var m = a("." + c); m.css("position", "relative").addClass(r); a(j[0]).clone().appendTo(f); (function () { a(j).each(function () { a(this).find("img").each(function () { a("<img>").attr("src", a(this).attr("src")) }) }) })(); b.controls && (p(), b.autoPlay === !1 && a("." + c + "-play").addClass(c + "-paused jshowoff-paused").text(b.controlText.play)); b.links && (q(), a("." + c + "-slidelinks a").eq(0).addClass(c + "-active jshowoff-active")); b.hoverPause && f.hover(function () { k() && l("hover") }, function () { k() && i("hover") }); b.autoPlay && j.length > 1 && (n = setInterval(function () { i() }, b.speed)); j.length < 1 && a("." + c).append("<p>For jShowOff to work, the container element must have child elements.</p>") }); return this } })(jQuery); (function (a) { a.fn.slideIt = function (g, b) { var e = { direction: "left", showHide: "show", changeSpeed: 600 }; g && a.extend(e, g); this.each(function () { a(this).css({ left: "auto", right: "auto", top: "auto", bottom: "auto" }); var g = e.direction == "left" || e.direction == "right" ? a(this).outerWidth() : a(this).outerHeight(), i = {}; i.position = a(this).css("position") == "static" ? "relative" : a(this).css("position"); i[e.direction] = e.showHide == "show" ? "-" + g + "px" : 0; var l = {}; l[e.direction] = e.showHide == "show" ? 0 : "-" + g + "px"; a(this).css(i).animate(l, e.changeSpeed, b) }); return this } })(jQuery);
