var Definitions = {
	Menu : {
		GENERAL: {
			ID:			0
		},
		ABOUT_US: {
			ID:			1,
			TEXT:		"About Us",
			PADDING:	321,
			URL:		null,
			OPTIONS: 	[
				//["Vision & Mission", "../about/vision_mission.html"],
				["Executive Team", "../about/executive_team.html"],
				["Contact Us", "../about/contact_us.html"]
			]
		},
		EXPERTISE: {
			ID:			2,
			TEXT:		"Company",
			PADDING:	20,
			URL:		null,
			OPTIONS:	[
                ["Who We Are", "../expertise/who_we_are.html"],
				["What Defines Us", "../expertise/what_defines_us.html"]
            ]
		},
		SERVICES: {
			ID:			3,
			TEXT:		"Services",
			PADDING:	224,
			URL:		null,
			OPTIONS: 	[
//				["Project Development", "../services/project_dev.html"],
				["By Design", "../services/by_design.html"],
//				["Co-Ventures", "../services/co_ventures.html"],
				["Classic Realty", "../services/classic_realties.html"]
			]
		},
		PORTFOLIO: {
			ID:			4,
			TEXT:		"Portfolio",
			PADDING:	126,
			URL:		null,
			OPTIONS: 	[
				["Current Developments", "../portfolio/current_projects.html"],
				["Completed Properties", "../portfolio/completed_properties.html"]
			]
		},
		NEWS: {
			ID:			5,
			TEXT:		"News & Events",
			PADDING:	425,
			URL:		null,
			OPTIONS: 	[
				["Articles", "../news/articles.html"],
				["Events", "../news/events.html"]
			]
		}
	}
};

var MENU_IS_DOCKED	= false;
var INITIAL_MENU	= null;
var INITIAL_SUBMENU	= -1;
var ACTIVE_MENU		= null;

function setMenuRollOverTdStyle(oTd){
	try {
		oTd.style.color = "#2C5C68";
		oTd.style.backgroundColor = "#F4F8F7";
	} catch(e) {}
}

function setMenuRollOutTdStyle(oTd){
	try {
		oTd.style.color = "#FFFFFF";
		oTd.style.backgroundColor = "#A7BEB4";
	} catch(e) {}
}

