var operan800 = true;
var currentSection = "1";
var scroll = {	timeScrolled:0,
		startPosition:0,
		amount:0.0,
		duration:0.0,
		element:null,
		timer:null};
function scrollTo(destination) {

	if (currentSection == destination) {
		return;
	}

	var offset = "1";

	var position = getElementY(document.getElementById(destination));
	var offsetPos = getElementY(document.getElementById(offset));
	position = position - offsetPos;
	
	var scroller = document.getElementById("scroller");
	
	scroll.timeScrolled = 0;
	scroll.startPosition = scroller.scrollTop;
	scroll.amount = position - scroller.scrollTop;
	scroll.duration = 25;
	scroll.element = scroller;

	scroll.timer = setInterval("scrollABit();", 7);

	var lastSection = currentSection;
	currentSection = destination;

//	document.getElementById(currentSection.split("-")[0]+"-tab").className = "active";
//	if (lastSection) {
//		document.getElementById(lastSection.split("-")[0]+"-tab").className = "inactive";
//	}
}

function scrollABit() {
	if (scroll.timeScrolled > scroll.duration) {
		clearInterval(scroll.timer);
		scroll.timer = null;
	}
	else {
		scroll.element.scrollTop = ease(scroll.timeScrolled, scroll.startPosition, scroll.amount, scroll.duration);
		scroll.timeScrolled++;
	}
}

function ease(time, start, change , duration) {
	return -change/2 * (Math.cos(Math.PI*time/duration) - 1) + start;
}

function getElementY(element){
	var y = 0;
	do {
		y += element.offsetTop;
	} while ( element = element.offsetParent )
	return y;
}
