function CMenu(instanceVar, id, topmenuBegin, topmenuEnd, topmenuSeparator, submenuSign, type) { this.instanceVar = instanceVar; this.id = id; this.topmenuBegin = topmenuBegin; this.topmenuEnd = topmenuEnd; this.topmenuSeparator = topmenuSeparator; this.submenuSign = submenuSign; this.type = type || 0; this.oDrawTarget = document.getElementById(id); this.rootItem = null; this.init = CMenu_init; this.getItemById = CMenu_getItemById; this.onMouseOver = CMenu_onMouseOver; this.onMouseOut = CMenu_onMouseOut; this.onClick = CMenu_onClick; } function CMenu_init(arrItemData) { this.rootItem = new CMenuItem(this, null, this.id, "root", null, arrItemData); var html = ""; for (var level = 1; ; level++) { var htmlOneLevel = this.rootItem.getHtml(level); if (htmlOneLevel != null && htmlOneLevel.length == 0) break; html += htmlOneLevel; } this.oDrawTarget.innerHTML = html; } function CMenu_getItemById(id) { return this.rootItem.getElementById(id); } function CMenu_onMouseOver(itemId) { var item = this.getItemById(itemId); if (item != null) { item.onMouseOver(); } } function CMenu_onMouseOut(itemId) { var item = this.getItemById(itemId); if (item != null) { item.onMouseOut(); } } function CMenu_onClick(itemId) { var item = this.getItemById(itemId); if (item != null) { item.onClick(); } } function CMenuItem(menu, oParent, id, name, action, arrItemData) { this.menu = menu; this.oParent = oParent; this.id = id; this.name = name; this.level = oParent != null ? oParent.level + 1 : 0; this.action = action; this.arrMenu = null; this.closeSubmenuTimer; this.toString = CMenuItem_toString; this.init = CMenuItem_init; this.getRoot = CMenuItem_getRoot; this.getHtml = CMenuItem_getHtml; this.getHtmlRootItem = CMenuItem_getHtmlRootItem; this.getHtmlTopItem = CMenuItem_getHtmlTopItem; this.getHtmlSubItem = CMenuItem_getHtmlSubItem; this.getElementById = CMenuItem_getElementById; this.selectItem = CMenuItem_selectItem; this.deselectItem = CMenuItem_deselectItem; this.showSubmenu = CMenuItem_showSubmenu; this.hideSubmenu = CMenuItem_hideSubmenu; this.hideSubmenuImmediate = CMenuItem_hideSubmenuImmediate; this.keepSubmenu = CMenuItem_keepSubmenu; this.getSubmenuTop = CMenuItem_getSubmenuTop; this.getSubmenuLeft = CMenuItem_getSubmenuLeft; this.onMouseOver = CMenuItem_onMouseOver; this.onMouseOut = CMenuItem_onMouseOut; this.onClick = CMenuItem_onClick; this.init(arrItemData); } function CMenuItem_toString() { return this.name; } function CMenuItem_init(arrItemData) { if (arrItemData != null) { this.arrMenu = new Array(); for(var i = 0; i < arrItemData.length; i++) { this.arrMenu[i] = new CMenuItem(this.menu, this, this.id + "_" + i, arrItemData[i][0], arrItemData[i][1], arrItemData[i][2]); } } } function CMenuItem_getRoot() { var oItem = this; while (oItem.oParent != null) { oItem = oItem.oParent; } return oItem; } function CMenuItem_getHtml(level) { if (this.level == 0) { return this.getHtmlRootItem(level); } else if (this.level == 1) { return this.getHtmlTopItem(level); } else { return this.getHtmlSubItem(level); } } function CMenuItem_getHtmlRootItem(level) { var html = ""; if (level == 1) { html += "<table border=0 cellspacing=0 cellpadding=0>"; if (this.menu.type == 0) { html += "<tr>"; } if (this.menu.topmenuBegin != null) { if (this.menu.type == 1) { html += "<tr>"; } html += "<td>" + this.menu.topmenuBegin + "</td>"; if (this.menu.type == 1) { html += "</tr>"; } } } if (this.arrMenu != null) { for (var i = 0; i < this.arrMenu.length; i++) { if (level == 1 && i != 0 && this.menu.topmenuSeparator != null) { if (this.menu.type == 1) { html += "<tr>"; } html += "<td>" + this.menu.topmenuSeparator + "</td>"; if (this.menu.type == 1) { html += "</tr>"; } } html += this.arrMenu[i].getHtml(level); } } else { if (level == 1) { if (this.menu.type == 1) { html += "<tr>"; } html += "<td>Menu is empty</td>"; if (this.menu.type == 1) { html += "</tr>"; } } } if (level == 1) { if (this.menu.topmenuEnd != null) { if (this.menu.type == 1) { html += "<tr>"; } html += "<td>" + this.menu.topmenuEnd + "</td>"; if (this.menu.type == 1) { html += "</tr>"; } } if (this.menu.type == 0) { html += "</tr>"; } html += "</table>" } return html; } function CMenuItem_getHtmlTopItem(level) { var html = ""; if (level == 1) { if (this.menu.type == 1) { html += "<tr>"; } html += "<td id=\"" + this.id + "\"" + " class=\"" + this.menu.id + "_TopItem\"" + " onMouseOver=\"" + this.menu.instanceVar + ".onMouseOver('" + this.id + "')\"" + " onMouseOut=\"" + this.menu.instanceVar + ".onMouseOut('" + this.id + "')\"" + " onClick=\"" + this.menu.instanceVar + ".onClick('" + this.id + "')\"" + ">&nbsp;" + this.name + "&nbsp;</td>"; if (this.menu.type == 1) { html += "</tr>"; } } else { if (this.arrMenu != null) { if (level == 2) { html += "<div id=\"" + this.id + "_Submenu\" " + "class=\"" + this.menu.id + "_Submenu\" " + "style=\"display: none; position: absolute; top: 0px; left: 0px;\">" + "<table border=0 cellspacing=0 cellpadding=0>"; } for (var i = 0; i < this.arrMenu.length; i++) { html += this.arrMenu[i].getHtml(level); } if (level == 2) { html += "</table></div>"; } } } return html; } function CMenuItem_getHtmlSubItem(level) { var html = ""; if (level == this.level) { html = "<tr>" + "<td id=\"" + this.id + "\" nowrap=true" + " class=\"" + this.menu.id + "_SubmenuItem\"" + " onMouseOver=\"" + this.menu.instanceVar + ".onMouseOver('" + this.id + "')\"" + " onMouseOut=\"" + this.menu.instanceVar + ".onMouseOut('" + this.id + "')\"" + " onClick=\"" + this.menu.instanceVar + ".onClick('" + this.id + "')\"" + ">" + this.name + "</td>" + "<td id=\"" + this.id + "_a\"" + " class=\"" + this.menu.id + "_SubmenuItem\"" + " onMouseOver=\"" + this.menu.instanceVar + ".onMouseOver('" + this.id + "')\"" + " onMouseOut=\"" + this.menu.instanceVar + ".onMouseOut('" + this.id + "')\"" + " onClick=\"" + this.menu.instanceVar + ".onClick('" + this.id + "')\"" + ">&nbsp;</td>" + "<td id=\"" + this.id + "_b\"" + " class=\"" + this.menu.id + "_SubmenuItem\"" + " onMouseOver=\"" + this.menu.instanceVar + ".onMouseOver('" + this.id + "')\"" + " onMouseOut=\"" + this.menu.instanceVar + ".onMouseOut('" + this.id + "')\"" + " onClick=\"" + this.menu.instanceVar + ".onClick('" + this.id + "')\"" + ">" + (this.arrMenu != null ? this.menu.submenuSign : "&nbsp;") + "</td>" + "</tr>"; } if (this.arrMenu != null) { if (level == this.level + 1) { html += "<div id=\"" + this.id + "_Submenu\" " + "class=\"" + this.menu.id + "_Submenu\" " + "style=\"display: none; position: absolute; top: 0px; left: 0px;\">" + "<table border=0 cellspacing=0 cellpadding=0>"; } for (var i = 0; i < this.arrMenu.length; i++) { html += this.arrMenu[i].getHtml(level); } if (level == this.level + 1) { html += "</table></div>"; } } return html; } function CMenuItem_getElementById(id) { var retVal = null; if (this.id == id) { retVal = this; } else if (this.arrMenu != null) { for (var i = 0; i < this.arrMenu.length; i++) { var oItem = this.arrMenu[i]; if (oItem.id == id) { retVal = oItem; break; } else { retVal = oItem.getElementById(id); if (retVal != null) break; } } } return retVal; } function CMenuItem_selectItem() { var itemClassName = this.level == 1 ? this.menu.id + "_TopItem_Selected" : this.menu.id + "_SubmenuItem_Selected"; var itemElement = document.getElementById(this.id); itemElement.className = itemClassName; if (this.level > 1) { var itemElementA = document.getElementById(this.id + "_a"); itemElementA.className = itemClassName; var itemElementB = document.getElementById(this.id + "_b"); itemElementB.className = itemClassName; } } function CMenuItem_deselectItem() { var itemClassName = this.level == 1 ? this.menu.id + "_TopItem" : this.menu.id + "_SubmenuItem"; var itemElement = document.getElementById(this.id); itemElement.className = itemClassName; if (this.level > 1) { var itemElementA = document.getElementById(this.id + "_a"); itemElementA.className = itemClassName; var itemElementB = document.getElementById(this.id + "_b"); itemElementB.className = itemClassName; } } function CMenuItem_showSubmenu() { this.keepSubmenu(); var submenu = document.getElementById(this.id + "_Submenu"); submenu.style.left = this.getSubmenuLeft() + "px"; submenu.style.top = this.getSubmenuTop() + "px"; submenu.style.display = ""; } function CMenuItem_hideSubmenu() { if (this.closeSubmenuTimer == null) { this.closeSubmenuTimer = setTimeout(this.menu.instanceVar + ".getItemById(\"" + this.id + "\").hideSubmenuImmediate()", 50); } if (this.level > 1) { this.oParent.hideSubmenu(); } } function CMenuItem_hideSubmenuImmediate() { var submenu = document.getElementById(this.id + "_Submenu"); submenu.style.display = "none"; this.closeSubmenuTimer = null; this.deselectItem(); } function CMenuItem_keepSubmenu() { this.selectItem(); if (this.closeSubmenuTimer != null) { clearTimeout(this.closeSubmenuTimer); this.closeSubmenuTimer = null; } if (this.level > 1) { this.oParent.keepSubmenu(); } } function CMenuItem_getSubmenuTop() { var top = 0; var element = document.getElementById(this.id); if (this.level == 1 && this.menu.type == 0) { top += element.offsetHeight; } while (element.offsetParent != null) { top += element.offsetTop; element = element.offsetParent; } return top; } function CMenuItem_getSubmenuLeft() { var left = 0; var element; if (this.level == 1) { element = document.getElementById(this.id); if (this.menu.type == 1) { left += element.offsetWidth; } } else if (this.level > 1) { element = document.getElementById(this.id + "_b"); left += element.offsetWidth; } while (element.offsetParent != null) { left += element.offsetLeft; element = element.offsetParent; } return left; } function CMenuItem_onMouseOver() { this.selectItem(); if (this.arrMenu != null) { this.showSubmenu(); } if (this.level > 1) { this.oParent.keepSubmenu(); } } function CMenuItem_onMouseOut() { this.deselectItem(); if (this.arrMenu != null) { this.hideSubmenu(); } if (this.level > 1) { this.oParent.hideSubmenu(); } } function CMenuItem_onClick() { eval(this.action); } 
// Menu 1 data
var menu1;

