var menuTopMargin = 100;
var menuSpeed = 5;
var timerSpeed = 200;
var timer;
var heightLimit = 0;

/*
function checkMenu() {
	if(document.body.offsetHeight > heightLimit) {
		var reTimer = timerSpeed;
		var startPoint = parseInt(document.all.sMenu.style.top,10);
		var endPoint = document.body.scrollTop;
		endPoint = (menuTopMargin <= endPoint ) ? endPoint - menuTopMargin : 0;
		if(startPoint != endPoint) {
			moveAmount = Math.ceil(Math.abs(endPoint - startPoint) / 15);
			document.all.sMenu.style.top = parseInt(document.all.sMenu.style.top,10) + ((endPoint<startPoint) ? -moveAmount : moveAmount);
			reTimer = menuSpeed;
		}
	} else document.all.sMenu.style.top = 0;
	timer = setTimeout("checkMenu();",reTimer);
}

function initsMenu(val) {
	if(document.body.offsetHeight > heightLimit) document.all.sMenu.style.top = document.body.scrollTop;
	menuTopMargin = val
	checkMenu();
}
*/

var menuflag 

function checkMenu(str) {
	menuflag = eval('document.all.'+str+'.style');
	if(document.body.offsetHeight > heightLimit) {
		var reTimer = timerSpeed;
		var startPoint = parseInt(menuflag.top,10);
		var endPoint = document.body.scrollTop;
		endPoint = (menuTopMargin <= endPoint ) ? endPoint - menuTopMargin : 0;
		if(startPoint != endPoint) {
			moveAmount = Math.ceil(Math.abs(endPoint - startPoint) / 15);
			menuflag.top = parseInt(menuflag.top,10) + ((endPoint<startPoint) ? -moveAmount : moveAmount);
			reTimer = menuSpeed;
		}
	} else menuflag.top = 0;
	timer = setTimeout("checkMenu('"+str+"');",reTimer);
}

function initsMenu(val, str) {
	if (str == '' || str == null)
	{
		str = 'sMenu'
	}
	menuflag = eval('document.all.'+str+'.style');
	if(document.body.offsetHeight > heightLimit) menuflag.top = document.body.scrollTop;
	menuTopMargin = val
	checkMenu(str);
}

