var scroller;
window.addEvent('domready', function () {
	try {
		scroller = new Scroller();
	} catch (e) {}
})

var Scroller = new Class ({
	
//------/* Kontruktor */--------//
	initialize: function () {
		this.up_arrow = $('up_arrow'); // strzalka w gore
		
		this.down_arrow = $('down_arrow'); // strzaka w dol
		
		this.content_scroll = $('menu_cart'); // to bedzie przewijane
		this.content_scroll_h = this.content_scroll.getStyle('height').toInt();
		
		this.init_arrow();	
	},
	
	init_arrow: function () {
		this.fx_scroll = new Fx.Scroll(this.content_scroll,{
			duration: 700,
			transition: Fx.Transitions.Quad.easeInOut
		})
		
		this.down_arrow.addEvent('click', function (event) {
			event = new Event(event).stop();
			if (this.move_down(180) >= this.content_scroll.getScrollSize().y) {
				//this.down_arrow.setStyle('background-position', 'bottom');
				this.down_arrow.setStyle('opacity', .4);
			} else {
				//this.up_arrow.setStyle('background-position', 'top');
				this.up_arrow.setStyle('opacity', 1);
			}
		}.bind(this))
		
		this.up_arrow.addEvent('click', function (event) {
			event = new Event(event).stop();
			
			if (this.move_up(180) <= 0) {
				//this.up_arrow.setStyle('background-position', 'bottom');
				this.up_arrow.setStyle('opacity', .4);
			} else {
				//this.down_arrow.setStyle('background-position', 'top');
				this.down_arrow.setStyle('opacity', 1);
			}
		}.bind(this))		
	},
	
	move_up: function (offset) {
		var y = this.content_scroll.getScroll().y;
		this.fx_scroll.start (0, y-offset);
		return y;
	},
	
	move_down: function (offset) {
		var y = this.content_scroll.getScroll().y;
		this.fx_scroll.start (0, y+offset);	
		
		return y+this.content_scroll.getStyle('height').toInt();
	}
})
