var scrolldelay;
var lastScrollPos;
function scrollTo(newVal) {
	lastScrollPos = -1;
	doScroll(newVal);
}

function doScroll(newVal) {
	clearTimeout(scrolldelay);
	
	var step = 150;
	var curr = getScrollTop();
	if(curr == lastScrollPos) {
		lastScrollPos = -1;
	} else if(curr + step < newVal) {
		window.scrollBy(0, step);
		
		scrolldelay = setTimeout('doScroll(' + newVal + ')', 20);
	} else if(curr + step >= newVal && curr < newVal) {
		// last
		window.scrollBy(0, newVal - curr);
	} else if(curr == newVal ) {
		
	} else if(curr - step > newVal) {
		window.scrollBy(0, -step);
		
		scrolldelay = setTimeout('doScroll(' + newVal + ')', 20);
	} else if(curr - step <= newVal && curr > newVal) {
		window.scrollBy(0, newVal - curr);
	}
	lastScrollPos = curr;
}

function stopScroll() {
	clearTimeout(scrolldelay);
}

function getScrollTop() {
	var ScrollTop = document.body.scrollTop;
	if (ScrollTop == 0) {
		if (window.pageYOffset)
			ScrollTop = window.pageYOffset;
		else
			ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
	}
	
	return ScrollTop;
}

function setSizeAndPos(nHeight, nPos) {
	nHeight += "px";
	document.getElementById("flashcontent").style.height = nHeight;
	
	if(nPos > -1)
		scrollTo(nPos);
}
