/* TYEENATION MENUBAR LOCATION */
menuIX = 0;
menuPX = 0;
menuPY = 70;
menuBY = 72;

var bIE      = false;
var bIE4     = false;
var bIE6     = false;
var bIE7     = false;
var bMac     = false;
var bPDA		 = false;
var bOpera   = false;
var bSafari  = false;
var bMozilla = false; 

var bMainMenu;

function checkBrowser(currentsys)
{
	var browser;

	if (currentsys && currentsys != "") {
		browser = currentsys;

		if (browser.indexOf('PDA_') != -1) {
			bPDA = true;
		}
		if (browser.indexOf('MAC_') != -1) {
			bMac = true;
		}
		if ((browser.indexOf('FIREFOX') != -1) ||(browser.indexOf('_NS') != -1)) {
			bMozilla = true;
		} else if (browser.indexOf('OPERA') != -1) {
			bOpera = true;
		} else if (browser.indexOf('SAFARI') != -1) {
			bSafari = true;
		} else {
			bIE = true;
			version = parseFloat(browser.substr(2));
			if (version >= 4.0) {
				bIE4 = true;
			}
			if (version >= 6.0) {
				bIE6 = true;
			}
			if (version >= 7.0) {
				bIE7 = true;
			}
		}

	} else {
		browser = navigator.userAgent;

		if ((browser.indexOf('Windows CE') != -1) || (browser.indexOf('PPC') != -1)) {
			bPDA = true;
		}
		if (browser.indexOf('Macintosh') != -1) {
			bMac = true;
		}
		if ((browser.indexOf('Firefox') != -1) ||(browser.indexOf('Netscape') != -1)) {
			bMozilla = true;
		} else if (browser.indexOf('Opera') != -1) {
			bOpera = true;
		} else if (browser.indexOf('Safari') != -1) {
			bSafari = true;
		} else if (browser.indexOf("MSIE") != -1) {
			bIE = true;
			temp = browser.split("MSIE");
			version=parseFloat(temp[1]);
			if (version >= 4.0) {
				bIE4 = true;
			}
			if (version >= 6.0) {
				bIE6 = true;
			}
			if (version >= 7.0) {
				bIE7 = true;
			}
		}
	}

//	alert("Browser: " + browser + "(PDA: " + bPDA + " - MAC: " + bMac + " - Mozilla: " + bMozilla + " - Opera: " + bOpera + " - Safari: " + bSafari + " - IE7: " + bIE7 + " - IE6: " + bIE6 + " - IE4: " + bIE4 + " - IE: " + bIE + ")");
}

function hide(menu, parent)
{
	if (document.layers) {
		theMenu = document.layers[menu];

	} else if (document.all) {
		if (document.all(menu))
			theMenu = document.all(menu).style;

	} else if (document.getElementById && !document.all) {
		if (document.getElementById(menu))
			theMenu = document.getElementById(menu).style;
	}

	if (theMenu) {
		if (theMenu.visibility == 'visible') {
			theMenu.visibility = 'hidden';
		} else {
			theMenu.visibility = 'hidden';
		}
	}
}

function showoff(menu, parent)
{
	if (document.layers) {
		theMenu = document.layers[menu];

	} else if (document.all) {
		theMenu = document.all(menu).style;

	} else if (document.getElementById) {
		if (document.getElementById(menu))
			theMenu = document.getElementById(menu).style;
	}

	if (theMenu.visibility == 'visible') {
		theMenu.visibility = 'visible';
	} else {
		theMenu.visibility = 'visible';
	}  
}

function CheckUIElements()
{
	var yMenuFrom, yMenuTo, bMenuFrom, bMenuTo, yOffset, bOffset, timeoutNextCheck, MainMenuObject;

	timeoutNextCheck = 100;

	if (bMac)
		divisor = 2;
	else
		divisor = 3;

	if (bMainMenu) {
		if (bMozilla) {
			MainMenuObject = document.getElementById('MainMenu');
			MainMenuObject.style.visibility = 'visible';
		}

		if (bMozilla) {
			yMenuFrom   = parseInt(MainMenuObject.style.top, 10);
			yMenuTo     = ((window.pageYOffset < menuIX) ? menuIX : window.pageYOffset) + menuPX;
//			yMenuTo     = window.pageYOffset + menuPX;
		} else if (bIE6) {
			yMenuFrom   = parseInt(MainMenu.style.top, 10);
			yMenuTo     = ((document.documentElement.scrollTop < menuIX) ? menuIX : document.documentElement.scrollTop) + menuPX;
		} else if (bIE4) {
			yMenuFrom   = parseInt(MainMenu.style.top, 10);
			yMenuTo     = ((document.body.scrollTop < menuIX) ? menuIX : document.body.scrollTop) + menuPX;
		}

		if (yMenuFrom != yMenuTo) {
			if (bMozilla)
				yOffset = Math.ceil(Math.abs(yMenuTo - yMenuFrom) / divisor);

			if (bIE4)
				yOffset = Math.ceil(Math.abs(yMenuTo - yMenuFrom) / divisor);

			if (yMenuTo < yMenuFrom)
				yOffset = -yOffset;

			if (bIE4) {
				MainMenu.style.top = (parseInt(MainMenu.style.top, 10) + yOffset) + 'px';
			}
			else if (bMozilla) {
				MainMenuObject.style.top = (parseInt (MainMenuObject.style.top , 10) + yOffset) + 'px';
			}

			timeoutNextCheck = 1;
		}
	}

	setTimeout ('CheckUIElements()', timeoutNextCheck);
}

function aSlide(currentsys)
{
	var MainMenuObject;

	checkBrowser (currentsys);

	if (!bIE4 && !bMozilla)
		return;

	if ((document.body.clientHeight + document.documentElement.clientHeight) > 600) {
		if (bMozilla) {
			MainMenuObject = document.getElementById('MainMenu');
			MainMenuObject.style.visibility = 'visible';
		}

		bMainMenu = document.getElementById('MainMenu');

		if (bIE6) {
			if (bMainMenu) {
				MainMenu.style.top = (((document.documentElement.scrollTop < menuIX) ? menuIX : document.documentElement.scrollTop) + menuPX) + 'px';
				MainMenu.style.visibility = 'visible';
			}
		} else if (bIE4) {
			if (bMainMenu) {
				MainMenu.style.top = (((document.body.scrollTop < menuIX) ? menuIX : document.body.scrollTop) + menuPX) + 'px';
				MainMenu.style.visibility = 'visible';
			}
		} else if (bMozilla) {
			MainMenuObject.style.top = (((window.pageYOffset < menuIX) ? menuIX : window.pageYOffset) + menuPX) + 'px';
		}

		CheckUIElements();
	}
}
