(function(a){a.fn.YSlide=function(p){var k=a(this);var c=a.extend({},a.fn.YSlide.defaults,p);var j=c.index;var f=0;var l=a("."+c.nav+" li",k);var e=a("."+c.nav+" .next",k);var h=a("."+c.nav+" .prev",k);var o=a("."+c.txt+" li",k);var d=a("."+c.container,k);var b=d.children().size();var n=c.slideH||d.children().first().height();var g=c.slideW||d.children().first().width();var m;var i;if(l){l.eq(j-1).addClass("on")}if(o.length){o.eq(j-1).addClass("on")}if(c.effect=="scroolY"||c.effect=="scroolTxt"){i=n}else{if(c.effect=="scroolX"||c.effect=="scroolLoop"){d.width(b*g);i=g}else{if(c.effect=="fade"){d.children().first().css("z-index","1")}}}return this.each(function(){var r=a(this);var q=function(){if(b==1){return}a.fn.YSlide.effect[c.effect](d,l,j,i,c);j++;if(j*c.steps>=b){j=0}o.length&&o.eq(j-1).addClass("on").siblings().removeClass("on")};e.click(function(t){if(b==1){return}var s=o.length||0;a.fn.YSlide.effectLoop.scroolLeft(d,l,j,i,c,function(){for(var u=0;u<c.steps;u++){d.find("li:first").appendTo(d)}d.css({left:"0"});if(s){f++;if(f>=s){f=0}o.eq(f).addClass("on").siblings().removeClass("on")}});t.preventDefault();return false});h.click(function(u){var s=o.length||0;if(b==1){return}for(var t=0;t<c.steps;t++){d.find("li:last").prependTo(d)}d.css({left:-j*c.steps*g});a.fn.YSlide.effectLoop.scroolRight(d,l,j,i,c,function(){f--;if(s){if(0>f){f=s-1}o.eq(f).addClass("on").siblings().removeClass("on")}});u.preventDefault();return false});if(c.auto){m=setInterval(q,c.timer);d.hover(function(){if(m){clearInterval(m)}},function(){if(m){clearInterval(m)}m=setInterval(q,c.timer)})}l.hover(function(){if(m){clearInterval(m)}j=l.index(this);window.setTimeout(function(){a.fn.YSlide.effect[c.effect](d,l,j,i,c)},200)},function(){if(m){clearInterval(m)}m=setInterval(q,c.timer)})})};a.fn.YSlide.effectLoop={scroolLeft:function(b,f,c,d,e,g){b.animate({left:-c*e.steps*d},e.speed,g);if(f){f.eq(c).addClass("on").siblings().removeClass("on")}},scroolRight:function(b,f,c,d,e,g){b.stop().animate({left:0},e.speed,g)}};a.fn.YSlide.effect={fade:function(b,f,c,d,e){b.children().eq(c).stop().animate({opacity:1},e.speed).css({"z-index":"1"}).siblings().animate({opacity:0},e.speed).css({"z-index":"0"});f.eq(c).addClass("on").siblings().removeClass("on")},scroolTxt:function(b,f,c,d,e){b.animate({"margin-top":-e.steps*d},e.speed,function(){for(var g=0;g<e.steps;g++){b.find("li:first").appendTo(b)}b.css({"margin-top":"0"})})},scroolX:function(b,f,c,d,e,g){b.stop().animate({left:-c*e.steps*d},e.speed,g);if(f){f.eq(c).addClass("on").siblings().removeClass("on")}},scroolY:function(b,g,c,d,e){var f=-c*e.steps*d;b.stop().animate({top:-c*e.steps*d},e.speed);if(g){g.eq(c).addClass("on").siblings().removeClass("on")}}};a.fn.YSlide.defaults={effect:"scroolY",auto:true,speed:"normal",timer:1000,index:1,nav:"YSlide_nav",container:"YSlide_c",txt:"YSlide_txt",steps:1};a.fn.YSlide.debug=function(b){var c=a("#YSlide_debug");if(!c.length){c=a('<div id="YSlide_debug"></div>').css({position:"absolute",top:"0",right:"0","z-index":"9999","font-size":"14px",color:"red",padding:"10px","background-color":"#FCF"}).appendTo(document.body)}c.html(b)};window.YSlide=a.fn.YSlide})(jQuery);
