var text_wrapper = $('scroll_text').getElementsByTagName('div')[0];
text_wrapper.style.top = '0px';
text_wrapper.style.left = '0px';
var distance = 5;
var speed = 15;
var lower = 0;
var t, d;

function scroll_down() {

	d = distance * -1; 
	
	do_scroll();
	
} //endfunction

function scroll_up() {
	
	d = distance; 
	
	do_scroll();
	
} //endfunction

function scroll_left() {

	d = distance * +1; 
	
	do_scroll_horiz();
	
} //endfunction

function scroll_right() {

	d = distance * -1; 
	
	do_scroll_horiz();
	
} //endfunction

function stop_scroll() {
	
	clearTimeout( t );
	
} //endfunction

function do_scroll() {

	var top = parseInt( text_wrapper.style.top, 10 );
	
	if( top + d > lower || top + d < upper ) {
		clearTimeout( t );
		return;
	}
	
	text_wrapper.style.top = ( top + d ) + 'px';
	
	t = setTimeout( "do_scroll()", speed );
	
} //endfunction

function do_scroll_horiz() {

	var left = parseInt( text_wrapper.style.left, 10 );
	
	if( left + d > lower || left + d < upper ) {
		clearTimeout( t );
		return;
	}
	
	text_wrapper.style.left = ( left + d ) + 'px';
	
	t = setTimeout( "do_scroll_horiz()", speed );
	
} //endfunction
