var xmlMenu;var activeTopItem = 0;var activeBottomItem = 0;var currentLink = "";function loadXMLDoc(xmlMenuFile) {    if (document.implementation && document.implementation.createDocument) {        // this is the W3C DOM way, supported so far only in NN6        xmlMenu = document.implementation.createDocument("", "thexmlMenu", null);    } else if (typeof ActiveXObject != "undefined") {        // make sure real object is supported (sorry, IE5/Mac)        if (document.getElementById("msxml").async) {            xmlMenu = new ActiveXObject("Msxml.DOMDocument");        }    }    if (xmlMenu && typeof xmlMenu.load != "undefined") {        // Netscape 6+ needs this delay for loading; start two-stage sequence        setTimeout("continueLoad('" + xmlMenuFile + "')", 50);    } else {/*        var reply = confirm("This page requires a browser with XML support. Sorry.");        if (reply) {            history.back();*/        }    }}function continueLoad(xmlMenuFile) {    xmlMenu.load(escape(xmlMenuFile));    // IE needs this delay to let loading complete before reading its content    setTimeout("finishInit()", 200);}function getTopMenu(){    var topMenuItemsQ = xmlMenu.getElementsByTagName("topMenu").length;    if (activeTopItem > (topMenuItemsQ - 1)) activeTopItem = 0;    var menuHTMLstring = "<table border='0' align='left' cellpadding='0' cellspacing='0' summary='header' bgcolor='#336699' width='100%'><tr height='23'>";    //Сборка верхней менюшки    for(i = 0; i < topMenuItemsQ; i++)    {        //прорисовка левого края        if (i==0)        {            if (i==activeTopItem)            {                menuHTMLstring = menuHTMLstring + "<td width='23' class='topmenuLeftEndActive'>&nbsp;</td>";            }            else            {                menuHTMLstring = menuHTMLstring + "<td width='23' class='topmenuLeftEndNotActive'>&nbsp;</td>";            }        }                //прорисовка середины        if (i==activeTopItem)         {            menuHTMLstring = menuHTMLstring + "<td width='70' class='topmenuActive'>";            currentLink = xmlMenu.getElementsByTagName("topMenu")[i].getAttribute("link");        }        else        {            menuHTMLstring = menuHTMLstring + "<td width='70' class='topmenuNotActive'>";        }        menuHTMLstring = menuHTMLstring + "<a class='whiteLink' href='" + xmlMenu.getElementsByTagName("topMenu")[i].getAttribute("link") + "'>" + xmlMenu.getElementsByTagName("topMenu")[i].getAttribute("text") + "</a></td>";                //прорисовка правого края        if (i==(topMenuItemsQ - 1))        {            if (i==activeTopItem)            {                menuHTMLstring = menuHTMLstring + "<td width='23' class='topmenuRightEndActive'>&nbsp;</td>";            }            else            {                menuHTMLstring = menuHTMLstring + "<td width='23' class='topmenuRightEndNotActive'>&nbsp;</td>";            }        }        else        {            if (i == activeTopItem)            {                menuHTMLstring = menuHTMLstring + "<td width='23' class='topmenuRightActive'>&nbsp;</td>";            }            if (i == (activeTopItem - 1))            {                menuHTMLstring = menuHTMLstring + "<td width='23' class='topmenuRightNotActive'>&nbsp;</td>";            }            if ((i != activeTopItem) && (i != (activeTopItem - 1)))            {                menuHTMLstring = menuHTMLstring + "<td width='23' class='topmenuRightNotActive2NotActive'>&nbsp;</td>";            }        }    }    menuHTMLstring = menuHTMLstring + "<td class='topmenuRight' align='right'>";    //menuHTMLstring = menuHTMLstring + "<a href='en_" + currentLink.slice(3,currentLink.length) + "'><img src='imgs/gbrFlagSmall.png' border='0' />&nbsp;english</a>&nbsp;&nbsp;";
    //menuHTMLstring = menuHTMLstring + "<a href='ru_" + currentLink.slice(3,currentLink.length) + "'><img src='imgs/ruFlagSmall.png' border='0' />&nbsp;русский</a>&nbsp;";    menuHTMLstring = menuHTMLstring + "&nbsp;</td>";    menuHTMLstring = menuHTMLstring + "</tr></table>";    return menuHTMLstring;}function getBottomMenu(){    var rootItem = xmlMenu.getElementsByTagName("topMenu")[activeTopItem];    var subItemsLen = rootItem.getElementsByTagName("bottomMenu").length;    var menuHTMLstring = "<table border='0' cellpadding='0' cellspacing='0'>";    if (subItemsLen > 0)    {        menuHTMLstring += "<tr height='32'><td class='bottMenuBG' width='30'>&nbsp;</td>";        for(i=0; i<subItemsLen; i++)        {            if (i == activeBottomItem)             {                menuHTMLstring += "<td class='bottMenuActBG'>&nbsp;&nbsp;";            }            else            {                menuHTMLstring += "<td class='bottMenuNActBG'>&nbsp;&nbsp;";            }            menuHTMLstring += "<a class='linkOrange' href='" + rootItem.getElementsByTagName("bottomMenu")[i].getAttribute("link") + "'>" + rootItem.getElementsByTagName("bottomMenu")[i].getAttribute("text") + "</a>&nbsp;&nbsp;</td>";            menuHTMLstring += "<td class='bottMenuBG'>&nbsp;<td>";        }                menuHTMLstring += "</tr>";    }    else    {        menuHTMLstring += "<tr height='32'><td class='bottMenuBG' width='100%'>&nbsp;</td></tr>";    }    menuHTMLstring += "</table>";    return menuHTMLstring;}function getHeader(){    var headerString = "<table border='0' align='left' cellpadding='0' cellspacing='0' summary='header' bgcolor='#336699' width='100%'>";    headerString += "<tr height='92'><td align='left' class='header_" + xmlMenu.getElementsByTagName("header")[0].getAttribute("lang") + "' width='457px'>&nbsp;</td>";
    headerString += "<td align='left' class='headerBGEmpty'>&nbsp;</td></tr></table>"    return headerString;}function finishInit() {        var topMenu = getTopMenu();        var bottomMenu = getBottomMenu();        var header = getHeader();        document.getElementById("header").innerHTML = header;        document.getElementById("topMenu").innerHTML = topMenu;        document.getElementById("bottomMenu").innerHTML = bottomMenu;}// initialize first time -- invoked onloadfunction initXML(xmlMenuFile) {    loadXMLDoc(xmlMenuFile);}
