function RecentSearches(_holderId, _mode)
{
	var holder = document.getElementById(_holderId);
	var topBTN;
	var bottomBTN;
	var contHolder;
	var cont;
	var currentMargin = 0;
	var scrollInt;
	var currentSpeed = 0;
	var maxSpeed = 10;
	var a = 0.5;
	var k;
	var stopScroll = false;
	var mode = _mode;
	var targetY = 0;
	var aK = 1;
	
	init();
	
	function init()
	{
		var i;
		var j;
		
		for(i=0; i<holder.childNodes.length; i++)
		{
			if(holder.childNodes[i].className == "TopBTN")
			{
				topBTN = holder.childNodes[i];
				switch(mode)
				{
					case "normal":
						topBTN.onmousedown = _tbtnClickHandler;
						topBTN.onmouseup = _tbtnUpHandler;
					break;	
					case "screen":
						topBTN.onclick = _tbtnClickHandlerScreen;
					break;
				}
			}
			if(holder.childNodes[i].className == "BottomBTN")
			{
				bottomBTN = holder.childNodes[i];
				switch(mode)
				{
					case "normal":
						bottomBTN.onmousedown = _bbtnClickHandler;
						bottomBTN.onmouseup = _bbtnUpHandler;
					break;	
					case "screen":
						bottomBTN.onclick = _bbtnClickHandlerScreen;
					break;
				}
			}
			
			if(holder.childNodes[i].className == "ContHolder")
			{
				contHolder = holder.childNodes[i];
				for(j=0; j<contHolder.childNodes.length; j++)
				{
					if(contHolder.childNodes[j].className == "RSCont")
					{
						cont = contHolder.childNodes[j];
					}
				}
			}
		}
	}
	function _tbtnClickHandler()
	{
		stopScroll = false;
		k=1;
		scrollInt = setInterval(_scrollIntervalHandler, 10);
	}
	function _bbtnClickHandler()
	{
		stopScroll = false;
		k=-1;
		scrollInt = setInterval(_scrollIntervalHandler, 10);
	}
	function _tbtnUpHandler()
	{
		stopScroll = true;
	}
	function _bbtnUpHandler()
	{
		stopScroll = true;
	}
	function _scrollIntervalHandler()
	{
		currentSpeed += a;
		if(currentSpeed>maxSpeed)
		{
			currentSpeed = maxSpeed;
		}		
		currentMargin+=currentSpeed*k;
		if(currentMargin>0)
		{
			currentMargin = 0;
			cont.style.marginTop = currentMargin+"px";
			clearInterval(scrollInt);
			currentSpeed = 0;
			return;
		}
		if(Math.abs(currentMargin) >= (cont.scrollHeight-contHolder.clientHeight))
		{
			currentMargin = -(cont.scrollHeight-contHolder.clientHeight);
			cont.style.marginTop = currentMargin+"px";
			clearInterval(scrollInt);
			currentSpeed = 0;
			return;
		}
		cont.style.marginTop = currentMargin+"px";
		if(stopScroll)
		{
			clearInterval(scrollInt);
			stopScroll = false;
			currentSpeed = 0;
		}
	}
	function _tbtnClickHandlerScreen()
	{
		targetY = contHolder.clientHeight+currentMargin;
		if(targetY>0)
		{
			targetY = 0;
		}
		k=1;
		aK = 1;
		currentSpeed = 0;
		scrollInt = setInterval(_scrollIntervalHandlerScreenBottom, 10);
		bottomBTN.onclick = null;
		topBTN.onclick = null;
	}
	function _bbtnClickHandlerScreen()
	{
		targetY = -contHolder.clientHeight+currentMargin;
		if(targetY<(-cont.scrollHeight+contHolder.clientHeight))
		{
			targetY = -cont.scrollHeight+contHolder.clientHeight;
		}
		k=-1;
		aK = 1;
		currentSpeed = 0;
		scrollInt = setInterval(_scrollIntervalHandlerScreenTop, 10);
		bottomBTN.onclick = null;
		topBTN.onclick = null;
	}
	function _scrollIntervalHandlerScreenTop()
	{
		currentSpeed += a*aK;
		stopDist = -(targetY-currentMargin);
		if(aK>0)
		{
			if(stopDist <= (0-Math.pow(currentSpeed,2))/(-2*a))
			{
				aK = -1;
			}
		}
		if(currentSpeed>maxSpeed)
		{
			currentSpeed = maxSpeed;
		}
		if(currentSpeed<0)
		{
			currentSpeed = 1;
		}
		//alert(currentMargin+"<="+targetY);
		if(currentMargin<=targetY)
		{
			currentMargin = targetY;
			bottomBTN.onclick = _bbtnClickHandlerScreen;
			topBTN.onclick = _tbtnClickHandlerScreen;
			clearInterval(scrollInt);
		}
		currentMargin+=currentSpeed*k;
		cont.style.marginTop = currentMargin+"px";
	}
	function _scrollIntervalHandlerScreenBottom()
	{
		
		currentSpeed += a*aK;
		stopDist = targetY-currentMargin;
		//alert(stopDist);
		if(aK>0)
		{
			if(stopDist <= (0-Math.pow(currentSpeed,2))/(-2*a))
			{
				aK = -1;
			}
		}
		if(currentSpeed>maxSpeed)
		{
			currentSpeed = maxSpeed;
		}
		if(currentSpeed<0)
		{
			currentSpeed = 1;
		}
		if(currentMargin>=targetY)
		{
			currentMargin = targetY;
			topBTN.onclick = _tbtnClickHandlerScreen;
			bottomBTN.onclick = _bbtnClickHandlerScreen;
			clearInterval(scrollInt);
		}
		currentMargin+=currentSpeed*k;
		cont.style.marginTop = currentMargin+"px";
	}
}
