﻿/**
* Simplethumbs Gallery
* Version 0.9.2b
* Author Abel Mohler
* Released with the MIT License: http://www.wayfarerweb.com/mit.php
*/
(function (a) { a.fn.simplethumbs = function (d, c) { var b = { slideshow: "", preload: true, activeClass: "active", speed: 600, next: "#next-image", prev: "#prev-image", wrap: false, cycle: false, cycleWrap: true, interval: 3000, reverse: false, startCycle: "#start-cycle", stopCycle: "#stop-cycle", toggleCycle: "#toggle-cycle", hoverPause: false, callAfter: function (f) { }, callBefore: function (f) { }, beforeCycle: function () { }, afterCycle: function () { } }; if (typeof d == "string" && typeof c != "undefined") { b[d] = c; d = {} } else { if (typeof c == "function") { b.callAfter = c } } d = a.extend(b, d || {}); if (d.slideshow == "") { return this } if (d.cycle) { d.cycleMem = d.wrap } var e = a(d.slideshow).find("img")[0].src; a(d.slideshow).css({ position: "relative", lineHeight: 0, overflow: "hidden" }); a("<img>").attr("src", a(d.slideshow).find("img").attr("src")).appendTo(d.slideshow); a(d.slideshow).find("img").eq(0).css({ position: "absolute", top: 0, left: 0 }); a(d.slideshow).find("img").eq(1).css({ position: "relative" }); this.find("a").each(function () { if (d.preload && this.href) { var f = new Image(); f.src = this.href } if (this.href == e) { a(this).addClass(d.activeClass) } }); return this.each(function () { var f = a(this).find("a"), g = false, k, i; f.click(function () { if (!g && !a(this).hasClass(d.activeClass)) { g = true; d.callBefore.call(this, this); var p = this.href, r = this.title, q = false, o = this; var n = a(d.slideshow).find("img").eq(1); if (a(d.slideshow).siblings("#caption").length) { q = true } a(d.slideshow).find("img").eq(0).attr("src", p); if (q) { a(d.slideshow).siblings("#caption").slideUp("normal") } a(f).removeClass(d.activeClass); a(this).addClass(d.activeClass); a(n).fadeOut(d.speed, function () { a(n).attr("src", p).css("display", "block"); if (q) { a(d.slideshow).siblings("#caption").find("div").text(r); a(d.slideshow).siblings("#caption").slideDown("normal") } d.callAfter.call(o, o); g = false }) } return false }); function m() { for (var n = 0; n < f.length; n++) { if (f.eq(n).hasClass(d.activeClass)) { if ((f.length - 1) == n) { if (d.wrap) { f.eq(0).trigger("click") } } else { f.eq(n + 1).trigger("click") } break } } return false } function h() { for (var n = 0; n < f.length; n++) { if (f.eq(n).hasClass(d.activeClass)) { if (n == 0) { if (d.wrap) { f.eq(f.length - 1).trigger("click") } } else { f.eq(n - 1).trigger("click") } break } } return false } function l() { d.beforeCycle(); d.cycle = true; d.wrapMem = d.wrap; d.wrap = d.cycleWrap; if (d.reverse) { h() } else { m() } k = setTimeout(function () { if (d.reverse) { h() } else { m() } i = setTimeout(arguments.callee, d.speed + d.interval) }, d.speed + d.interval); return false } function j() { clearTimeout(k); clearTimeout(i); d.cycle = false; d.wrap = d.wrapMem; d.afterCycle(); return false } a(d.next).click(function () { j(); return m() }); a(d.prev).click(function () { j(); return h() }); a(d.startCycle).click(function () { return l() }); a(d.stopCycle).click(function () { return j() }); a(d.toggleCycle).click(function () { if (d.cycle) { return j() } else { return l() } }); if (d.hoverPause) { a(d.slideshow).hover(function () { j() }, function () { l() }) } if (d.cycle) { l() } }) } })(jQuery);
