/* marquee.js */
$(function(){var self=this,$hots_block=$('.hots_block'),$btn_prev=$hots_block.find('.btn:eq(0)'),$btn_next=$hots_block.find('.btn:eq(1)'),$ul=$hots_block.find('ul'),$lis=$ul.find('li'),scroll_width=$lis.eq(0).width(),scroll_max=scroll_width*($lis.length-1),marginLeft=parseInt($ul.css('margin-left'));this.setActive=function(){if(marginLeft<scroll_max){$btn_next.addClass('next_hot').removeClass('nonext_hot')}else $btn_next.addClass('nonext_hot').removeClass('next_hot');if(marginLeft>0){$btn_prev.addClass('prev_hot').removeClass('noprev_hot')}else $btn_prev.addClass('noprev_hot').removeClass('prev_hot')};$hots_block.delegate('.btn','click',function(){var $btn=$(this),isDisabled=$btn.hasClass('noprev_hot')||$btn.hasClass('nonext_hot'),dirIsNext=$btn.is($btn_next),activeClass=dirIsNext?'next_hot':'prev_hot',inactiveClass=dirIsNext?'nonext_hot':'noprev_hot';if(isDisabled)return false;marginLeft=dirIsNext?marginLeft+scroll_width:marginLeft-scroll_width;self.setActive(marginLeft);$ul.animate({marginLeft:(dirIsNext?'-=':'+=')+scroll_width});return false});var timeout_id=false;this.startNextTimer=function(){timeout_id=setTimeout(self.onNextTimer,5000)};this.onNextTimer=function(){marginLeft=marginLeft+scroll_width;if(marginLeft>scroll_max)marginLeft=0;self.setActive(marginLeft);$ul.animate({marginLeft:-marginLeft},function(){self.startNextTimer()})};$hots_block.mouseenter(function(){if(!timeout_id)return;clearTimeout(timeout_id);timeout_id=false});$hots_block.mouseleave(function(){self.startNextTimer()});self.startNextTimer()})
