function MainMenu(currSec) {
	this._sections                = new Array('home', 'openaccount', 'investment', 'perspectives', 'overview', 'news', 'info', 'about');
	this._currentSection          = null;
	this.showSubMenu              = _mm_showSubMenu;
	this.hideSubMenu              = _mm_hideSubMenu;
	this.hideAllSubmenu           = _mm_hideAllSubMenu;
	this.highlightSectionTab      = _mm_highlightSectionTab;
	this.unHighlightSectionTab    = _mm_unHighlightSectionTab;
	this.unHighlightAllSectionTab = _mm_unHighlightAllSectionTab;
	this.getCurrentSection        = _mm_getCurrentSection;
	this.setCurrentSection        = _mm_setCurrentSection;
	this.resumeCurrentSection     = _mm_resumeCurrentSection;
	this.tabMouseOver             = _mm_tabMouseOver;
	this.tabMouseOut              = _mm_tabMouseOut;
	this.subMenuMouseOver         = _mm_subMenuMouseOver;
	this.subMenuMouseOut          = _mm_subMenuMouseOut;
	// Test if there is a globally defined section names
	if(window.mmSectionNames != null) {
		this._sections = window.mmSectionNames;
	}
	if(currSec != null) {
		this.setCurrentSection(currSec);
	}
	// Register menu tab behaviors.
	for(var i = 0; i < this._sections.length; i++) {
		var sectionName = this._sections[i];
		var tabElement = document.getElementById('mainMenuTab_' + sectionName);
		if(tabElement != null) {
			tabElement.onmouseover = new Function('mm.tabMouseOver("' + sectionName + '");');
			tabElement.onmouseout = new Function('mm.tabMouseOut("' + sectionName + '");');
		}
		var subMenuElement = document.getElementById('subMenu_' + sectionName);
		if(subMenuElement != null) {
			subMenuElement.onmouseover = new Function('mm.subMenuMouseOver("' + sectionName + '");');
			subMenuElement.onmouseout = new Function('mm.subMenuMouseOut("' + sectionName + '");');
		}
	} // for
} // MainMenu()

function _mm_tabMouseOver(section) {
	this.showSubMenu(section);
	this.highlightSectionTab(section);
} // _mm_tabMouseOver()

function _mm_tabMouseOut(section) {
	this.resumeCurrentSection();
} // _mm_tabMouseOut()

function _mm_subMenuMouseOver(section) {
	this.showSubMenu(section);
	this.highlightSectionTab(section);
} // _mm_subMenuMouseOver()

function _mm_subMenuMouseOut(section) {
	this.resumeCurrentSection();
} // _mm_subMenuMouseOut()

function _mm_getCurrentSection() {
	return this._currentSection;
} // _mm_getCurrentSection()

function _mm_resumeCurrentSection() {
	this.setCurrentSection(this._currentSection);
} // _mm_resumeCurrentSection()

function _mm_setCurrentSection(section) {
	this._currentSection = section;
	this.showSubMenu(section);
	this.highlightSectionTab(section);
} // _mm_setCurrentSection()

function _mm_showSubMenu(section) {
	this.hideAllSubmenu();
	this.unHighlightAllSectionTab();
	var sectionParts =  _mm_getSectionParts(section);
	var subMenuElement = document.getElementById('subMenu_' + sectionParts[0]);
	if(subMenuElement != null) {
		subMenuElement.style.visibility = 'visible';
	}
	// Find the "a" element for the current sub section.
	var element = document.getElementById('subMenu_' + sectionParts[0] + '_' + sectionParts[1]);
	if(element != null) {
		element.className = 'highlight';
	}
} // _mm_showSubMenu()

function _mm_hideSubMenu(section) {
	this.unHighlightAllSectionTab();
	var sectionParts =  _mm_getSectionParts(section);
	var subMenuElement = document.getElementById('subMenu_' + sectionParts[0]);
	if(subMenuElement == null) {
		return false;
	}
	subMenuElement.style.visibility = 'hidden';
} // _mm_hideSubMenu()

function _mm_hideAllSubMenu() {
	for(var i = 0; i < this._sections.length; i++) {
		this.hideSubMenu(this._sections[i]);
	}
} // _mm_hideAllSubMenu()

function _mm_highlightSectionTab(section) {
	this.unHighlightAllSectionTab();
	var sectionParts = _mm_getSectionParts(section);
	var tabElement = document.getElementById('mainMenuTab_' + sectionParts[0]);
	if(tabElement == null) {
		return false;
	}
	tabElement.className = 'tabHighlight';
} // _mm_highlightSectionTab()

function _mm_unHighlightSectionTab(section) {
	var sectionParts = _mm_getSectionParts(section);
	var tabElement = document.getElementById('mainMenuTab_' + sectionParts[0]);
	if(tabElement == null) {
		return false;
	}
	tabElement.className = 'tabNormal';
} // _mm_unHighlightSectionTab()

function _mm_unHighlightAllSectionTab() {
	for(var i = 0; i < this._sections.length; i++) {
		this.unHighlightSectionTab(this._sections[i]);
	}
} // _mm_unHighlightAllSectionTab()

function _mm_getSectionParts(section) {
	return section.split('.');
} // _mm_getSectionParts()

function _array_hasElement(element) {
	for(var i = 0; i < this.length; i++) {
		if(this[i] == element) {
			return true;
		}
	}
	return false;
} // _array_hasElement()
Array.prototype.hasElement = _array_hasElement;
