/*
	This script is (c) 2000 Ivanopulo http://www.damn.to
	Please leave this message intact if you use the script.
*/
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 yMenuFrom, yMenuTo, yButtonFrom, yButtonTo, yOffset, timeoutNextCheck;
	
	if ( bNetscape4plus ) {

		yMenuFrom   = document["divMenu"].top;
		yMenuTo     = top.pageYOffset + 130;
	}
	else if ( bExplorer4plus ) {

		yMenuFrom   = parseInt (divMenu.style.top, 10);
		yMenuTo     = document.body.scrollTop + 130;
	}
	
	timeoutNextCheck = 500;

	if ( Math.abs (yButtonFrom - (yMenuTo + 113)) < 6 && yButtonTo < yButtonFrom ) {
		setTimeout ("CheckUIElements()", timeoutNextCheck);
		return;
	}
	
	

	if ( yMenuFrom != yMenuTo ) {
		yOffset = Math.ceil( Math.abs( yMenuTo - yMenuFrom ) / 20 );
		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()
{
	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 ( bNetscape4plus ) {
		document["divMenu"].top = top.pageYOffset + 119;
		document["divMenu"].visibility = "visible";

	}
	else if ( bExplorer4plus ) {
		divMenu.style.top = document.body.scrollTop + 119;
		divMenu.style.visibility = "visible";

	}
	
	// initializing UI update timer
	CheckUIElements();
	return true;
}

function funcSwapImage(imageName, bHilite) {
// DUMB Netscape doesn't see img names if they're inside a <div which has an id
// if they're just in <div></div> - it's okay, but that's not the case :\
// Workaround (using layers) was provided by Kostya. Tnx man :)
	if ( bExplorer4plus ) {
		document.images[imageName].src = "" + imageName + (bHilite == 1 ? "_hi.gif" : "_lo.gif");
	}
	else if ( bNetscape4plus ) {
		document.layers["divMenu"].document.images[imageName].src = "" + imageName + (bHilite == 1 ? "_hi.gif" : "_lo.gif");
	}
	return false;
}



/* IE only function for flashing the page title onload */
function StartTitleFlash()
{
	if ( bExplorer4plus )
		setTimeout ( "FlashTitleStepIt(255)", 10 );
	return true;
}

function FlashTitleStepIt( fptItersLeft )
{
	var str;
	str = fptItersLeft.toString(16);
	str = eval ( "\"#" + str + str + str + "\"" );
	
	pageTitle.style.color = str;

	fptItersLeft--;
	if ( str !=  "#606060" )
		setTimeout ( eval ( "\"FlashTitleStepIt(" + fptItersLeft + ")\"" ), 10 );
}
