
var interval_scroll=50;
var increments_scroll=8;
var moviment_scroll=0;
var scroll_actual = 0;

function puja_scroll() {
	moviment_scroll = -increments_scroll;
	setTimeout("mou_scroll()",interval_scroll);
	return false;
}
function baixa_scroll() {
	moviment_scroll = increments_scroll;
	setTimeout("mou_scroll()",interval_scroll);
	return false;
}
function atura_scroll() {
	moviment_scroll=0;
	return false;
}
function mou_scroll() {
	if (moviment_scroll==0) return;
	var obj=document.getElementById("contingut_scroll");
	scroll_actual+=moviment_scroll;
	var max=obj.parentNode.style.height;
	max=parseInt(max.substr(0,max.length-2));
	if (scroll_actual>=0) { scroll_actual=0; moviment_scroll=0; }
	else if (obj.offsetHeight + scroll_actual <= max) {
		scroll_actual=max-obj.offsetHeight;
		moviment_scroll=0;
	}
	obj.style.marginTop = scroll_actual+"px";
	if (moviment_scroll!=0) setTimeout("mou_scroll()",interval_scroll);
}


function autoscroll(nom_div,interval,increments) {
	var obj=document.getElementById(nom_div);
	var actual=llegir_mida(obj.style.left);
	var ample_tot=llegir_mida(obj.parentNode.style.width);
	var ample=llegir_mida(obj.style.width);
	var max=ample_tot - ample;
	actual -= increments;
	if ((actual<max)||(actual>0)) increments = -increments;
	obj.style.left=actual+"px";
	setTimeout("autoscroll('"+nom_div+"',"+interval+","+increments+")",interval);
}

function llegir_mida(str) {
	if (str=="") return 0;
	return (str.substr(0,str.length-2));
}


