/*
	file:			scrolling.js
	content:		minimal scrolling funtcionality
	project:		Animoto HTML
	version:		1.0
	last update:	31.01.2006
	(c):			Daniel Liebig, Wevin - http://www.wevin.de
*/

var scrolling;

function scroll(direction)
{
	i = 0;
	if ( direction == 'up')
	{
		var move = 'move_up()';
	}
	if ( direction == 'down')
	{
		var move = 'move_down()';
	}
	scrolling	= window.setInterval(move, 1);
}

function move_down()
{
	var Content	= document.getElementById('scrolling_content');
	var top		= Content.offsetTop;
	if ( top >= 0 )
	{
		stop_scrolling();
		return;
	}
	top += 5;
	Content.style.top = top + 'px';
}

function move_up()
{
	var Content	= document.getElementById('scrolling_content');
	var top		= Content.offsetTop;
	var Frame	= document.getElementById('frame');
	if ( top <= ( Frame.offsetHeight - Content.offsetHeight ) )
	{
		stop_scrolling();
		return;
	}
	top -= 5;
	Content.style.top = top + 'px';
}


function stop_scrolling()
{
	window.clearInterval(scrolling);
}


function move_to(pos)
{
	var Content	= document.getElementById('scrolling_content');
	Content.style.top = pos + 'px';
}


function emergency_break()
{
	i += 1;
	if ( i >= 100 )
	{
		stop_scrolling();
		alert('emergency break!');
	}
}
