/**
 * 버전 : 1.2.0
 * 만든 이 : 석상범
 * 만든 일자 : 2014. 8. 5
 * 좌우 화살표 네비게이션 버튼을 추가함.
 * params : opts(JSON)
 * slideHolder: Slide Holder ID
 * Slide : Slide Classname
 * buttonHolder: Button Holder ID
 * speed
 * slidingPlane: horizontal or vertical),
 * period: Timer Duration
 * direction: left or right or up or down
 * isNaviArrow: 좌우 또는 상하 화살표 내비게이션 보이기(true or false)
 **/
var MySlider=function(c){$("#"+c.slideHolder);var e=$("#"+c.slideHolder+">."+c.slide),r=$("#"+c.slideHolder+">#"+c.buttonHolder),g=$("#"+c.slideHolder+">#"+c.buttonHolder+">img");e.eq(0).width();e.eq(0).height();var f=[],m=[],n=e.length,l=null,d=0,h=!1,s=-1;if(c.isNaviArrow)var p=$("#"+c.slideHolder+">#first-arrow"),q=$("#"+c.slideHolder+">#second-arrow");PS=function(a,b,d,f,g){this.p=e.eq(a);this.n=a;this.w=b;this.h=d;this.from=this.to=0;this.distance="horizontal"==c.slidingPlane?b:d;this.direction=
"";this.isMoving=!1};PS.prototype.move=function(a,b){zi=0==b?"0":"10";"horizontal"==c.slidingPlane?(this.from="left"==a?this.w*b:-1*b*this.w,this.to="left"==a?this.from-this.distance:this.from+this.distance,this.p.css({display:"block",left:this.from+"px",zIndex:zi}).animate({left:this.to+"px"},c.speed,function(){0==b&&$(this).css({display:"none",left:"0",top:"0px"});h=!1})):(this.from="up"==a?this.h*b:-1*b*this.h,this.to="up"==a?this.from-this.distance:this.from+this.distance,this.p.css({display:"block",
top:this.from+"px",zIndex:zi}).animate({top:this.to+"px"},c.speed,function(){0==b&&$(this).css({display:"none",top:"0",top:"0px"});h=!1}))};var t=function(a,b){this.p=g.eq(a);this.n=a;this.imgSrc=b};t.prototype.change=function(){for(var a,b,c=0;c<n;c++)a=g.eq(c).attr("src"),b=a.replace("-on","-off"),c!=this.n&&a!=b&&g.eq(c).attr("src",b);b=this.imgSrc.replace("-off","-on");this.p.attr("src",b)};var k=function(a){if("left"==a||"up"==a)return(d+1)%n;d-=1;0>d&&(d=n-1);return d},u=function(){for(var a=
0;a<n;a++)f.push(new PS(a,e.eq(a).width(),e.eq(a).height(),c.direction,0)),m.push(new t(a,g.eq(a).attr("src")))};(function(){u();g.click(function(a){a.stopPropagation();a=g.index($(this));if(a!=s&&!h){h=!0;var b=e.filter(":visible"),b=e.index(b);s=d=a;m[a].change();f[b].move(c.direction,0);f[a].move(c.direction,1)}});r.mouseenter(function(a){a.stopPropagation();clearInterval(l)});r.mouseleave(function(a){a.stopPropagation();l=setInterval(function(){d=k(c.direction);g.eq(d).trigger("click")},c.period)});
c.isNaviArrow&&(p.show().mouseenter(function(a){a.stopPropagation();clearInterval(l)}),p.click(function(a){a.stopPropagation();if(!h)if(h=!0,a=e.filter(":visible"),a=e.index(a),"horizontal"==c.slidingPlane){var b=k("left");d=b;m[b].change();f[a].move("left",0);f[b].move("left",1)}else d=b=k("up"),m[b].change(),f[a].move("up",0),f[b].move("up",1)}),p.mouseleave(function(a){a.stopPropagation();l=setInterval(function(){d=k();g.eq(d).trigger("click")},c.period)}),q.show().mouseenter(function(a){a.stopPropagation();
clearInterval(l)}),q.click(function(a){a.stopPropagation();if(!h)if(h=!0,a=e.filter(":visible"),a=e.index(a),"horizontal"==c.slidingPlane){var b=k("right");d=b;m[b].change();f[a].move("right",0);f[b].move("right",1)}else d=b=k("down"),m[b].change(),f[a].move("down",0),f[b].move("down",1)}),q.mouseleave(function(a){a.stopPropagation();l=setInterval(function(){d=k(c.direction);g.eq(d).trigger("click")},c.period)}));e.eq(0).css({display:"block"});l=setInterval(function(){d=k(c.direction);g.eq(d).trigger("click")},
c.period)})()};