﻿(function(a){a.fn.dualSlider=function(b){var c={auto:true,autoDelay:1e4,easingCarousel:"swing",easingDetails:"easeOutBack",durationCarousel:1e3,durationDetails:600},b=a.extend(c,b);this.each(function(){var c=a(this),s,f=a(".backgrounds",c).children().length,d=1,e=1,l="",g=a(c).width(),j=a(".panel .details_wrapper",c).width(),m=false;if(b.auto==true){a(".backgrounds",c).prepend(a(".backgrounds .item:last-child",c).clone().css("margin-left","-"+g+"px"));a(".backgrounds",c).append(a(".backgrounds .item:nth-child(2)",c).clone());a(".details",c).prepend(a(".details .detail:last-child",c).clone().css("margin-left","-"+j+"px"));a(".details",c).append(a(".details .detail:nth-child(2)",c).clone())}else{a(".previous",c).hide();a(".play, .pause",c).hide()}a(".backgrounds",c).css("width",(f+1)*g+100+"px");a(".details_wrapper .details",c).css("width",(f+1)*g+"px");for(i=1;i<=f;i++){i==1?(l+='<a rel="'+e+'" title="Go to page '+e+' " class="link'+e+' selected" href="javascript:void(0)">'+e+"</a>"):(l+='<a rel="'+e+'"  title="Go to page '+e+' " class="link'+e+'" href="javascript:void(0)" >'+e+"</a>");e++}a("#numbers",c).html(l);a(".next",c).click(function(){h(parseInt(d+1),false);k()});a(".previous",c).click(function(){h(parseInt(d-1),false);k()});a("#numbers a",c).click(function(){h(a(this).attr("rel"),false);k()});a(".pause",c).click(function(){n()});a(".play",c).click(function(){o()});function k(){m=true}function r(){m=false}function p(){a("#numbers a",c).removeClass("selected");a("#numbers .link"+d,c).addClass("selected");if(b.auto==false){d==f?a(".next",c).hide():a(".next",c).show();d<2?a(".previous",c).hide():a(".previous",c).show()}}function q(){if(d<1){a(".backgrounds",c).css("margin-left",-1*((f-1)*g));a(".details",c).css("margin-left",-1*((f-1)*j));d=f}if(d>f){a(".backgrounds",c).css("margin-left",0);a(".details",c).css("margin-left",0);d=1}}function h(h,i){if(m!=true){d=parseFloat(h);if(i==false)n();var e=h*g-g,f=h*j-j;if(e!=0){e=e*-1;f=f*-1}a(".backgrounds",c).animate({marginLeft:e},{duration:b.durationCarousel,easing:b.easingCarousel,complete:function(){a(".details",c).animate({marginLeft:f},{duration:b.durationDetails,easing:b.easingDetails,complete:function(){q();p();r()}})}})}}function n(){a(".pause",c).hide();a(".play",c).show();a("body").stopTime("autoScroll")}function o(){a(".pause",c).show();a(".play",c).hide();a("body").everyTime(b.autoDelay,"autoScroll",function(){h(d+1,true);k()})}if(b.auto==true)o()})}})(jQuery)
