/***************************** 滑动门 *****************************/ $(function () { $(".tab dl dt>a:first").addclass("tabactive"); $(".tab dl dd ul").not(":first").hide(); $(".tab dl dt>a").unbind("click").bind("click", function () { $(this).siblings("a").removeclass("tabactive").end().addclass("tabactive"); var index = $(".tab dl dt>a").index($(this)); $(".tab dl dd ul").eq(index).siblings(".tab dl dd ul").hide().end().fadein("slow"); }); $(".ppsjbox dl dt>a:first").addclass("tabactive"); $(".ppsjbox dl dd ul").not(":first").hide(); $(".ppsjbox dl dt>a").unbind("click").bind("click", function () { $(this).siblings("a").removeclass("tabactive").end().addclass("tabactive"); var index = $(".ppsjbox dl dt>a").index($(this)); $(".ppsjbox dl dd ul").eq(index).siblings(".ppsjbox dl dd ul").hide().end().fadein("slow"); }); }); // 自动轮换选项卡 $(document).ready(function () { $('.tab dl dt a:first').addclass('tabactive'); $('.tab dl dd ul:first').css('display', 'block'); autoroll(); hookthumb(); $('.ppsjbox dl dt a:first').addclass('tabactive'); $('.ppsjbox dl dd ul:first').css('display', 'block'); autoroll2(); hookthumb2(); }); var i = -1; //第i+1个tab开始 var timer = null; function autoroll() { n = $('.tab dl dt a').length - 1; i++; if (i > n) { i = 0; } slide(i); timer = window.settimeout(autoroll, 30000); } function slide(i) { $('.tab dl dt a').eq(i).addclass('tabactive').siblings().removeclass('tabactive'); $('.tab dl dd ul').eq(i).fadein("slow").siblings('.tab dl dd ul').hide(); } function hookthumb() { $('.tab dl dt a').hover( function () { if (timer) { cleartimeout(timer); i = $(this).prevall().length; slide(i); } }, function () { timer = window.settimeout(autoroll, 30000); this.blur(); return false; } ); } /***************************** 滑动门 end *****************************/ /*****************************导航代码*****************************/ $(function () { $("ul#nav>li:has(ul)").hover( function () { $(this).children('a').end().find('ul').fadein(200); }, function () { $(this).children('a').end().find('ul').fadeout(200); } ); }); /******************************幻灯片代码******************************/ ; (function ($) { $.fn.extend({ "nav": function (con) { var $this = $(this), $nav = $this.find('.switch-tab'), t = (con && con.t) || 3000, a = (con && con.a) || 500, n = (con && con.n) || 5, i = 0, autochange = function () { $nav.find('a:eq(' + (i + 1 === n ? 0 : i + 1) + ')').addclass('current').siblings().removeclass('current'); $this.find('.event-item:eq(' + i + ')').css('display', 'none').end().find('.event-item:eq(' + (i + 1 === n ? 0 : i + 1) + ')').css({ display: 'block', opacity: 0 }).animate({ opacity: 1 }, a, function () { i = i + 1 === n ? 0 : i + 1; }).siblings('.event-item').css({ display: 'none', opacity: 0 }); }, st = setinterval(autochange, t); $this.hover(function () { clearinterval(st); return false; }, function () { st = setinterval(autochange, t); return false; }).find('.switch-nav>a').bind('click', function () { var current = $nav.find('.current').index(); i = $(this).attr('class') === 'prev' ? current - 2 : current; autochange(); return false; }).end().find('.switch-tab>a').bind('click', function () { i = $(this).index() - 1; autochange(); return false; }); return $this; } }); } (jquery)); /***************************** 滑动门 *****************************/ var i2 = -1; //第i+1个tab开始 var timer2 = null; function autoroll2() { n = $('.ppsjbox dl dt a').length - 1; i2++; if (i2 > n) { i2 = 0; } slide2(i2); timer2 = window.settimeout(autoroll2, 30000); } function slide2(a) { $('.ppsjbox dl dt a').eq(a).addclass('tabactive').siblings().removeclass('tabactive'); $('.ppsjbox dl dd ul').eq(a).fadein("slow").siblings('.ppsjbox dl dd ul').hide(); } function hookthumb2() { $('.ppsjbox dl dt a').hover( function () { if (timer2) { cleartimeout(timer2); i2 = $(this).prevall().length; slide2(i2); } }, function () { timer2 = window.settimeout(autoroll2, 30000); this.blur(); return false; } ); }