// javascript document var ie6 = !-[1,] && !window.xmlhttprequest; //导航 var $nav=$('.nav').find('.li'), $navcur=$('.nav').find('.cur').length?$('.nav').find('.cur').index():0, $navline=$('.nav_line'); $navline.css('left',$navcur*$nav.eq(0).width()); $nav.mouseenter(function(){ $(this).addclass('hover'); $navline.stop(1,0).animate({left:$(this).index()*$nav.eq(0).width()},200) }).mouseleave(function(){ $(this).removeclass('hover'); $navline.stop(1,0).animate({left:($('.nav').find('.cur').length?$('.nav').find('.cur').index():0)*$nav.eq(0).width()},200) }); //slide func $.fn.slide=function(){ var defaults,opts,data_opts,$this,$b_,t,n=0,count,$nav,$p,$n; defaults={ fade:true, auto:true, time:4000 } $this=$(this); if($this.attr('data-slide')!==''){eval('data_opts='+$this.attr('data-slide'));} opts=$.extend({},defaults,data_opts); $b_=$this.children('.ban_c'); count=$b_.length; if($this.find('.ban_nav').length){ $nav=$this.find('.ban_nav') }else{ $nav=$('
'); for(i=0;i'+(i+1)+'') } $this.append($nav) } $this.append(' '); $nav.children('a').eq(0).addclass('on'); $nav.children('a').eq(1).addclass('ban_next'); $nav.children('a').eq(count-1).addclass('ban_prev'); $b_.hide().eq(0).show(); if(ie6){$b_.height($b_.attr('height') || $this.height())} $nav.children('a').each(function(index) { $(this).click(function(event) { event.preventdefault(); if (index >= count){ return }else{ $nav.children('a').eq(index-1).addclass('ban_prev').siblings().removeclass('ban_prev'); $nav.children('a').eq(index==count-1 ? 0 : index+1).addclass('ban_next').siblings().removeclass('ban_next'); }; if(opts.fade){ $b_.fadeout(500).eq(index).fadein(800) }else{ $b_.hide().eq(index).show() } $(this).addclass('on').siblings().removeclass("on"); n=index }) }); $p=$(this).find('.left'); $n=$(this).find('.right'); if(opts.auto){ t = setinterval(function(){ showauto() }, opts.time); $this.hover(function(){clearinterval(t)}, function(){t = setinterval(function(){ showauto() }, opts.time);}); } $p.click(function(){showpre()}) $n.click(function(){showauto()}) function showauto(){ n = n >=(count - 1) ? 0 : ++n; $nav.find('a').eq(n).trigger('click') } function showpre(){ n = n <=0 ? (count - 1) : --n; $nav.find('a').eq(n).trigger('click') } } $('.slide').each(function() { $(this).slide() }); //1026 add:ie6定位修复 $.fn.ie6fix=function(){ var $this=$(this), positop=$this.css('top')!='auto' ? true : ($this.css('bottom')!='auto' ? false : null), selfhei=$(this).outerheight(true), $h=$(window).height(), posival=parseint($this.css(positop ? 'top' : 'bottom')); if(positop!=null){ $this.css('top',positop ? posival : $h-selfhei-posival).css('position','absolute'); $(window).resize(function(){ $h=$(this).height(); $this.css('top',positop ? posival : $h-selfhei-posival); }) $(window).scroll(function(){ $h=$(this).height(); $this.css('top',positop ? $(this).scrolltop()+posival : $h-selfhei-posival+$(this).scrolltop()); }) }else{ console.warn('ie6fix():对象缺少top或bottom属性') } }; if(ie6){$('.ie6fix').each(function() {$(this).ie6fix()})}; //纵向滚动 $.fn.scroll_v=function(opt,callback){ if(!opt) var opt={}; var _btnup = $("#"+ opt.up), _btndown = $("#"+ opt.down), timerid, _this=this.eq(0).find("ul:first"), lineh=_this.find("li").outerheight(true), line=opt.line?parseint(opt.line,10):parseint(this.height()/lineh,10), speed=opt.speed?parseint(opt.speed,10):500, timer=opt.timer || 30000, cols,lasted; line=line?line:1; var upheight=0-line*lineh; var scrollup=function(){ cols=math.floor(_this.width()/_this.find("li").width()); _btnup.unbind("click",scrollup); _this.animate({margintop:upheight},speed,function(){ _this.find("li:lt("+cols+")").appendto(_this); _this.css('margintop',0); _btnup.bind("click",scrollup); }) }; var scrolldown=function(){ lasted=_this.find("li").length-math.floor(_this.width()/_this.find("li").width())-1; _btndown.unbind("click",scrolldown); for(i=1;i<=line;i++){_this.find("li:gt("+lasted+")").show().prependto(_this)}; _this.css({margintop:upheight}); _this.animate({margintop:0},speed,function(){ _btndown.bind("click",scrolldown) }) }; var autoplay = function(){if(timer)timerid = window.setinterval(scrollup,timer)}; var autostop = function(){if(timer)window.clearinterval(timerid)}; _this.hover(autostop,autoplay).mouseout(); _btnup.click( scrollup ).hover(autostop,autoplay); _btndown.click( scrolldown ).hover(autostop,autoplay); }; /*内页导航*/ function settopselect(num){ try{ $("#top"+num).addclass("cur"); $('.nav_line').css('left',($('.nav').find('.cur').length?$('.nav').find('.cur').index():0)*$('.nav').find('.li').eq(0).width()); }catch(e){} };