(function($){$.fn.multipleElementsCycle=function(options){var defaults={elementContainer:'#cycleElements',prevElement:'#cycleElementsLeft',nextElement:'#cycleElementsRight',speed:500,containerWidth:false,showCount:7};var options=$.extend(defaults,options);this.each(function(){var totalElements=$(this).find("li");var maxIndex=totalElements.length-1;var startIndex=Math.floor((maxIndex-options.showCount)/2);var elementWidth=$(this).find("li").outerWidth(true);var margin=((startIndex+1)*elementWidth)*-1;var lowerIndex=startIndex+1;var upperIndex=startIndex+options.showCount;var parent=$(this);$(this).find(options.elementContainer).css({'width':(options.containerWidth)?options.containerWidth:elementWidth*options.showCount,'overflow':'hidden'});$(this).find("ul").css({'width':(maxIndex+1)*elementWidth,'padding':'0'});cycle("load");$(options.nextElement).click(function(){cycle("next");return false;});$(options.prevElement).click(function(){cycle("prev");return false;});function cycle(dir){switch(dir){case"next":if(upperIndex<=(maxIndex-1)){$(options.prevElement).show();margin=margin-elementWidth;upperIndex=upperIndex+1;lowerIndex=lowerIndex+1;$("ul",parent).animate({marginLeft:margin},options.speed);$(options.nextElement).toggleClass("disabledN",(upperIndex+1)>maxIndex);$(options.prevElement).removeClass("disabledP");}
break;case"prev":if(lowerIndex>=1){$(options.nextElement).show();upperIndex=upperIndex-1;lowerIndex=lowerIndex-1;margin=margin+elementWidth;$("ul",parent).animate({marginLeft:margin},options.speed);$(options.prevElement).toggleClass("disabledP",(lowerIndex-1)<0);$(options.nextElement).removeClass("disabledN");}
break;case"load":{$("ul",parent).animate({marginLeft:margin},options.speed);break;}
default:break;};};});};})(jQuery);
