function evolve()
{
	this.init();	
}

evolve.prototype.init = function()
{
	//attach nav handlers
	var tA = $('navigation').select('a');
	var iMax = tA.length;
	for(var i=0;i<iMax;i++){
		Event.observe(tA[i], 'click', this.viewSection.bindAsEventListener(this));
	}	
	//call footer
	this.footer();
	
	this.contentA = [];
	var tA = $('page').select('div.section');
	var iMax = tA.length;
	for(var i=0;i<iMax;i++){
		var t = Element.cumulativeOffset(tA[i]);
		this.contentA.push({elem:tA[i],_y1:t.top,_y2:t.top + Element.getDimensions(tA[i]).height});
		if(i<2){
		//alert(tA[i].id + '---' + t.top + ' ' + Element.getDimensions(tA[i]).height);
		}
	}
	
	//observe window on resize and send to footer
	Event.observe(window, 'resize', this.footer.bindAsEventListener(this));
	//Event.observe(window, 'scroll', this.processScroll.bindAsEventListener(this));
}

evolve.prototype.processScroll = function()
{
	var yPos = document.viewport.getScrollOffsets().top + 95;
	var iMax = this.contentA.length;
	for(var i=0;i<iMax;i++){
		var obj = this.contentA[i];
		if(yPos >= obj._y1 && yPos <= obj._y2){
			var t = obj.elem.id;
			this.trackMenu($('nav' + t.charAt(t.length-1)));
		}
	}
	
}

evolve.prototype.viewSection = function(event)
{
	var elem = Event.element(event);
	var t = elem.hash.substring(1);
	new Effect.ScrollTo($(t), {offset: -95});
	Event.stop(event);
	this.trackMenu(Event.element(event));
}

evolve.prototype.footer = function()
{
	/*
	get the height of the browser window with prototype
	subtract the height of the navigation and footer
	setting last section min height
	*/
	
	//get last child
	var tA = $('content').select('div.section');
	
	tA[(tA.length-1)].setStyle({'height': (document.viewport.getHeight() - 225) + 'px'});	
}

evolve.prototype.trackMenu = function(hit)
{	
	//highlight navigation links
	var tA = $('navigation').select('a');
	var iMax = tA.length;
	for(var i=0;i<iMax;i++){
		var elem = tA[i];
		if (elem == hit){
			elem.addClassName('selected');
		}else{
			elem.removeClassName('selected');
		}
	}
}