//Scroll Page

var ie5 = (document.getElementById && document.all) ? true : false;
var x = 0; //the scroll-from-left position of the page
var scrollPageSpeed = 10;
var scrollPageTimer = null;
var isScrolling = false;
var paddingRight = 206; //padding to the right of the last scrollDest
var scrollDest = new Array(200,386,572,758,944,1130,1316,1502,1688,1874,2060);

//scrolls the page horizontally
function scrollPage(index) {
	stopScroll();
	dest = scrollDest[index];
	if (ie5) innerWidth = document.body.offsetWidth;
	if (innerWidth) dest = eval(dest - innerWidth/2);
	minLeft = 0;
	maxRight = eval(scrollDest[scrollDest.length-1]+paddingRight-innerWidth);
	if (dest<minLeft) dest=minLeft;
	if (dest>maxRight) dest=maxRight;
	//checkScrollPage(); //gets current scroll position as x
	if (x>dest) {
		isScrolling = true;
		scrollPageLeft(dest,index);
	}
	else if (x<dest) {
		isScrolling = true;
		scrollPageRight(dest,index);
	}
	else fadeClick(index);
}
function scrollPageLeft(dest,index) {
	if (x>dest+1) {
		distance = eval(x - dest);
		step = 0.15 * distance;
		if (step<1) step=1;
		x -= step;
		window.scroll(x,0)
		scrollPageTimer = setTimeout('scrollPageLeft('+dest+','+index+')',scrollPageSpeed);
		if (x<dest+10) {//start navigation fade early
			isScrolling = false;
			fadeClick(index);
		}
	}
	else stopScroll(dest,index);
}
function scrollPageRight(dest,index) {
	if (x<dest-1) {
		distance = eval(dest - x);
		step = 0.15 * distance;
		if (step<1) step=1;
		x += step;
		window.scroll(x,0)
		scrollPageTimer = setTimeout('scrollPageRight('+dest+','+index+')',scrollPageSpeed);
		if (x<dest-10) {//start navigation fade early
			isScrolling = false;
			fadeClick(index);
		}
	}
	else stopScroll(dest,index);
}
function stopScroll(dest,index) {
	isScrolling = false;
	if(scrollPageTimer) clearTimeout(scrollPageTimer);
	scrollPageTimer = null;
	if(dest) window.scroll(dest,0);
	if(index) fadeUp(index);
	checkScrollPage();
}
//gets the current scroll position of the page
function checkScrollPage() {
	if (ie5) window.pageXOffset = window.document.body.scrollLeft;
	if (window.pageXOffset) x = window.pageXOffset;
	else x = 0;
	return x;
}

function initScroll(index) {
	if (index && index!=0) {
		dest = scrollDest[index];
		if (ie5) innerWidth = document.body.offsetWidth;
		if (innerWidth) dest = eval(dest - innerWidth/2);
		window.scroll(dest,0);
	}
}