// This script is (c) 2000 DAMN, (c) 2001 SierraRC

var nn6DivMenu, nn6DivButton, yMax; // specially for NN6 to speed up things at least a little
var bNetscape4     = (navigator.appName == "Netscape" && navigator.appVersion.substring(0,1) == "4");
var bNetscape6     = (navigator.appName == "Netscape" && navigator.appVersion.substring(0,1) >= "5");
var bExplorer4plus = (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.substring(0,1) >= "4");
var bOpera5        = (navigator.appName == "Opera" && navigator.appVersion.substring(0,1) >= "5" );

function CheckUIElements()
{
	var yMenuFrom, yMenuTo, yOffset, timeoutNextCheck;
	
	if ( bNetscape4 ) {
		yMenuFrom   = document["divMenu"].top;
		yMenuTo     = top.pageYOffset + 70;
	}                                                             	
	else if ( bExplorer4plus ) {
//	alert(divMenu.style.top);
		yMenuFrom   = parseInt (divMenu.style.top,10)-50;
		yMenuTo     = document.body.scrollTop + 100;
//		yMax = document.body.scrollHeight-50;
		yMax = document.body.clientHeight - 320;

		//alert(yMax);
		if (yMenuTo>yMax) 
		{
//			alert(yMenuTo);
			yMenuTo = yMax;
		}
	}
	else if ( bNetscape6 || bOpera5) {
		yMenuFrom   = nn6DivMenu.style.top.replace(/px/,"");
		yMenuTo     = top.pageYOffset + 70;
	}
//	else if ( bOpera5 ) {
//		nn6DivMenu = document.getElementById('divMenu');
//		yMenuFrom   = nn6DivMenu.style.top;
//		yMenuTo     = top.pageYOffset + 70;
//	}
	
	timeoutNextCheck = 700;
	

	if ( yMenuFrom != yMenuTo ) {
	
		if ( bNetscape6 )
			yOffset = Math.ceil( Math.abs( yMenuTo - yMenuFrom ) / 10 );
		else
			yOffset = Math.ceil( Math.abs( yMenuTo - yMenuFrom ) / 30 );
			
		if ( yMenuTo < yMenuFrom )
			yOffset = -yOffset;
		
		timeoutNextCheck = 10;

//alert(yOffset);
		if ( bNetscape4 )
			document["divMenu"].top += yOffset;
		else if ( bExplorer4plus )
			divMenu.style.top = parseInt (divMenu.style.top, 10) + yOffset  ;
		else if ( bOpera5 )
			nn6DivMenu.style.top += yOffset;
//			nn6DivButton.style.left += xOffset;
		else if ( bNetscape6 ) {
			nn6DivMenu.style.top = eval(nn6DivMenu.style.top.replace(/px/,"")) + yOffset;
//			document.getElementById('divMenu').style.top = eval(document.getElementById('divMenu').style.top.replace(/px/,"")) + yOffset;
			timeoutNextCheck = 70;
		}

		timeoutNextCheck = 10;
	}

	setTimeout ("CheckUIElements()", timeoutNextCheck);
}

function OnLoad()
{
	var y, yMax;
	
//	yMax = document.body.scrollHeight-400;


	// we're not gonna be loaded in frames, no sir!
	if ( top.frames.length )
		top.location.href = self.location.href;
		
	// setting initial UI elements positions
	if ( bNetscape4 ) {
		document["divMenu"].top = top.pageYOffset + 70;
		document["divMenu"].visibility = "visible";
	}
	else if ( bExplorer4plus ) {
		yMax = document.body.clientHeight - 320;
//		alert(document.body.scrollTop);
		y = document.body.scrollTop + 85;
//		alert(yMax);
		if (y>yMax) 
		{
			y = yMax;
//			alert(y);
		}
		divMenu.style.top = y;
		divMenu.style.visibility = "visible";
		
//		alert(yMax);
	}
	else if ( bNetscape6 || bOpera5 ) {
		nn6DivMenu = document.getElementById('divMenu');
		nn6DivMenu.style.top = top.pageYOffset + 70;
		nn6DivMenu.style.visibility = "visible";
	}
	
	// initializing UI update timer


	CheckUIElements();
	return true;
}

