(function ($) { $.fn.rotate = function (options) {var settings = $.extend({list: 'ul',items: 'li',buttons: {prev: 'p.prev-btn a',next: 'p.next-btn a'},visible: 1,lastVisible: 'last'}, options); return this.each(function () { var self = this, list = $(settings.list, self),items = $(settings.items, list),buttons = {prev: $(settings.buttons.prev, this),next: $(settings.buttons.next, this)}; init(); function move(direction) { switch (direction) { case 'prev':list.append($(items.filter(':first'))); break; case 'next':list.prepend($(items.filter(':last'))); break; default: } list = $(settings.list, self); items = $(settings.items, list); items.removeClass(settings.lastVisible).css('display', 'none'); if (items.length > settings.visible) { items.slice(0, settings.visible).css('display', 'block'); var attrid = items.slice(0, settings.visible).attr('id'); $(items[settings.visible - 1]).addClass(settings.lastVisible); $(".icoArea a").each(function () { var pth = $(this).find("img")[0]; $(this).removeClass("on").addClass("off"); }); $("#i_"+attrid).removeClass("off").addClass("on"); } else { items.css('display', 'block'); items.filter(':last').addClass(settings.lastVisible); } } function init() { if (items.length <= settings.visible) { var button, img; for (button in buttons) { if (buttons.hasOwnProperty(button)) { img = $('img', buttons[button]); img.attr('src', function () { var src = this.getAttribute('src'); return src.replace('_on.', '_off.'); }); } } items.css('display', 'block'); items.filter(':last').addClass(settings.lastVisible); } else { items.css('display', 'none'); items.slice(0, settings.visible).css('display', 'block'); $(items[settings.visible - 1]).addClass(settings.lastVisible); } } buttons.prev.bind('click', function (e) { e.preventDefault(); if (items.length > settings.visible) { move('next'); } }); buttons.next.bind('click', function (e) { e.preventDefault(); if (items.length > settings.visible) { move('prev'); } }); }); }; } (jQuery)); $(document).ready(function () { $('div.qsCont').rotate({ buttons: { prev:'p.prev-btn a', next:'p.next-btn a' }, visible: 1 }); $("div.icoArea a").each(function () { function move(id) { $(".icoArea a").each(function () { var pth = $(this).find("img")[0]; $(this).removeClass("on").addClass("off"); $(".itemWrap li").css('display', 'none'); $(".itemWrap li").removeClass("last"); }); $("#i_" + id).removeClass("off").addClass("on"); $("#" + id).css('display', 'block'); $("#" + id).addClass("last"); } $(this).bind("click", function () { var newid = $(this).attr("id").split("_")[1]; move(newid); }); }); setInterval(onValue, 7000); }); function onValue() {if ($('[class^=on]').next().attr("id") == undefined) {$("#i_Item1").click(); } else { $('[class^=on]').next().click();}}