(function(n){n.fn.flexisel=function(t){var c=n.extend({visibleItems:1,animationSpeed:200,autoPlay:!1,autoPlaySpeed:3e3,pauseOnHover:!0,setMaxWidthAndHeight:!1,enableResponsiveBreakpoints:!0,clone:!1,responsiveBreakpoints:{portrait:{changePoint:480,visibleItems:1},landscape:{changePoint:640,visibleItems:2},tablet:{changePoint:768,visibleItems:3}}},t),i=n(this),r=n.extend(c,t),u,f=!0,s=r.visibleItems,h=i.children().length,o=[],e={init:function(){return this.each(function(){e.appendHTML();e.setEventHandlers();e.initializeItems();n("li").bind("click",function(){n("img").removeClass("imageBottomBorder");n("img",this).addClass("imageBottomBorder");var t=n("img",this);t[0].className=="imageBottomBorder"?localStorage.setItem("currntImageId",t[0].id):(localStorage.getItem("currntImageId")==null||localStorage.getItem("currntImageId")==undefined)&&localStorage.setItem("currntImageId","AECI-link")});n("img").bind("click",function(){n("img").removeClass("imageBottomBorder");n(this).addClass("imageBottomBorder");var t=n(this);t[0].className=="imageBottomBorder"?localStorage.setItem("currntImageId",t[0].id):(localStorage.getItem("currntImageId")==null||localStorage.getItem("currntImageId")==undefined)&&localStorage.setItem("currntImageId","AECI-link")})})},initializeItems:function(){var f=i.parent(),t=i.children(),o;e.sortResponsiveObject(r.responsiveBreakpoints);o=f.width();u=160;t.width(u);r.clone&&(t.last().insertBefore(t.first()),t.last().insertBefore(t.first()),i.css({left:-u}));i.fadeIn();n(window).trigger("resize")},appendHTML:function(){var t,u,f,e;i.addClass("nbs-flexisel-ul");i.wrap("<div class='nbs-flexisel-container'><div class='nbs-flexisel-inner'><\/div><\/div>");i.find("li").addClass("nbs-flexisel-item");t=i.parent();r.setMaxWidthAndHeight&&(u=n(".nbs-flexisel-item img").width(),f=400,n(".nbs-flexisel-item img").css("max-width",u),n(".nbs-flexisel-item img").css("max-height",f));n("<div class='nbs-flexisel-nav-left'><\/div><div class='nbs-flexisel-nav-right'><\/div>").insertAfter(t);r.clone&&(e=i.children().clone(),i.append(e))},setEventHandlers:function(){var c=i.parent(),l=c.parent(),a=i.children(),t=l.find(".nbs-flexisel-nav-left"),o=l.find(".nbs-flexisel-nav-right");n(window).on("resize",function(){var y,l,v,f;e.setResponsiveEvents();y=n(c).width();l=n(c).height();u=150;a.width(u);r.clone?i.css({left:-u}):i.css({left:0});!r.clone&&h<=s?t.add(o).css("visibility","hidden"):(t.add(o).css("visibility","visible"),v=t.height()/2,f=l/2-v,t.css("top",f+"px"),o.css("top",f+"px"))});i.position().left==0?t.css("opacity","0.5"):t.css("opacity","1");i.position().left==-3150?o.css("opacity","0.5"):o.css("opacity","1");n(t).on("click",function(){o.css("opacity","1");var i=n("div.nbs-flexisel-inner").scrollLeft();i>0?(n("div.nbs-flexisel-inner").animate({scrollLeft:i-200},800),t.css("opacity","1")):t.css("opacity","0.5")});n(o).on("click",function(){t.css("opacity","1");var i=n("div.nbs-flexisel-inner").scrollLeft();i<3005?(o.css("opacity","1"),n("div.nbs-flexisel-inner").animate({scrollLeft:i+200},800)):o.css("opacity","0.5")});n(o).on("dblclick",function(){window.getSelection?window.getSelection().empty?window.getSelection().empty():window.getSelection().removeAllRanges&&window.getSelection().removeAllRanges():document.selection&&document.selection.empty()});if(r.pauseOnHover==!0)n(".nbs-flexisel-item").on({mouseenter:function(){f=!1},mouseleave:function(){f=!0}});r.autoPlay==!0&&setInterval(function(){f==!0&&e.scrollRight()},r.autoPlaySpeed)},setResponsiveEvents:function(){var i=n("html").width(),u,t;if(r.enableResponsiveBreakpoints){u=o[o.length-1].changePoint;for(t in o)if(i>=u){s=r.visibleItems;break}else if(i<o[t].changePoint){s=o[t].visibleItems;break}else continue}},sortResponsiveObject:function(n){var t=[];for(var i in n)t.push(n[i]);t.sort(function(n,t){return n.changePoint-t.changePoint});o=t},scrollLeft:function(){var n;if(i.position().left<0&&f==!0){f=!1;var t=i.parent(),o=t[0].scrollLeft,s=t.width();u=150;n=i.children();i.animate({left:"+="+u},{queue:!1,duration:r.animationSpeed,easing:"linear",complete:function(){r.clone&&n.last().insertBefore(n.first());e.adjustScroll();f=!0}})}},scrollRight:function(){var t=i.parent(),a=t[0].scrollLeft,o=t.width(),c,l,n;u=150;c=u-o;l=i.position().left+(h-s)*u-o;c<=Math.ceil(l)&&!r.clone?i.position().left>=-3150&&f==!0&&(f=!1,i.animate({left:"-="+u},{queue:!1,duration:r.animationSpeed,easing:"linear",complete:function(){e.adjustScroll();f=!0}})):r.clone&&f==!0&&(f=!1,n=i.children(),i.animate({left:"-="+u},{queue:!1,duration:r.animationSpeed,easing:"linear",complete:function(){n.first().insertAfter(n.last());e.adjustScroll();f=!0}}))},adjustScroll:function(){var n=i.parent(),t=i.children(),f=n.width();u=150;t.width(u);r.clone&&i.css({left:-u})}};if(e[t])return e[t].apply(this,Array.prototype.slice.call(arguments,1));if(typeof t!="object"&&t)n.error('Method "'+method+'" does not exist in flexisel plugin!');else return e.init.apply(this)}})(jQuery)