// Defilement block roster
// By Fofif
//
// Using mootools

var i = 0, top = 0, timer = null;

window.onload = function() {
	realHeight = $('rosterContent').getStyle('height').toInt();
	containerHeight = $('rosterInside2').getStyle('height').toInt();
	
	$('arrow_up').addEvent('mouseover', function() {
		if (i != 0) {
			setTimer('down');
		}
	});
	
	$('arrow_up').addEvent('mouseout', function() {
		clearTimeout(timer);
		timer = null;
	});
	
	$('arrow_down').addEvent('mouseover', function() {
		setTimer('up');
	});
	
	$('arrow_down').addEvent('mouseout', function() {
		clearTimeout(timer);
		timer = null;
	});
};

function setTimer(sens) {
	if (timer == null) timer = setInterval('makeDefil(\'' + sens + '\')', 35);
}

function makeDefil(sens) {
	$('rosterContent').setStyle('top', top + 'px');
	
	if (sens == 'up') {
		if (-(top - containerHeight) != realHeight) {
			top--;
		} else {
			clearTimeout(timer);
			timer = null;
		}
	}
	else {
		if (top != 0) {
			top++;
		} else {
			clearTimeout(timer);
			timer = null;
		}
	}
	
	i++;
}