function menuRollOver(oMenu, evnt){
	try {
		var submenu = document.getElementById("submenu");
		var oTd	= document.getElementById("menu_" + oMenu.ID);
		var aHTML = new Array();

		setMenuRollOverTdStyle(oTd);
		
		if (MENU_IS_DOCKED && oMenu != INITIAL_MENU){
			var initialTd = document.getElementById("menu_" + INITIAL_MENU.ID);
			setMenuRollOutTdStyle(initialTd);
		}
		
		switch (oMenu){
			case Definitions.Menu.ABOUT_US:
				var options = Definitions.Menu.ABOUT_US.OPTIONS;
				aHTML[aHTML.length] = '<table style="margin-top:8px" border="0" cellpadding="0" cellspacing="0"><tbody><tr>';
				aHTML[aHTML.length] = '<td class="link1" align="center" width="'+oMenu.PADDING+'"></td>';
				
				for (var i=0; i<options.length; i++){
					aHTML[aHTML.length] = '<td><a class="submenu-link" ' + ((INITIAL_SUBMENU==i && INITIAL_MENU==oMenu)?'style="font-weight:bolder" ':'') + 'href="' + options[i][1] + '">' + options[i][0] + '</a></td>';
					if (i < options.length-1)
						aHTML[aHTML.length] = '<td class="submenu-link" align="center" width="30">|</td>';
				}
				
				aHTML[aHTML.length] = '</tr></tbody></table>';
				submenu.style.visibility = "visible";
				break;
			case Definitions.Menu.EXPERTISE:
				var options = Definitions.Menu.EXPERTISE.OPTIONS;
				aHTML[aHTML.length] = '<table style="margin-top:8px" border="0" cellpadding="0" cellspacing="0"><tbody><tr>';
				aHTML[aHTML.length] = '<td class="link1" align="center" width="'+oMenu.PADDING+'"></td>';

				for (var i=0; i<options.length; i++){
					aHTML[aHTML.length] = '<td><a class="submenu-link" ' + ((INITIAL_SUBMENU==i && INITIAL_MENU==oMenu)?'style="font-weight:bolder" ':'') + 'href="' + options[i][1] + '">' + options[i][0] + '</a></td>';
					if (i < options.length-1)
						aHTML[aHTML.length] = '<td class="submenu-link" align="center" width="30">|</td>';
				}

				aHTML[aHTML.length] = '</tr></tbody></table>';
				submenu.style.visibility = "visible";
				break;
			case Definitions.Menu.SERVICES:
				var options = Definitions.Menu.SERVICES.OPTIONS;
				aHTML[aHTML.length] = '<table style="margin-top:8px" border="0" cellpadding="0" cellspacing="0"><tbody><tr>';
				aHTML[aHTML.length] = '<td class="link1" align="center" width="'+oMenu.PADDING+'"></td>';
				
				for (var i=0; i<options.length; i++){
					aHTML[aHTML.length] = '<td><a class="submenu-link" ' + ((INITIAL_SUBMENU==i && INITIAL_MENU==oMenu)?'style="font-weight:bolder" ':'') + 'href="' + options[i][1] + '">' + options[i][0] + '</a></td>';
					if (i < options.length-1)
						aHTML[aHTML.length] = '<td class="submenu-link" align="center" width="30">|</td>';
				}
				
				aHTML[aHTML.length] = '</tr></tbody></table>';
				submenu.style.visibility = "visible";
				break;
			case Definitions.Menu.PORTFOLIO:
				var options = Definitions.Menu.PORTFOLIO.OPTIONS;
				aHTML[aHTML.length] = '<table style="margin-top:8px" border="0" cellpadding="0" cellspacing="0"><tbody><tr>';
				aHTML[aHTML.length] = '<td class="link1" align="center" width="'+oMenu.PADDING+'"></td>';
				
				for (var i=0; i<options.length; i++){
					aHTML[aHTML.length] = '<td><a class="submenu-link" ' + ((INITIAL_SUBMENU==i && INITIAL_MENU==oMenu)?'style="font-weight:bolder" ':'') + 'href="' + options[i][1] + '">' + options[i][0] + '</a></td>';
					if (i < options.length-1)
						aHTML[aHTML.length] = '<td class="submenu-link" align="center" width="30">|</td>';
				}
				
				aHTML[aHTML.length] = '</tr></tbody></table>';
				submenu.style.visibility = "visible";
				break;
			case Definitions.Menu.NEWS:
				var options = Definitions.Menu.NEWS.OPTIONS;
				aHTML[aHTML.length] = '<table style="margin-top:8px" border="0" cellpadding="0" cellspacing="0"><tbody><tr>';
				aHTML[aHTML.length] = '<td class="link1" align="center" width="'+oMenu.PADDING+'"></td>';
				
				for (var i=0; i<options.length; i++){
					aHTML[aHTML.length] = '<td><a class="submenu-link" ' + ((INITIAL_SUBMENU==i && INITIAL_MENU==oMenu)?'style="font-weight:bolder" ':'') + 'href="' + options[i][1] + '">' + options[i][0] + '</a></td>';
					if (i < options.length-1)
						aHTML[aHTML.length] = '<td class="submenu-link" align="center" width="30">|</td>';
				}
				
				aHTML[aHTML.length] = '</tr></tbody></table>';
				submenu.style.visibility = "visible";
				break;
		}
		submenu.innerHTML = aHTML.join("");
		ACTIVE_MENU = oMenu;
	} catch(e) {}
}

function menuRollOut(oMenu, evnt){
	try {
		var submenu = document.getElementById("submenu");
		var oTd	= document.getElementById("menu_" + oMenu.ID);

		setMenuRollOutTdStyle(oTd);
		if (MENU_IS_DOCKED){
			var r = null;
			if (window.event)
				r = evnt.toElement;
			else
				r = evnt.relatedTarget;
			
			if (r != submenu && !contains(submenu, r)){
				menuRollOver(INITIAL_MENU);
			}
		}else{
			submenu.style.visibility = "hidden";
		}
	} catch(e) {}
}

