/*
	This script (c) 2000 Ivanopulo / DAMN -- http://www.damn.to
	You're free to use it, but please leave this message intact if you do it.
	
	Thanks alot to Marek for making this script NN6 compatible
	
	NN6 notice: It's *very* slow when it comes to timers, and it's an understatement!)
	
	Opera notice: Opera can identify itself as any browser, depending on value chosen
	in Preferences / Connections / Browser identification. This script assumes that it
	identifies itself as Opera. I dare not say it's a bold assumption, but it's default
	is MSIE 5. Go figure.
*/

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
var topoffset = 1;
var wheigth;


function CheckUIElements()
{
	var yMenuFrom, yMenuTo, yButtonFrom, yButtonTo, yOffset, timeoutNextCheck;
	
	if ( bNetscape4 ) {
		yMenuFrom   = document["divMenu"].top;
		yMenuTo	 = top.pageYOffset + topoffset;
		wheight = top.innerHeight;
	}
	else if ( bExplorer4plus ) {
		yMenuFrom   = parseInt (divMenu.style.top, 10);
		yMenuTo	 = document.body.scrollTop + topoffset;
		wheight = document.body.clientHeight;
	}
	else if ( bNetscape6 ) {
		yMenuFrom   = nn6DivMenu.style.top.replace(/px/,"");
		yMenuTo	 = top.pageYOffset + topoffset;
		wheight = top.innerHeight;
	}
	else if ( bOpera5 ) {
		yMenuFrom   = nn6DivMenu.style.top;
		yMenuTo	 = top.pageYOffset + topoffset;
		wheight = top.innerHeight;
	}
	
	
	timeoutNextCheck = 500;
	
	if ( yMenuFrom != yMenuTo && wheight >= 460 ) {
	
		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;
			timeoutNextCheck = 50;
		}

		timeoutNextCheck = 10;
	}

	setTimeout ("CheckUIElements()", timeoutNextCheck);
}

function ReadCookie (CookieName) {
  var CookieString = document.cookie;
  var CookieSet = CookieString.split (';');
  var SetSize = CookieSet.length;
  var CookiePieces
  var ReturnValue = "";
  var x = 0;

  for (x = 0; ((x < SetSize) && (ReturnValue == "")); x++) {

	CookiePieces = CookieSet[x].split ('=');

	if (CookiePieces[0].substring (0,1) == ' ') {
	  CookiePieces[0] = CookiePieces[0].substring (1, CookiePieces[0].length);
	}

	if (CookiePieces[0] == CookieName) {
	  ReturnValue = CookiePieces[1];
	}

  }

  return ReturnValue;

}


function OnLoad()
{
	if (ReadCookie('nofloat')=='"1"') return true;
	// we're not gonna be loaded in frames, no sir!

		
	// setting initial UI elements positions
	if ( bNetscape4 ) {
		document["divMenu"].top = top.pageYOffset + topoffset;
		document["divMenu"].visibility = "visible";
	}
	else if ( bExplorer4plus ) {
		divMenu.style.top = document.body.scrollTop + topoffset;
		divMenu.style.visibility = "visible";
	}
	else if ( bNetscape6 || bOpera5 ) {
		nn6DivMenu = document.getElementById('divMenu');
		nn6DivMenu.style.top = top.pageYOffset + topoffset;
		nn6DivMenu.style.visibility = "visible";
	}
	
	// initializing UI update timer
	CheckUIElements();
	return true;
}

