ptm(document).ready(function(){ function cur(ele,currentclass,tag){ ele= ptm(ele)? ptm(ele):ele; if(!tag){ ele.addclass(currentclass).siblings().removeclass(currentclass); }else{ ele.addclass(currentclass).siblings(tag).removeclass(currentclass); } } ptm.fn.tab=function(options){ var org={ tabid:"", tabtag:"", conid:"", contag:"", curclass:"active", act:"click", dft:0, effact:null, auto:false, autotime:3000, anispeed:100 }; ptm.extend(org,options); var t=false; var k=0; var _this=ptm(this); var tagwrp=ptm(org.tabid); var conwrp=ptm(org.conid); var tag=tagwrp.find(org.tabtag); var con=conwrp.find(org.contag); var len=tag.length; var taght=parseint(tagwrp.css("height")); var conwh=conwrp.get(0).offsetwidth; var conht=conwrp.get(0).offsetheight; var curtag=tag.eq(org.dft); cur(curtag,org.curclass); con.eq(org.dft).show().siblings(org.contag).hide(); if(org.effact=="scrollx"){ var padding=parseint(con.css("padding-left"))+parseint(con.css("padding-right")); _this.css({"position":"relative","height":taght+conht+"px","overflow":"hidden"}); conwrp.css({"width":len*conwh+"px","height":conht+"px","position":"absolute","top":taght+"px"}); con.css({"float":"left","width":conwh-padding+"px","display":"block"}); }if(org.effact=="scrolly"){ var padding=parseint(con.css("padding-top"))+parseint(con.css("padding-bottom")); _this.css({"position":"relative","height":taght+conht+"px","overflow":"hidden" }); tagwrp.css({"z-index":100}); conwrp.css({"width":"100%","height":len*conht+"px","position":"absolute","z-index":99}); con.css({"height":conht-padding+"px","float":"none","display":"block"}); } tag.css({"cursor":"pointer"}).each(function(i){ tag.eq(i).bind(org.act,function(){ cur(this,org.curclass); k=i; switch(org.effact){ case "slow": con.eq(i).show("slow").siblings(org.contag).hide("slow"); break; case "fast":con.eq(i).show("fast").siblings(org.contag).hide("fast"); break; case"scrollx":conwrp.animate({left:-i*conwh+"px"},org.anispeed); break; case "scrolly" : conwrp.animate({top:-i*conht+taght+"px"},org.anispeed); break; default:con.eq(i).show().siblings(org.contag).hide(); break; } }) }); if(org.auto){ var drive=function(){ if(org.act=="mouseover"){ tag.eq(k).mouseover(); }else if(org.act=="click"){ tag.eq(k).click(); } k++; if(k==len) k=0; }; t=setinterval(drive,org.autotime); } } });