var bNetscape4plus = (navigator.appName == "Netscape" && navigator.appVersion.substring(0,1) >= "4");
var bExplorer4plus = (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.substring(0,1) >= "4");

function CheckUIElements()
{
	var maxscroll = 135;
	var xx,yMenuFrom, yMenuTo, yOffset, timeoutNextCheck;
	xx=0;
        if ( bNetscape4plus ) {
		yMenuFrom   = document["divMenu"].top;
		if (top.frames["mainFrame"].pageYOffset < maxscroll) {xx = top.frames["mainFrame"].pageYOffset;} else {xx = maxscroll - 6;}
		yMenuTo     = top.frames["mainFrame"].pageYOffset - xx;

	}
	else if ( bExplorer4plus ) {
		yMenuFrom   = parseInt (divMenu.style.top, 10);
		if (document.body.scrollTop < maxscroll) {xx = document.body.scrollTop ;} else {xx = maxscroll - 6;}
		yMenuTo     = document.body.scrollTop - xx;
	}
	
	timeoutNextCheck = 500;

	
	
	if ( yMenuFrom != yMenuTo ) {
		yOffset = Math.ceil( Math.abs( yMenuTo - yMenuFrom ) /2 );
		if ( yMenuTo < yMenuFrom )
			yOffset = -yOffset;
		
		if ( bNetscape4plus )
			document["divMenu"].top += yOffset;
		else if ( bExplorer4plus )
			divMenu.style.top = parseInt (divMenu.style.top, 10) + yOffset;

		timeoutNextCheck = 10;
	}
	
	setTimeout ("CheckUIElements()", timeoutNextCheck);
}

function OnLoad()
{

	if ( bNetscape4plus ) {
		document["divMenu"].top = top.frames["mainFrame"].pageYOffset + 0;
		document["divMenu"].visibility = "visible";
	}
	else if ( bExplorer4plus ) {
		divMenu.style.top = document.body.scrollTop + 0;
		divMenu.style.visibility = "visible";
	}
	
	// initializing UI update timer
	CheckUIElements();
	if ( bExplorer4plus )
	return true;
}
