(function(a) { a.fn.db_rotaterollingbanner = function(b) { var c = { key: "", movespeed: 200, autorollingtime: 5000 }; a.extend(c, b); return this.each(function() { var k = a(this); var l = k.find(".d_img"); var h = l.find(">li"); var j = k.find(".d_menu"); var r = j.find(">li"); var z = k.find(".d_prev"); var b = k.find(".d_next"); var p = h.length; var y = 3; var s = "next"; var f; var c; var u = []; var x = []; var m = 1; var t = 0; var o = 0; var v = 0; var e = 0; w(); function w() { d(); g(); n() } function d() { j.html(""); for (var e = 0; e < p; e++) { var d = h.eq(e); if (e < y) { u[e] = { left: d.position().left, top: d.position().top, zindex: d.css("z-index"), width: d.width() }; d.css("left", u[e].left) } else { d.css("left", u[y - 1].left) } x.push(d); j.append("
") } r = j.find(">li"); r.eq(0).addclass("d_select") } function g() { k.bind("mouseenter", function() { clearinterval(f) }).bind("mouseleave", function() { n() }); r.bind("click", function() { if (m && o != a(this).index()) { t = a(this).index(); m = 0; v = math.abs(t - o); if (t > o) { s = "next" } else { s = "prev" } if (v > math.ceil(p / 2)) { v = p - v; if (s == "next") { s = "prev" } else { s = "next" } } e = 0; q(); if (v > 1) { c = setinterval(function() { if (m) { q(); m = 0; if (e >= v) { clearinterval(c) } } }, 50) } } }); b.bind("click", function() { if (m) { s = "next"; m = 0; if (t == p - 1) { t = 0 } else { t++ } q() } }); z.bind("click", function() { if (m) { s = "prev"; m = 0; if (t == 0) { t = p - 1 } else { t-- } q() } }) } function q() { if (s == "next") { for (i = 0; i < y; i++) { var d = u[i - 1]; if (i == 0) { x[i].fadeout(c.movespeed) } else { x[i].css("z-index", d.zindex).animate({ left: d.left, top: d.top, width: d.width }, c.movespeed) } } var d = u[y - 1]; if (x.length != y) { x[y].css({ left: d.left, top: d.top, width: d.width, "z-index": d.zindex }).fadein(c.movespeed, function() { m = 1 }) } else { x[0].stop().css({ left: d.left, top: d.top, width: d.width, "z-index": d.zindex }).fadein(c.movespeed, function() { m = 1 }) } x.push(x.shift()) } else { for (i = 0; i < y; i++) { var d = u[i + 1]; if (i == y - 1) { x[i].css("z-index", 0).fadeout(c.movespeed) } else { x[i].css("z-index", d.zindex).animate({ left: d.left, top: d.top, width: d.width }, c.movespeed) } } var d = u[0]; x[x.length - 1].stop().css({ left: d.left, top: d.top, width: d.width, "z-index": d.zindex }).fadein(c.movespeed, function() { m = 1 }); x.unshift(x.pop()) } r.removeclass("d_select"); r.eq(t).addclass("d_select"); o = t; e++ } function n() { f = setinterval(a, c.autorollingtime) } function a() { b.click() } }) } })(jquery);