var speed=50   // speed of scroller
var step=1     // smoothness of movement
var y, scroll, hb, hs, h

function addLoadEvent(func) {
  if (!document.getElementById | !document.getElementsByTagName) return
	var oldonload = window.onload
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload()
			func()
		}
	}
}

function initScroller(){
  if (document.getElementById && document.createElement &&
document.body.appendChild) {
    document.getElementById('control').style.display='block'
    hb=document.getElementById('board').offsetHeight
    hc=document.getElementById('control').offsetHeight
    hs=hb-6-hc
    document.getElementById('scrollcontent').style.height=hs+'px'
    tp=hs-(hs/3)
    document.getElementById('news').style.top=tp+'px'
    y=tp
    scroll=setTimeout('startScroller()',speed)
  }
}

function startScroller(){
  h=document.getElementById('news').offsetHeight
  y-=step
  if (y<-h) {y=hs}
  document.getElementById('news').style.top=y+'px'
  scroll=setTimeout('startScroller()',speed)
}

function stopScroller(){clearTimeout(scroll)}

function showAll(){
  if (document.getElementById) {
    stopScroller()
    document.getElementById('news').style.position='relative'
    document.getElementById('board').style.height='auto'
    document.getElementById('scrollcontent').style.height='auto'
    document.getElementById('news').style.top='0px'
  }
}

function hideAll(){
  if (document.getElementById) {
    document.getElementById('news').style.position='absolute'
    document.getElementById('board').style.height=hb+'px'
    initScroller()
  }
}

function scrollUp(){
  if (document.getElementById) {
    y-=step*20
    if (y<-h) {y=hs}
    document.getElementById('news').style.top=y+'px'
  }
}

function scrollDown(){
  if (document.getElementById) {
    y+=step*50
    if (y>h) {y=h}
    document.getElementById('news').style.top=y+'px'
  }
}

addLoadEvent(initScroller)

