var jq = jquery.noconflict(); jq(document).ready(function () { flash_ad(); }); //首页flash广告 function flash_ad() { var defaultopts = { interval: 5000, fadeintime: 300, fadeouttime: 200 }; //iterate over the current set of matched elements var _titles = jq("ul.slide_txt li"); jq(_titles).eq(0).addclass("li_on"); var _titles_bg = jq("ul.bg li"); jq(_titles_bg).eq(0).addclass("li_on"); var _bodies = jq("ul.slide-pic li"); jq(_bodies).eq(0).addclass("li_on"); var _count = jq(_titles).size(); var _current = 0; var _intervalid = null; var stop = function() { window.clearinterval(_intervalid); }; var slide = function(opts) { if (opts) { _current = opts.current || 0; } else { _current = (_current >= (_count - 1)) ? 0 : (++_current); }; _bodies.filter(":visible").fadeout(defaultopts.fadeouttime, function() { _bodies.eq(_current).fadein(defaultopts.fadeintime); _bodies.removeclass("li_on").eq(_current).addclass("li_on"); }); _titles.removeclass("li_on").eq(_current).addclass("li_on"); _titles_bg.removeclass("li_on").eq(_current).addclass("li_on"); }; //endof slide var go = function() { stop(); _intervalid = window.setinterval(function() { slide(); }, defaultopts.interval); }; //endof go var itemmouseover = function(target, items) { stop(); var i = jq.inarray(target, items); slide({ current: i }); }; //endof itemmouseover _titles.hover(function() { if (jq(this).attr('class') != 'li_on') { itemmouseover(this, _titles); } else { stop(); } }, go); //_titles_bg.hover(function() { itemmouseover(this, _titles_bg); }, go); _bodies.hover(stop, go); //trigger the slidebox go(); }