/* #####################################//
//		News Scroller Functions
// #####################################*/
//In Pixels per second
var speedOfScroll = 20;
var newsDivID = 'news_content';
var containerDivID = 'news_container';

var heightOfBox;
var heightOfContainer;
var ScrollEffect;
var scrollHeight = 0;
var topLoc = 0;
var startingHeight;

function scrollNewsStart(){
	startingHeight = $(newsDivID).getHeight();
	$(newsDivID).innerHTML = $(newsDivID).innerHTML + $(newsDivID).innerHTML  //add a second copy so we can scroll down to the wrap point
	scrollNews();
	}

function scrollNews(){
	heightOfBox = $(newsDivID).getHeight();
	heightOfContainer = $(containerDivID).getHeight();
	if(ScrollEffect){
		ScrollEffect.cancel();
		}
	topLoc = $(newsDivID).positionedOffset().top;
	if (topLoc != parseInt(topLoc)){
		topLoc = 0;
		}
	//scrollHeight = heightOfBox + topLoc;
	scrollHeight = startingHeight + topLoc;

	//alert('Box:' + heightOfBox + '\nCont: ' + heightOfContainer + '\nLoc: ' + topLoc + '\nScrollDist: ' + scrollHeight);
	timeOfScroll = scrollHeight / speedOfScroll;
	ScrollEffect = new Effect.Move($(newsDivID),{x: 0, y: -scrollHeight, duration: timeOfScroll, afterFinish: scrollNewsReset});
	}

function scrollNewsReset(){
	if(ScrollEffect){
		ScrollEffect.cancel();
		}
	topLoc = $(containerDivID).getHeight();
	$(newsDivID).setStyle({
		//top : topLoc+'px'
		top : '0px'
		});
	scrollNews();
	}
function scrollNewsPause(){
	if(ScrollEffect){
		ScrollEffect.cancel();
		}
	}