/*!
* jQuery UI Image Carousel v1.0.0
* http://www.ferretarmy.com/files/jQuery/ImageCarousel/ImageCarousel.html
*
* Copyright (c) 2009 Jon Neal
* Dual licensed under the MIT and GPL licenses, using the same terms as jQuery.
* Refer to http://docs.jquery.com/License
*
* Date: 2009-09-29 (Tue, 29 September 2009)
* Revision: 1.0.0
*/
(function($){$.fn.ImageCarousel=function(options){var options=$.extend({},$.fn.ImageCarousel.defaults,options);return this.each(function(){var gallery=$(this);var currentItem=0;var currentPosition=parseInt($("ul",gallery).css("marginLeft").replace(/px/g,""));options=$.metadata?$.extend({},options,$(gallery).metadata()):options;AddjQueryUIClassesToCarousel(gallery);SetupButtonBehavior(gallery);$(".btnNext",gallery).click(function(event){event.preventDefault();if(currentItem<$("li",gallery).size()-1){currentPosition=currentPosition-$("li:eq("+currentItem+")",gallery).outerWidth();currentItem=currentItem+1;MoveGallery(gallery,currentPosition,currentItem)}});$(".btnPrevious",gallery).click(function(event){event.preventDefault();if(currentItem>0){currentPosition=currentPosition+$("li:eq("+(currentItem-1)+")",gallery).outerWidth();currentItem=currentItem-1;MoveGallery(gallery,currentPosition,currentItem)}});$(".btnHide",gallery).click(function(event){event.preventDefault();if($(".carouselBody",gallery).css("display")=="none"){$(".carouselHeader",gallery).removeClass("ui-corner-all").addClass("ui-corner-top")}else{$(".carouselBody .btnPrevious, .carouselBody .btnNext",gallery).hide()}$(".carouselBody",gallery).slideToggle(options.carousel_speed,function(){if($(this).css("display")=="none"){$(".carouselHeader",gallery).removeClass("ui-corner-top").addClass("ui-corner-all");$(".btnHide",gallery).attr("title","Show");$(".btnHide span",gallery).removeClass("ui-icon-minus").addClass("ui-icon-plus")}else{$(".btnHide span").removeClass("ui-icon-plus").addClass("ui-icon-minus");$(".btnHide",gallery).attr("title","Hide");$(".carouselBody .btnPrevious, .carouselBody .btnNext",gallery).show()}})});gallery.css("width",options.carousel_width).append('<div style="clear: both; height: 0px;"></div>');$('ul',gallery).append('<div style="clear: both; height: 0px;"></div>');var imageListWidth=0;$('li',gallery).each(function(index){imageListWidth=imageListWidth+$('li:eq('+index+')').outerWidth()});$('ul',gallery).outerWidth((imageListWidth*2)+'px')});function AddjQueryUIClassesToCarousel(gallery){gallery.addClass("ui-widget");if(options.display_header){$(".carouselHeader",gallery).addClass("ui-widget-header ui-corner-top ui-helper-clearfix");$(".carouselBody",gallery).addClass("ui-widget-content ui-corner-bottom").css("borderTop","0px");$(".carouselHeader",gallery).html('<span class="headerTitle">'+$(".carouselHeader",gallery).html()+'</span>');if(options.allow_minimize){$(".carouselHeader",gallery).append('<a href="#" class="fg-button ui-state-default fg-button-icon-solo ui-corner-all btnHide" title="Hide"><span class="ui-icon ui-icon-minus"></span></a>')}}else{$(".carouselHeader",gallery).hide();$(".carouselBody",gallery).addClass("ui-widget-content ui-corner-all")}$(".btnNext, .btnPrevious",gallery).addClass("fg-button ui-state-default fg-button-icon-solo ui-corner-all");$(".btnNext",gallery).prepend('<span class="ui-icon ui-icon-carat-1-e"></span>');$(".btnPrevious",gallery).prepend('<span class="ui-icon ui-icon-carat-1-w"></span>')}function SetupButtonBehavior(gallery){$(".fg-button:not(.ui-state-disabled)",gallery).hover(function(){$(this).addClass("ui-state-hover")},function(){$(this).removeClass("ui-state-hover")}).mousedown(function(){$(this).addClass("ui-state-active")}).mouseup(function(){$(this).removeClass("ui-state-active")});$(".btnPrevious",gallery).addClass("ui-state-disabled")};function MoveGallery(gallery,currentPosition,currentItem){$("ul",gallery).stop().animate({marginLeft:currentPosition+"px"},options.carousel_speed);if(currentItem==0){$(".btnPrevious",gallery).addClass("ui-state-disabled")}else{$(".btnPrevious",gallery).removeClass("ui-state-disabled")}if(currentItem==$(".carousel li").size()-1){$(".btnNext",gallery).addClass("ui-state-disabled")}else{$(".btnNext",gallery).removeClass("ui-state-disabled")}}};$.fn.ImageCarousel.defaults={allow_minimize:true,display_header:true,carousel_speed:'normal',carousel_width:'500px'}})(jQuery);
