(function(a){a.fn.tabSwitch=function(f,j,h){var l={type:"slide",cols:2,toggle:"fade",ease:40,easeType:"linear",loopback:1,width:400,height:400,index:0,speed:500,interval:5e3,step:1,wrapperClass:"",viewportClass:""},b=a.extend(l,j),d=this,i=d.eq(1),c=d.eq(1).get(0);if(!a.isFunction(h))var e=function(){a.data(c,"index",b.index)};else var e=function(){a.data(c,"index",b.index);h()};StoreToCache=function(){a.data(c,"type",b.type);a.data(c,"toggle",b.toggle);a.data(c,"cols",b.cols);a.data(c,"ease",b.ease);a.data(c,"easeType",b.easeType);a.data(c,"index",b.index);a.data(c,"loopback",b.loopback);if(i.attr("style"))a.data(c,"orgAttr",i.attr("style"));else a.data(c,"orgAttr","")};backFromCache=function(){d.attr("style",a.data(c,"orgAttr"));var b=a("#ViewPort"+a.data(c));b.replaceWith(d);stopAuto();a.removeData(c)};var k=function(){StoreToCache();b.width&&d.width(b.width);b.height&&d.height(b.height);var f="WideDiv"+a.data(c);d.wrapAll("<div id='"+f+"'></div>");var e=a("#"+f);e.addClass(b.wraperClass);e.css({position:"relative"});e.wrap("<div id='"+f.replace("WideDiv","ViewPort")+"'></div>");var h=a("#"+f.replace("WideDiv","ViewPort"));h.width(b.width);h.height(b.height);h.css({display:"block",overflow:"hidden",position:"relative"});h.addClass(b.viewportClass);switch(b.type){case"slide":d.css({"float":"left"});e.width((b.width+2)*d.length);break;case"scroll":e.width(b.width);e.height((b.height+2)*d.length);break;case"toggle":e.width(b.width);e.height(b.height);d.css({position:"absolute",left:"-999px"});d.eq(b.index).css({left:"0px",top:"0px"});d.eq(b.index).css("opacity",1);break;case"table":e.width(b.width*b.cols);d.css("float","left")}g()},g=function(){var g=0;if(!b.easeType)b.easeType=(c,"easeType");if(b.index>d.length-1)if(a.data(c,"loopback")!=0){b.index=0;g=-a.data(c,"ease")}else return;if(b.index<0)if(a.data(c,"loopback")!=0){b.index=d.length-1;g=a.data(c,"ease")}else return;var j="WideDiv"+a.data(c),f=a("#"+j);switch(a.data(c,"type")){case"slide":if(g!=0){var h=parseInt(f.css("left").replace("px",""))+g;f.animate({left:h+"px"},b.speed,function(){f.animate({left:-(d.outerWidth(true)*b.index)+"px"},b.speed,b.easeType,e())})}else f.animate({left:-(d.outerWidth(true)*b.index)+"px"},b.speed,b.easeType,e());break;case"scroll":if(g!=0){var h=parseInt(f.css("top").replace("px",""))+g;f.animate({top:h+"px"},b.speed,function(){f.animate({top:-(d.outerHeight(true)*b.index)+"px"},b.speed,b.easeType,e())})}else f.animate({top:-(d.outerHeight(true)*b.index)+"px"},b.speed,b.easeType,e());break;case"toggle":d.eq(b.index).css({left:"0px",top:"0px"});switch(a.data(c,"toggle")){case"fade":d.eq(b.index).css({opacity:0});d.eq(b.index).animate({opacity:1},b.speed);a.data(c,"index")!=b.index&&d.eq(a.data(c,"index")).animate({opacity:0},b.speed,function(){a(this).css("left",-999);e()});break;case"toggle":if(a.data(c,"index")!=b.index){d.eq(b.index).css({display:"none"});d.eq(a.data(c,"index")).slideUp(b.speed,function(){d.eq(b.index).slideDown(b.speed,function(){e()});a(this).css("left",-999)})}break;case"show":if(a.data(c,"index")!=b.index){d.eq(b.index).css({display:"none"});d.eq(a.data(c,"index")).hide(b.speed,function(){d.eq(b.index).show(b.speed,function(){e()});a(this).css("left",-999)})}break;case"noeffect":if(a.data(c,"index")!=b.index){d.eq(a.data(c,"index")).css("left",-999);e()}}break;case"table":var i=a.data(c,"cols"),k=-(b.index%i)*d.width(),l=-Math.floor(b.index/i)*d.height();f.animate({left:k},b.speed,b.easeType,function(){f.animate({top:l},b.speed,b.easeType,e())});break;default:a("html,body").animate({scrollTop:d.eq(b.index).offset().top},b.speed)}};moveStep=function(){var d=a.data(c,"index");b.index=parseInt(d)+parseInt(b.step);g()};startAuto=function(){a.data(c,"AutoSwitch",setInterval(moveStep,b.interval))};stopAuto=function(){clearInterval(a.data(c,"AutoSwitch"));a.removeData(c,"AutoSwitch")};toggleAuto=function(){if(isAuto())stopAuto();else startAuto()};isAuto=function(){return a.data(c,"AutoSwitch")?true:false};if(!f)f="";switch(f.toLowerCase()){case"index":if(a.data(c,"index"))return a.data(c,"index");else return 0;break;case"moveto":g();break;case"movestep":moveStep();break;case"destroy":backFromCache();break;case"create":k();break;case"isauto":return isAuto();break;case"toggleauto":toggleAuto();break;case"startauto":startAuto();break;case"stopauto":stopAuto()}}})(jQuery)