/* ©2011 Didier Berck */

var Scroller = Class.create({
				  
	initialize: function() {
		/*this.resetDimensions();
		this.yPos = $('nav').cumulativeOffset().top + $('nav').getHeight() - 50;
		this.scrollTotal = $('header').up().getHeight();
		var pos = this.getYpos();
		$('top').setStyle({
			top: pos + 'px',
			left: this.mid + 'px'
		});*/
		Event.observe($('top').down('a'), 'click', this.scrollToNav);
		//Event.observe(window, 'scroll', this.onScroll.bind(this));
		//Event.observe(window, 'resize', this.updateSize.bind(this));
	},
	scrollToNav: function(evt) {
		evt.stop();
		//new Effect.Tween(null, document.viewport.getScrollOffsets().top, $('nav').cumulativeOffset().top, function(p) { 
		new Effect.Tween(null, document.viewport.getScrollOffsets().top, 0, function(p) { 
			scrollTo(0,p);
		});
	}/*,
	onScroll: function(evt) {
		this.initScroll();
	},
	initScroll: function() {
		var pos = this.getYpos();
		new Effect.Move($('top'), {
			x: this.mid,
			y: pos, 
			mode: 'absolute'
		});
	},
	updateSize: function(evt) {
		this.resetDimensions();
		this.initScroll();
	},
	resetDimensions: function(evt) {
		this.vpHeight = document.viewport.getHeight();
		this.mid = Math.round(document.viewport.getWidth() / 2);
		if(this.mid < 490) this.mid = 490;
		this.yPos = $('nav').cumulativeOffset().top + $('nav').getHeight() - 50;
		this.scrollTotal = $('header').up().getHeight();
	},
	getYpos: function() {
		var scrollOffset = document.viewport.getScrollOffsets().top;
		var pos = Math.round(scrollOffset + this.vpHeight - (scrollOffset / this.scrollTotal * this.vpHeight));
		if(scrollOffset == 0) pos = this.yPos;
		return pos;
	}*/
});

Event.observe(window, 'load', function(evt) {
	var scroller = new Scroller();
}); 
