(function(jQuery){jQuery.fn.homepromo=function(input){var defaults={featured:'#featured',container:'#container',pagination:'#breadcrumb .pagination',nav_right:'#breadcrumb .right',nav_left:'#breadcrumb .left',slides:'.slide',right:'right',speed:200,timeout:10000,animate:false,resize:false};return this.each(function(){var holder=jQuery(this);var options=jQuery.extend(defaults,input);var featured=jQuery(options.featured,holder);var pagination=jQuery(options.pagination,holder);var nav=jQuery(options.nav,holder);var nav_right=jQuery(options.nav_right,holder);var nav_left=jQuery(options.nav_left,holder);var slides=jQuery(options.slides,holder);var right=options.right;var speed=options.speed;var timeout=options.timeout;var animate=options.animate;var resize=options.resize;var slideCount=slides.length;var count=0;var nextItem;var nextItemHeight=featured.find('.slide:eq(0)').height();if(resize){featured.css('height',nextItemHeight)}if(timeout!=0){function autoAnimate(){count++;slides.hide();if(count>=slideCount){count=0}if(count==0){nextItem=featured.find('.slide:eq('+count+')');nextItem.fadeIn(speed);nextItemHeight=nextItem.height();if(animate){featured.animate({height:nextItemHeight})}else if(resize){featured.css('height',nextItemHeight)}pagination.find('li').removeClass('active').end().find('li:first-child').addClass('active')}else{nextItem=featured.find('.slide:eq('+count+')');nextItem.fadeIn(speed);nextItemHeight=nextItem.height();if(animate){featured.animate({height:nextItemHeight})}else if(resize){featured.css('height',nextItemHeight)}pagination.find('li').removeClass('active').end().find('li:eq('+count+')').addClass('active')}};doAutoAnimate=setInterval(autoAnimate,timeout);holder.click(function(){clearInterval(doAutoAnimate);holder.addClass('stopped')})}nav_right.add(nav_left).click(function(){slides.hide();if(timeout!=0){clearInterval(doAutoAnimate);holder.addClass('stopped')};if(jQuery(this).hasClass('right')){count++;if(count>=slideCount){count=0}var action='right'}else{count--;if(count<0){count=(slideCount-1)}var action='left'}if(count==0){nextItem=featured.find('.slide:eq('+count+')');nextItem.fadeIn(speed);nextItemHeight=nextItem.height();if(animate){featured.stop().animate({height:nextItemHeight})}else if(resize){featured.css('height',nextItemHeight)}pagination.find('li').removeClass('active').end().find('li:first-child').addClass('active')}else if(action=='left'){nextItem=featured.find('.slide:eq('+count+')');nextItem.fadeIn(speed);nextItemHeight=nextItem.height();if(animate){featured.stop().animate({height:nextItemHeight})}else if(resize){featured.css('height',nextItemHeight)}pagination.find('li').removeClass('active').end().find('li:eq('+count+')').addClass('active')}else{nextItem=featured.find('.slide:eq('+count+')');nextItem.fadeIn(speed);nextItemHeight=nextItem.height();if(animate){featured.stop().animate({height:nextItemHeight})}else if(resize){featured.css('height',nextItemHeight)}pagination.find('li').removeClass('active').end().find('li:eq('+count+')').addClass('active')}return false});pagination.find('li').click(function(){slides.hide();var index=jQuery(this).index();if(timeout!=0){clearInterval(doAutoAnimate);holder.addClass('stopped')}nextItem=featured.find('.slide:eq('+index+')');nextItem.fadeIn(speed);nextItemHeight=nextItem.height();if(animate){featured.stop().animate({height:nextItemHeight})}else if(resize){featured.css('height',nextItemHeight)}pagination.find('li').removeClass('active').end().find('li:eq('+index+')').addClass('active');count=index;return false});holder.hover(function(){clearInterval(doAutoAnimate)},function(){if(holder.hasClass('stopped')){}else{doAutoAnimate=setInterval(autoAnimate,timeout)}})})}})(jQuery);
