var timeoutId;
var delta;

function now() {
	return (new Date).getTime();
}

function ShowClose (objId) { 
	var obj = document.getElementById(objId); 
	if(timeoutId) 
		clearTimeout(timeoutId);
	delta = parseInt(obj.scrollHeight/10);
	if(delta < 5) delta = 5;
	if (obj.offsetHeight <= 0)  {
		Show (objId);
	} else	{
		Close (objId);
	}	
	return false;
}

function Show (objId) { 
	var obj = document.getElementById(objId); 
	var cur = parseInt(obj.offsetHeight);
	var hBlock = obj.scrollHeight;
	if (cur < hBlock) { 
		var newS = cur + delta;
		obj.style.height = (newS < hBlock ? newS : hBlock) + "px"; 
		timeoutId = setTimeout (function (){Show (objId)}, 13); 
	} else {
		clearTimeout(timeoutId);
		timeoutId = null;
	}
	return false;
}

function Close (objId) { 
	var obj = document.getElementById(objId); 
	var cur = parseInt(obj.offsetHeight);
	if (cur > 0) { 
		var newS = cur - delta;
		obj.style.height = (newS > 0 ? newS : 0) + "px"; 
		timeoutId = setTimeout (function (){Close (objId)}, 13); 
	} else {
		obj.style.height = "0px";
		clearTimeout(timeoutId);
		timeoutId = null;
	} 
	return false;
} 
