jQuery.fn.slideMenu = function(settings) {
	settings = jQuery.extend({
		offset: 34,
		height: 90,
		width: 123,
		items: 5,
		speed: 500
	}, settings);
	return this.each(function(i){

		lengthMenu = $('li',this).size();
		
		
		
		$('ul',this).wrap('<div class="slider-menu"></div>');
		$('.slider-menu',this).before('<a href="#" class="prev"><span></span>Poprzedni</a>');
		$('.slider-menu',this).after('<a href="#" class="next"><span></span>Następny</a>');
		$('.slider-menu',this).css('width', (settings.width*settings.items)+'px');
		if(lengthMenu <= settings.items) $('.next').hide();
		
		$('ul',this).css('position','absolute');
			$('ul',this).css('left','0');
			$('ul',this).css('width', (settings.width*lengthMenu)+'px');


		animating = false;
		$('.next',this).click(function() {
			thisParent = jQuery(this).parent();
			$(this).blur();		
			if (animating == false) {
				animating = true;
				posLeft = parseInt($('ul',thisParent).css('left'));
				posMaxLeft = (settings.width*(lengthMenu-settings.items-1));
				animateLeft = parseInt($('ul',thisParent).css('left')) - (settings.width);
				if ((animateLeft + parseInt($('ul',thisParent).css('width')) > 0) && (-posLeft <= posMaxLeft)) {
					$('ul',thisParent).animate({left: animateLeft}, settings.speed, function() {
						$(this).css('left',animateLeft);
						animating = false;
					});
				} 
				else { 
					animating = false; 
				}
				
				if(-posLeft < posMaxLeft-settings.width+1){
					$(this).show();
					$('.prev').show();
				}
				else { $(this).hide();$('.prev').show(); }
				return false;
			}
		});	// next
	
		$('.prev',this).click(function() {
			thisParent = $(this).parent();
			$(this).blur();
			if (animating == false) {
				animating = true;
				posLeft = parseInt($('ul',thisParent).css('left'));
				posMaxLeft = (settings.width*(lengthMenu-settings.items-1));
				animateLeft = parseInt($('ul',thisParent).css('left')) + (settings.width);
				if ((animateLeft + parseInt($('ul',thisParent).css('width'))) <= parseInt($('ul',thisParent).css('width'))) {
					$('ul',thisParent).animate({left: animateLeft}, settings.speed, function() {
						$(this).css('left',animateLeft);
						animating = false;
					});
				} 
				else { animating = false; }
				if(posLeft+settings.width == 0){
				
					$(this).hide();
					$('.next').show();
				}
				else { 
					$(this).show(); 
					$('.next').show();
				}
				return false;
			}
		});

		$('.next, .prev').click(function(){
			menuID = $('#prods-menu').attr('class');
			posLeft = animateLeft;
			catMenu = menuID+'_'+posLeft;
			$.cookie('catMenuPos', catMenu, 365);
			
		});		
	
	}); // each	
		
}; // slideMenu


jQuery.fn.slideInfo = function() {
	return this.each(function(i){
		
		$(this).click(function(){
		
			$('#prods-menu li.item').removeClass('act').css('opacity', '0.5');
			$(this).addClass('act').css('opacity', '1');
			$('#prods-list li.item').hide().css('left','-800px');
			$('#prods-list li.item').eq(i).show().animate({left: '0'}, "slow");
			
			return false;
		});
	}); // each
};