/*************************************************************************
    news_scroll.js (version date June 2007)
    news scroller script by Joshua Seigler for PVCC
*************************************************************************/
var scroller;
var newsPage = 0;
function setVis(id, visibility) {
	document.getElementById(id).style.visibility=visibility;
}
function scrollNews(item) {
// scrolls the news pane to the selected location. Integers correspond to news posts.
	var news = document.getElementById('news');
	var items = news.getElementsByTagName('li');
	if(item > items.length - 3) {
		item = items.length - 3;
		stopScroll();
	}
	if(item <= 0) {
		newsPage = item = 0;
		stopScroll();
	}
	news.style.top = -63 * item + 'px';
}
function startScroll(direction) {
	scroller = setInterval( function () {
	scrollNews(3*(newsPage+=direction * 0.036)) }, 70 )
}
function startScrollUp() {
  startScroll(-1);
}
function startScrollDown() {
  startScroll(1);
}
function stopScroll() {
  clearInterval(scroller);
}
function init() {
// set up news scroller
	setVis('upDiv','visible');
	setVis('downDiv','visible');
	var upDiv = document.getElementById('upDiv');
	var downDiv = document.getElementById('downDiv');
	upDiv.onmouseover = startScrollUp;
	upDiv.onmouseout = stopScroll;
	downDiv.onmouseover = startScrollDown;
	downDiv.onmouseout = stopScroll;
}