i want to scroll my window to a certain point and i want a smooth scroll.But i dont know why this code isn't working.can any one explain to me the reasons behind it?
Code:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style>
.this{
	width:200px;
	height:1000px;
	border:1px solid black;
}


</style>

</head>

<body>
<a href="#" onClick="return false;" onMouseDown="scroll('div1');">click to div1</a></br>
<a href="#" onClick="return false;" onMouseDown="scroll('div2');">click to div2</a></br>
<a href="#" onClick="return false;" onMouseDown="scroll('div3');">click to div3</a></br>
<a href="#" onClick="return false;" onMouseDown="scroll('div4');">click to div4</a></br>
<div class="this" id="div1">div1</div>
<a href="#" onClick="return false;" onMouseDown="toTop();">back to top</a>
<div class="this" id="div2" >div2</div>
<a href="#" onClick="return false;" onMouseDown="toTop();">back to top</a>
<div class="this"id="div3" >div3</div>
<a href="#" onClick="return false;" onMouseDown="toTop();">back to top</a>
<div class="this" id="div4" >div4</div>
<a href="#" onClick="return false;" onMouseDown="toTop();">back to top</a>
<script>
function scroll(el){
	var m=document.getElementById(el);
	var t=m.offsetTop;
		var c=window.pageYOffset;
	window.scrollBy(0,40);
		if(c==t){
			clearTimeout(p);
		}

		var p=setTimeout(scrolll,50);
		
	
}

</script>
<script>
function toTop(){
	var m=window.pageYOffset;
	window.scrollBy(0,-m);
}
</script>
</body>
</html>