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