/*
	This script is (c) 2000 Ivanopulo http://www.damn.to
	Please leave this message intact if you use the script.
	
	Thanks alot to Marek for making this script NN6 compatible
	( Warning: NN6 is *very* slow when it comes to timers, and it's an understatement! )
*/
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" );

var nn6DivMenu; // specially for NN6 to speed up things at least a little

function CheckUIElements()
{
	var yMenuFrom, yMenuTo, yOffset, timeoutNextCheck;
	
	if ( bNetscape4 ) {
		yMenuFrom   = document["divMenu"].top;
		yMenuTo     = top.pageYOffset + 50;
	}
	else if ( bExplorer4plus ) {
		yMenuFrom   = parseInt (divMenu.style.top, 10);
		yMenuTo     = document.body.scrollTop + 50;
	}
	else if ( bNetscape6 ) {
		yMenuFrom   = nn6DivMenu.style.top.replace(/px/,"");
		yMenuTo     = top.pageYOffset + 50;
	}
	else if ( bOpera5 ) {
		yMenuFrom   = nn6DivMenu.style.top;
		yMenuTo     = top.pageYOffset + 50;
	}
	
	timeoutNextCheck = 100;
	
	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;

		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;
		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 = 50;
		}

		timeoutNextCheck = 10;
	}

	setTimeout ("CheckUIElements()", timeoutNextCheck);
}

function OnLoad()
{
	var y;
	
	// we're not gonna be loaded in frames
	if ( top.frames.length )
		top.location.href = self.location.href;
		
	// setting initial UI elements positions
	if ( bNetscape4 ) {
		document["divMenu"].top = top.pageYOffset + 50;
		document["divMenu"].visibility = "visible";
		}
	else if ( bExplorer4plus ) {
		divMenu.style.top = document.body.scrollTop + 50;
		divMenu.style.visibility = "visible";
		}
	else if ( bNetscape6 || bOpera5 ) {
		nn6DivMenu = document.getElementById('divMenu');
		nn6DivMenu.style.top = top.pageYOffset + 50;
		nn6DivMenu.style.visibility = "visible";
		

//		document.getElementById('divMenu').style.top = top.pageYOffset + 50;
//		document.getElementById('divMenu').style.visibility = "visible";
	}
	
	// initializing UI update timer
	CheckUIElements();
	return true;
}

