$(function(){ $("#tabs").tab("tab_on","tab_con_","rel","tab_more"); $("#scroll_imgs").scrollPics(1,30); var picSliders = $("#pic_news").children("li"); var titleTarget = $("#title"); $("#slider_btns").createNode($(picSliders).length,"li",{"class":"floatL"}); $.classOprate($("#slider_btns").children("li"),0,"cur_pic"); $(picSliders).eq(0).find("a").clone(true).appendTo($(titleTarget)); var tFade = null; var fadeIndex = 0; tFade = setInterval(function(){ fadeIndex = parseInt(fadeIndex + 1) === $(picSliders).length ? 0 : parseInt(fadeIndex + 1); $(picSliders).eq(fadeIndex).siblings().sFadeOut(500); $(picSliders).eq(fadeIndex).sFadeIn(500); $.classOprate($("#slider_btns").children("li"),fadeIndex,"cur_pic"); $(titleTarget).empty(); $(picSliders).eq(fadeIndex).find("a").clone(true).appendTo($(titleTarget)); },4000); }); $.fn.extend({ tab:function(className,contentId,attributeName,moreLink){ $(this).find("li").each(function(){ $(this).click(function(){ var curContent = $("#" + contentId + $(this).index()); $(this).removeClass(className) .addClass(className) .siblings() .removeClass(className); $(curContent).show() .siblings() .hide(); if(attributeName && moreLink){ $("#" + moreLink).attr("href",$(this).attr(attributeName)); }else{} }); }); } }); $.fn.extend({ scrollPics:function(speed,interValtime){ var _this = this; $(this).html($(this).html() + $(this).html()); $(this).width($(this).children("li").length * $(this).children("li").outerWidth(true)); var left = 0; var tScroll = null; function setLeft(){ if($(_this).position().left == -$(_this).outerWidth()/2){ $(_this).css("left","0"); } left = $(_this).position().left - speed; $(_this).css({ left:left + "px" }); } tScroll = setInterval(function(){ setLeft() },interValtime); $(_this).hover(function(){ clearInterval(tScroll) },function(){ tScroll = setInterval(function(){ setLeft() },interValtime); }); } }); $.fn.extend({ sFadeTo:function(Target,speed,callback){ return this.animate({ opacity:Target },speed,function(){ if($.browser.msie){ this.style.removeAttr("filter"); } if($.isFunction(callback)){ callback(); } }); } }); $.fn.extend({ sFadeIn:function(speed,callback){ return this.animate({ opacity:"show" },speed,function(){ if($.browser.msie && this.style.filter){ this.style.removeAttribute("filter"); }; if(callback && $.isFunction(callback)){ callback(); } }); } }); $.fn.extend({ sFadeOut:function(speed,callback){ return this.animate({ opacity:"hide" },speed,function(){ if($.browser.msie && this.style.filter){ this.style.removeAttribute("filter"); }; if(callback &&$.isFunction(callback)){ callback(); } }) } }); $.fn.extend({ createNode:function(times,nodeName,settings){ var attrName,attrValue; for(var item in settings){ attrName = item; attrValue = settings[item]; } for(var i = 0;i < times;i ++){ $(this).append("<"+ nodeName + " " + attrName + "=" + attrValue + ">"+ (parseInt(i + 1)) +"" ); } } }); $.extend({ classOprate:function(obj,index,className){ $(obj).eq(index).removeClass(className) .addClass(className) .siblings() .removeClass(className); } });