$.fn.infiniteCarousel = function () {
  
    return this.each(function () {
        var $wrapper = $(this),
            $items = $wrapper.find('img'),
            
            singleWidth = $items.outerWidth(), 
			
            currentPage = 1,
            total = $items.length;
			
			$prev = $('#prev-s');
			$next = $('#next-s');
				
				
		els = $wrapper.children().each(function(i) {
			var el = $(this);
		});
		
		$(".bottom").html(els.eq(0).attr('alt'));
		
		function gotoPage(page) {
            var dir = page < currentPage ? -1 : 1,
                left = -450 * (page-1)  ;
			
			$(".bottom").animate({opacity: 0}, 150,function(){ $(this).html(els.eq(page-1).attr('alt')) }).animate({opacity: 1}, 150);
			
			$wrapper.stop().animate({"left": left}, {duration:600});
            currentPage = page;
			
            return false;
        }
       
        $prev.click(function () {		
			if(currentPage==1) return false;
			else return gotoPage(currentPage - 1);                
		});
		
		$next.click(function () {
			if(currentPage==total) return gotoPage(1);
			else return gotoPage(currentPage + 1);
		});
        	
		
		
    });  
};