function createMenu1(sTopic) {

	if (sTopic == 1) sHomePrfx = '<span class=\'menu_on\'>';
		else sHomePrfx = '<span class=\'menu\'>';
	if (sTopic == 2) sProductsPrfx = '<span class=\'menu_on\'>';
		else sProductsPrfx = '<span class=\'menu\'>';
	if (sTopic == 3) sDownloadPrfx = '<span class=\'menu_on\'>';
		else sDownloadPrfx = '<span class=\'menu\'>';
	if (sTopic == 4) sPurchasePrfx = '<span class=\'menu_on\'>';
		else sPurchasePrfx = '<span class=\'menu\'>';
	if (sTopic == 5) sSupportPrfx = '<span class=\'menu_on\'>';
		else sSupportPrfx = '<span class=\'menu\'>';
	if (sTopic == 6) sContactPrfx = '<span class=\'menu_on\'>';
		else sContactPrfx = '<span class=\'menu\'>';
	if (sTopic == 7) sPartnersPrfx = '<span class=\'menu_on\'>';
		else sPartnersPrfx = '<span class=\'menu\'>';		

    menu1 = new CMenu("menu1", "idMenu1", "", "<img src='http://www.workexaminer.info/images/sep.gif' width='20' height='40' border='0'>", "<img src='http://www.workexaminer.info/images/sep.gif' width='20' height='40' border='0'>", "&gt;");

    menu1.init(
        [
            [sHomePrfx+"<b>Главная</b></span>", "window.location.href='http://www.workexaminer.info/index.html'", null],

            [sProductsPrfx+"<b>Продукты</b></span>", "window.location.href='http://www.workexaminer.info/products.html'",
                [
                    ["Work Examiner Standard", "window.location.href='http://www.workexaminer.info/overview_std.html'", null],
					["Work Examiner Professional", "window.location.href='http://www.workexaminer.info/overview_pro.html'", null]
                ]
            ],

            [sDownloadPrfx+"<b>Загрузка</b></span>", "window.location.href='http://www.workexaminer.info/download.html'", null],

            [sPurchasePrfx+"<b>Купить</b></span>", "window.location.href='http://www.workexaminer.info/order.html'", null],
            
            [sSupportPrfx+"<b>Поддержка</b></span>", "window.location.href='http://www.workexaminer.info/support.html'",
                [
                    ["Обратная связь", "window.location.href='http://www.workexaminer.info/feedback.html'", null]
                ]
            ],
            
            [sContactPrfx+"<b>О нас</b></span>", "window.location.href='http://www.workexaminer.info/contact.html'",
                [
                    ["Контакты", "window.location.href='http://www.workexaminer.info/contact.html'", null],
                    ["Отзывы", "window.location.href='http://www.workexaminer.info/testimonials.html'", null]
                ]				
			]						
        ]);
}
