var movestep=10;
var movetime=50;
var slptime=20000;
var pheight;
var cheight;
var ctop;

function scrlbox(obj){
	pheight=document.getElementById("p_"+obj).clientHeight;
	var newctop =(parseInt(pheight/movestep)*movestep)+movestep;
	document.write ("<input type='hidden' name='n_"+obj+"' id='n_"+obj+"' value='"+newctop+"'>");

	SetStartPos(obj);	
	moveup(obj);
}
function moveup(obj){
	ctop=parseInt(document.getElementById(obj).style.top)-movestep;
	pheight=document.getElementById("p_"+obj).clientHeight;
	cheight=parseInt(document.getElementById(obj).clientHeight);
	
	if (-ctop<=cheight){
			newctop = parseInt(document.getElementById("n_"+obj).value) - movestep;
		document.getElementById("n_"+obj).value = newctop;
		var a1=newctop/movestep;
		var a2=parseInt(pheight/movestep);
		if (a1%a2==0 && newctop+movestep!=(parseInt(pheight/movestep)*movestep)+movestep){
			var corecttop = (a1/a2) * pheight + 1;
			document.getElementById(obj).style.top=corecttop+"px";
			//document.getElementById('msg').innerHTML="c " + corecttop ;
			setTimeout("moveup('"+ obj + "')", slptime);
		}else{
			document.getElementById(obj).style.top=ctop+"px";
			setTimeout("moveup('"+ obj + "')", movetime);
		}		
	}else{
		SetStartPos(obj);
		setTimeout("moveup('"+ obj + "')", movetime); 
	}		
}
function SetStartPos(obj){

	pheight=document.getElementById("p_"+obj).clientHeight;
	document.getElementById(obj).style.top=pheight;

	var newctop =(parseInt(pheight/movestep)*movestep)+movestep;
	//alert('a');
	document.getElementById("n_"+obj).value = newctop;

}

