jQuery.fn.accessNewsa = function(settings) {
    settings = jQuery.extend({
        newsSpeed: "normal"
    }, settings);
    return this.each(function(i) {
        aNewsSlidera.itemWidth = 86;
        aNewsSlidera.init(settings,this);
    });
};
var aNewsSlidera = {
    itemWidth: 0,
	iloscPrzewijanych: 1,
    init: function(s,p) {
        itemLength = jQuery(".item",p).length;
       
        newsContainerWidth = itemLength * aNewsSlidera.itemWidth;
		jQuery(".container",p).css("height",newsContainerWidth + "px");
		
		if(itemLength > aNewsSlidera.iloscPrzewijanych * 4) {
			jQuery(".bottoms",p).css("display","block");
		}
        animating = false;
        jQuery(".bottoms",p).click(function() {
            if (animating == false) {
                animating = true;
                animateLeft = parseInt(jQuery(".container",p).css("top")) - (aNewsSlidera.itemWidth * aNewsSlidera.iloscPrzewijanych);
                if (animateLeft + parseInt(jQuery(".container",p).css("height")) > 0) {
					jQuery(".tops",p).css("display","block");
                    jQuery(".container",p).animate({top: "-86px"}, s.newsSpeed, function() {
                        jQuery(this).css("top",animateLeft);
                        if (parseInt(jQuery(".container",p).css("top")) + parseInt(jQuery(".container",p).css("height")) <= aNewsSlidera.itemWidth * aNewsSlidera.iloscPrzewijanych * 4) {
                            jQuery(".bottoms",p).css("display","none");
                        }
                        animating = false;
                    });
                } else {
                    animating = false;
                }
            }
            return false;
        });
        jQuery(".tops",p).click(function() {
            if (animating == false) {
                animating = true;
                animateLeft = parseInt(jQuery(".container",p).css("top")) + (aNewsSlidera.itemWidth * aNewsSlidera.iloscPrzewijanych);
                if ((animateLeft + parseInt(jQuery(".container",p).css("height"))) <= parseInt(jQuery(".container",p).css("height"))) {
                    jQuery(".bottoms",p).css("display","block");
                    jQuery(".container",p).animate({top: "+86px"}, s.newsSpeed, function() {
                        jQuery(this).css("top",animateLeft);
                        if (parseInt(jQuery(".container",p).css("top")) == 0) {
                            jQuery(".tops",p).css("display","none");
                        }
                        animating = false;
                    });
                } else {
                    animating = false;
                }
            }
            return false;
        });
    }
};