(function(c) { var d = (navigator.userAgent.toLowerCase().match(/.+(?:ie)[\/: ]([\d.]+)/) || [0, "0"])[1]; var a = (d == "7.0" || d == "6.0") ? false : true; var b = function(f, e) { this.parent = c("#" + f); this.body = c("body"); if (this.parent.length <= 0) { return false } this.options = c.extend({}, b.options, e); this.reset(); var g = this; c(window).resize(function() { g.reset() }) }; b.prototype = { reset: function(e) { if (typeof (e) == "object") { c.extend(this.options, e) } this.total = this.parent.find("img").length; this.pageNow = this.options.initPage; this.preLeft = 0; this.nextLeft = this.options.width - this.options.imgP; this.preNLeft = -this.options.imgP; this.nextNLeft = this.options.width; this.pageNowLeft = (this.options.width - this.options.imgWidth) / 2; this.drawContent() }, drawContent: function() { this.parent.css({ height: this.options.imgHeight + "px" }); this.parent.find(".snapShotCont").css({ height: this.options.imgHeight + "px" }); this.parent.find(".snopshot").css({ width: "0px", opacity: 0, left: this.options.width / 2 + "px", zIndex: 0, marginTop: "135px" }); this.parent.find(".snopshot:nth-child(" + this.pageNow + ")").css({ width: this.options.imgWidth + "px", height: this.options.imgHeight + "px", opacity: 1, left: this.pageNowLeft + "px", zIndex: 3, marginTop: 0 }); var f = this.pageNow > 1 ? this.pageNow - 1 : this.total; var e = this.pageNow == this.total ? 1 : this.pageNow + 1; this.parent.find(".snopshot:nth-child(" + f + ")").css({ opacity: 1, left: this.preLeft + "px", width: this.options.imgP + "px", zIndex: 0, marginTop: this.options.imgHeight / 12 + "px" }); this.parent.find(".snopshot:nth-child(" + e + ")").css({ opacity: 1, left: this.nextLeft + "px", width: this.options.imgP + "px", zIndex: 0, marginTop: this.options.imgHeight / 12 + "px" }); this.bind() }, bind: function() { this.leftNav = this.parent.find("#shotPrev"); this.rightNav = this.parent.find("#shotNext"); var e = this; e.leftNav.click(function() { e.turn("right") }); e.rightNav.click(function() { e.turn("left") }) }, start: function() { var e = this; if (e.timerId) { e.stop() } e.timerId = setInterval(function() { e.turn(e.options.direct) }, e.options.delay) }, stop: function() { clearInterval(this.timerId) }, turn: function(e) { var g = this; if (e == "right") { var f = g.pageNow - 1; if (f <= 0) { f = g.total } } else { var f = g.pageNow + 1; if (f > g.total) { f = 1 } } g.turnpage(f, e) }, turnpage: function(f, e) { var h = this; if (h.locked) { return false } h.locked = true; if (h.pageNow == f) { return false } var g = function(m, j, k) { var o = m > 1 ? m - 1 : h.total; var l = m == h.total ? 1 : m + 1; var i = o - 1 >= 1 ? o - 1 : h.total; var n = l + 1 > h.total ? 1 : l + 1; if (j == "left") { h.parent.find(".snopshot:nth-child(" + h.pageNow + ")").css({ zIndex: 0 }); h.parent.find(".snopshot:nth-child(" + o + ")").css({ zIndex: 2 }); if (a) { h.parent.find(".snopshot:nth-child(" + o + ")").find(".elementOverlay").css({ opacity: 0.4 }) } h.parent.find(".snopshot:nth-child(" + o + ")").animate({ opacity: 1, left: h.preLeft + "px", width: h.options.imgP + "px", height: h.options.imgHeight / 1.2 + "px", zIndex: 2, marginTop: h.options.imgHeight / 12 + "px" }, k); h.parent.find(".snopshot:nth-child(" + m + ")").css({ zIndex: 3 }); if (a) { h.parent.find(".snopshot:nth-child(" + m + ")").find(".elementOverlay").css({ opacity: 0 }) } h.parent.find(".snopshot:nth-child(" + m + ")").animate({ width: h.options.imgWidth + "px", height: h.options.imgHeight + "px", opacity: 1, left: h.pageNowLeft + "px", zIndex: 3, marginTop: 0 }, k); h.parent.find(".snopshot:nth-child(" + l + ")").css({ opacity: 0, left: h.nextNLeft + "px", height: "100px", width: h.options.imgP + "px", zIndex: 2, marginTop: "85px" }); if (a) { h.parent.find(".snopshot:nth-child(" + l + ")").find(".elementOverlay").css({ opacity: 0.4 }) } h.parent.find(".snopshot:nth-child(" + l + ")").animate({ opacity: 1, left: h.nextLeft + "px", width: h.options.imgP + "px", height: h.options.imgHeight / 1.2 + "px", zIndex: 2, marginTop: h.options.imgHeight / 12 + "px" }, k, "", function() { if (h.total === 3) { h.locked = false } }); if (h.total != 3) { h.parent.find(".snopshot:nth-child(" + i + ")").css({ zIndex: 0 }); if (a) { h.parent.find(".snopshot:nth-child(" + i + ")").find(".elementOverlay").css({ opacity: 0.4 }) } h.parent.find(".snopshot:nth-child(" + i + ")").animate({ width: h.options.imgP + "px", opacity: 0, left: h.preNLeft + "px", zIndex: 0, marginTop: "85px" }, k, "", function() { h.locked = false }) } } else { h.parent.find(".snopshot:nth-child(" + h.pageNow + ")").css({ zIndex: 0 }); h.parent.find(".snopshot:nth-child(" + l + ")").css({ zIndex: 2 }); if (a) { h.parent.find(".snopshot:nth-child(" + l + ")").find(".elementOverlay").css({ opacity: 0.4 }) } h.parent.find(".snopshot:nth-child(" + l + ")").animate({ opacity: 1, left: h.nextLeft + "px", width: h.options.imgP + "px", height: h.options.imgHeight / 1.2 + "px", zIndex: 2, marginTop: h.options.imgHeight / 12 + "px" }, k); h.parent.find(".snopshot:nth-child(" + m + ")").css({ zIndex: 3 }); if (a) { h.parent.find(".snopshot:nth-child(" + m + ")").find(".elementOverlay").css({ opacity: 0 }) } h.parent.find(".snopshot:nth-child(" + m + ")").animate({ width: h.options.imgWidth + "px", height: h.options.imgHeight + "px", opacity: 1, left: h.pageNowLeft + "px", zIndex: 3, marginTop: 0 }, k); h.parent.find(".snopshot:nth-child(" + o + ")").css({ opacity: 0, left: h.preNLeft + "px", height: "100px", width: h.options.imgP + "px", zIndex: 2, marginTop: "85px" }); if (a) { h.parent.find(".snopshot:nth-child(" + o + ")").find(".elementOverlay").css({ opacity: 0.4 }) } h.parent.find(".snopshot:nth-child(" + o + ")").animate({ opacity: 1, left: h.preLeft + "px", width: h.options.imgP + "px", height: h.options.imgHeight / 1.2 + "px", zIndex: 2, marginTop: h.options.imgHeight / 12 + "px" }, k, "", function() { if (h.total === 3) { h.locked = false } }); if (h.total != 3) { h.parent.find(".snopshot:nth-child(" + n + ")").css({ zIndex: 0 }); if (a) { h.parent.find(".snopshot:nth-child(" + n + ")").find(".elementOverlay").css({ opacity: 0.4 }) } h.parent.find(".snopshot:nth-child(" + n + ")").animate({ width: h.options.imgP + "px", opacity: 0, left: h.nextNLeft + "px", zIndex: 0, marginTop: "85px" }, k, "", function() { h.locked = false }) } } h.pageNow = m }; g(f, e, h.options.speed) } }; b.options = { total: 5, offsetPages: 3, direct: "left", initPage: 1, className: "snapShotWrap", autoWidth: true, width: 860, height: 310, delay: 5000, speed: 500, imgP: 200 }; window.posterTvGrid = b } )(jQuery);