var halfX;
var halfY;
var fullX;
var fullY;
var nMenuShow = -1;
var objMenu;
var objInner;
var nAlpha = 0;
var invClose;
var invFI;
var invFO;

var arrMenu = new Array();
arrMenu[0] = new Array();
arrMenu[0][0] = new Array("OVERVIEW","VILLAS & FACILITIES","LAND PLOTS");
arrMenu[0][1] = new Array("masterplan.htm","villas.htm","landplot.php");
arrMenu[0][2] = 128; //width
arrMenu[0][3] = 134; //top (position Y)
arrMenu[0][4] = -252; //x pos from center

arrMenu[1] = new Array();
arrMenu[1][0] = new Array("MAP","GETTING HERE");
arrMenu[1][1] = new Array("location.htm","gettinghere.htm");
arrMenu[1][2] = 96; //width
arrMenu[1][3] = 136; //top (position Y)
arrMenu[1][4] = -135; //x pos from center

arrMenu[2] = new Array();
arrMenu[2][0] = new Array("VILLAS RENTAL","ACTIVIES & AMENITIES");
arrMenu[2][1] = new Array("rental.php","activities.htm");
arrMenu[2][2] = 126; //width
arrMenu[2][3] = 132; //top (position Y)
arrMenu[2][4] = -58; //x pos from center
/*
arrMenu[3] = new Array();
arrMenu[3][0] = new Array("RESERVATION");
arrMenu[3][1] = new Array("page1.html");
arrMenu[3][2] = 124; //width
arrMenu[3][3] = 136; //top (position Y)
arrMenu[3][4] = -189; //x pos from center
*/
function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	} else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		} else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}

function initial() {
	IE = document.all ? true : false;
	fox = new RegExp("Firefox","i");
	chrome = new RegExp("Chrome","i");
	safari = new RegExp("Safari","i");
	opera = new RegExp("Opera","i");
	if (IE) {
		fullX = document.body.clientWidth;
		fullY = getWindowHeight();
	}
	else if (fox.test(navigator.userAgent) || chrome.test(navigator.userAgent) || safari.test(navigator.userAgent) || opera.test(navigator.userAgent)) {
		fullX = document.body.clientWidth;
		fullY = getWindowHeight();
	}
	else {
		fullX = pageXOffset;
		fullY = pageYOffset;
	}
	halfX = Math.floor(fullX / 2);
	halfY = fullY / 2;
	objMenu = document.getElementById("menuFly");
	objInner = document.getElementById("menuInner");
	setAlpha(objMenu,40);
}

function showMenu(ref,n,y) {
	clearInterval(invClose);
	if (n == nMenuShow) return;
	ref.onmouseout = closeMenu;
	obj = arrMenu[n];
	txt = "";
	for (i = 0;i < obj[0].length;i++) {
		txt += "<div align=\"center\" style=\"height:20px;\" onmouseover=\"clearInterval(invClose)\" onmouseout=\"closeMenu()\"><a href=\"" + obj[1][i] + "\"><font color=\"#676757\">" + obj[0][i] + "</font></a></div>";
	}
	
	nAlpha = 0;
	setAlpha(objInner,nAlpha);
	setAlpha(objMenu,nAlpha - 60);
	
	objInner.innerHTML = txt;
	objMenu.style.width = obj[2] + "px";
	nTop = obj[3];
	if (y) {
		scrollY = (document.documentElement.scrollTop) ? document.documentElement.scrollTop : window.pageYOffset;
		nTop = scrollY + fullY - 55;
	}
	objMenu.style.top = nTop + "px";
	objMenu.style.left = (halfX + obj[4]) + "px";
	objInner.style.width = (obj[2] - 10) + "px";
	objInner.style.top = (nTop + 5) + "px";
	objInner.style.left = (halfX + obj[4] + 5) + "px";
	objMenu.style.height = ((20 * obj[0].length) + 10) + "px";
	
	nMenuShow = n;

	clearInterval(invFI);
	clearInterval(invFO);
	invFI = setInterval(fadeIn,30);
}

function setAlpha(obj,per) {
	inone = per / 100;
	if (inone >= 1) inone = 0.99;
	obj.style.opacity = inone;
	obj.style.MozOpacity = inone;
	obj.style.KhtmlOpacity = per / 100;
	obj.style.filter = "alpha(opacity=" + per + ")";
}

function fadeIn() {
	nAlpha += 5;
	nAlpha2 = nAlpha;
	//if (nAlpha2 > 80) nAlpha2 = 80;
	setAlpha(objInner,nAlpha);
	setAlpha(objMenu,nAlpha2);
	if (nAlpha >= 100) clearInterval(invFI);
}

function closeMenu() {
	clearInterval(invClose);
	invClose = setInterval(closeMenu2,1000);
}

function closeMenu2() {
	nMenuShow = -1;
	clearInterval(invFI);
	clearInterval(invFO);
	invFO = setInterval(fadeOut,30);
}

function fadeOut() {
	nAlpha -= 5;
	//nAlpha2 = nAlpha - 60;
	//if (nAlpha2 < 0) nAlpha2 = 0;
	setAlpha(objInner,nAlpha);
	setAlpha(objMenu,nAlpha);
	if (nAlpha <= 0) {
		clearInterval(invFO);
		objMenu.style.top = "-500px";
		objInner.style.top = "-500px";
	}
}