function submenuRollOver(evnt){
	try {
		var submenu = document.getElementById("submenu");
		var oTd	= document.getElementById("menu_" + ACTIVE_MENU.ID);

		setMenuRollOverTdStyle(oTd);
		if (!MENU_IS_DOCKED){
			submenu.style.visibility = "visible";
		}
	} catch(e) {}
}

function submenuRollOut(evnt){
	try {
		var submenu = document.getElementById("submenu");
		var oTd	= document.getElementById("menu_" + ACTIVE_MENU.ID);
		
		setMenuRollOutTdStyle(oTd);
		if (MENU_IS_DOCKED){
			var r = null;
			if (window.event)
				r = evnt.toElement;
			else
				r = evnt.relatedTarget;
			
			if (r != submenu && !contains(submenu, r)){
				menuRollOver(INITIAL_MENU);
			}
		}else{
			submenu.style.visibility = "hidden";
		}
	} catch(e) {}
}

function contains(a,b){
	try {
		while (b.parentNode)
			if ((b = b.parentNode) == a)
				return true;
	} catch(e) {
		return false;
	}
	return false;
};

function openPage(url){
	window.location.href = url;
}

function createMenu(isDocked, oMenu, oSubMenu){
	try {
		MENU_IS_DOCKED = isDocked;
		INITIAL_MENU = oMenu;
		INITIAL_SUBMENU = oSubMenu;

		/*document.write(	'<table width="100%" height="41" border="0" cellpadding="0" cellspacing="0">' +
							'<tr>' +
								'<td align="center" onmouseover="menuRollOver(Definitions.Menu.ABOUT_US, event)" id="menu_'+Definitions.Menu.ABOUT_US.ID+'" onmouseout="menuRollOut(Definitions.Menu.ABOUT_US, event)" width="100" class="menu-root menu-border-right">' + Definitions.Menu.ABOUT_US.TEXT + '</td>' +
								'<td align="center" onmouseover="menuRollOver(Definitions.Menu.EXPERTISE, event)" id="menu_'+Definitions.Menu.EXPERTISE.ID+'" onmouseout="menuRollOut(Definitions.Menu.EXPERTISE, event)" width="105" class="menu-root menu-border-right menu-border-left" onclick="openPage(\''+Definitions.Menu.EXPERTISE.URL+'\')">' + Definitions.Menu.EXPERTISE.TEXT + '</td>' +
								'<td align="center" onmouseover="menuRollOver(Definitions.Menu.SERVICES, event)" id="menu_'+Definitions.Menu.SERVICES.ID+'" onmouseout="menuRollOut(Definitions.Menu.SERVICES, event)" width="94" class="menu-root menu-border-right menu-border-left">' + Definitions.Menu.SERVICES.TEXT + '</td>' +
								'<td align="center" onmouseover="menuRollOver(Definitions.Menu.PORTFOLIO, event)" id="menu_'+Definitions.Menu.PORTFOLIO.ID+'" onmouseout="menuRollOut(Definitions.Menu.PORTFOLIO, event)" width="95" class="menu-root menu-border-right menu-border-left">' + Definitions.Menu.PORTFOLIO.TEXT + '</td>' +
								'<td align="center" onmouseover="menuRollOver(Definitions.Menu.NEWS, event)" id="menu_'+Definitions.Menu.NEWS.ID+'" onmouseout="menuRollOut(Definitions.Menu.NEWS, event)" width="152" class="menu-root menu-border-left">' + Definitions.Menu.NEWS.TEXT + '</td>' +
								'<td align="right" valign="top" width="155" class="bg3">' +
									(oMenu!=Definitions.Menu.GENERAL?'':'<img width="155" height="41" border="0" src="../common/images/menu.jpg">') + 
									//'<div style="padding:3px 12px 0px 0px"><a href="../../mprod/home/home.html">Visit Horizen Global<br>Movie Production</a></div>' +
								'</td>' +
							'</tr>' +
						'</table>' +
						'<span id="submenu" style="visibility:' + ((isDocked && oMenu.OPTIONS.length > 0)?'visible':'hidden') + '" class="submenu submenu-image" onmouseover="submenuRollOver(event)" onmouseout="submenuRollOut(event)"></span>');
		*/
		if (isDocked){
			menuRollOver(oMenu);
		}
		
	} catch(e) {}
}