////////////////////Please leave this notice////////////////////
//
//      DropDown Menu 1.0
//      By Evgeny Novikov (java@aladin.ru)
//      http://java.skyteam.ru
//      It works only with IE5.0(++) and Netscape6.0(++)
//      Free to use!
//
////////////////////Last modified 2002-03-10////////////////////

//      Modify following four lines to customize your menu
var tdColor="#000000";          // menu item text color
var tdBgColor="#EDEDED";        // menu item background color
var hlColor="#000000";          // highlight text color
var hlBgColor="#cccccc";        // highlight background color

//      After change, modify same values in your *.css file

//----------------------------------------------

///---------------------------------------------


var WidthMainMenu=142; //ширина таблицы главной меню

var menuLeft=1//Положение меню по X
var menuTop=1//Положение меню по y

menuLeft=( document.body.clientWidth / 2 ) - 450;



switch (window.screen.height)
{
case 768 :
	menuTop=305;
	break;

case 1024 : 
	menuTop=295;
	break;

default : 
	menuTop=285;
	break;
}









var cellpChildleft=115//Отступ подменю от меню главного left
var cellpChildtop=2//Отступ подменю от меню главного top

var md=50;
var ti=-1;
var oTd=new Object;
oTd=null;

function doMenu(td,nametd){
        clearTimeout(ti);
        td.style.backgroundColor=hlBgColor;
        td.style.color=hlColor;
        var i;
        var sT="";
        var tda=new Array();
        tda=td.id.split("_");
        if(oTd!=null){
                var tdo=new Array();
                tdo=oTd.id.split("_");
                for(i=1;i<tdo.length;i++){
                        sT+="_"+tdo[i];
                        if(tdo[i]!=tda[i]){
                                document.getElementById("td"+nametd+sT).style.backgroundColor=tdBgColor;
                                document.getElementById("td"+nametd+sT).style.color=tdColor;
                                if(document.getElementById("tbl"+nametd+sT)!=null)
                                        document.getElementById("tbl"+nametd+sT).style.visibility="hidden";
                        }
                }                       
        }
        oTd=td;
        sT="tbl"+nametd;
        for(i=1;i<tda.length;i++)
                sT+="_"+tda[i];
        if(document.getElementById(sT)!=null)
                document.getElementById(sT).style.visibility="visible";

}

function clearMenu(nametd){
        if(oTd!=null){
                var tdo=new Array();
                tdo=oTd.id.split("_");
                var sT="";
                for(var i=1;i<tdo.length;i++){
                        sT+="_"+tdo[i];
                        document.getElementById("td"+nametd+sT).style.backgroundColor=tdBgColor;
                        document.getElementById("td"+nametd+sT).style.color=tdColor;
                        if(document.getElementById("tbl"+nametd+sT)!=null)
                                document.getElementById("tbl"+nametd+sT).style.visibility="hidden";
                }
                oTd=null;                       
        }
}

function runMenu(strURL){

        location.href=strURL;
}

var tt="";
var sT="";
var pT=new Array();
var tA=new Array();

function getCoord(st,nametd){
        tA=st.split("_");

        if(tA.length>2)
        {
                tA=tA.slice(0,-1);
                tt=tA.join("_");
                return (document.getElementById('tbl'+nametd+tt).offsetTop+document.getElementById('td'+nametd+st).offsetTop+4)+"px;left:"+
                        (document.getElementById("tbl"+nametd+tt).offsetLeft+document.getElementById("td"+nametd+st).offsetWidth-2)+"px\">";
        }

        a=document.all["mainmenu"+nametd];
        a.style.pixelLeft=menuLeft;
        a.style.pixelTop=menuTop;

        return (document.getElementById("mainmenu"+nametd).offsetTop+document.getElementById("td"+nametd+st).offsetTop+document.getElementById("td"+nametd+st).offsetHeight-15)+"px;left:"+
                  (document.getElementById("mainmenu"+nametd).offsetLeft+document.getElementById("td"+nametd+st).offsetLeft+5+cellpChildleft)+"px\">";

}

function CreateMenu(nametd,vis_hid)
{
 if(document.getElementById)
   {
        var sH="<table width="+WidthMainMenu+" class=\"menujs\" id=\"mainmenu"+nametd+"\" cellspacing=\"0\"  border: 0 style=\"top:"+menuTop+"px;left:"+menuLeft+"px;\">";
        var p=0;
        var j=0;
        while(eval("typeof(td"+nametd+"_"+ ++j +")!=\"undefined\""))
         {
                sH+="<tr><td width=15 align=left valign=top><img src=\"images/square.gif\" align=left valign=top ></td><td id=\"td"+nametd+"_"+j+"\" onmouseover=\"doMenu(this,"+nametd+")\" onmouseout=\"ti=setTimeout('clearMenu("+nametd+")',md)\" ";
                sH+=(eval("typeof(url"+nametd+"_"+j+")!=\"undefined\""))?" onclick=\"runMenu('"+eval("url"+nametd+"_"+j)+"')\">":">";
                sH+=eval("td"+nametd+"_"+j)+"</td></tr>";
                if (eval("typeof(td"+nametd+"_"+j+"_1)!=\"undefined\""))
                        pT[p++]="_"+j;
         } // while
   sH+="</table>";
   document.write(sH);

   for(var q=0;typeof(pT[q])!="undefined";q++){
        sT=pT[q];
        sH="";
        j=0;
        sH+="<table  class=\"menujs\" id=\"tbl"+nametd+sT+"\" cellspacing=\"0\" style=\"       border: 1px solid black;top:"+getCoord(sT, nametd);
        while (eval("typeof(td"+nametd+sT+"_"+ ++j +")!=\"undefined\"")){

                sH+="<tr ><td id=\"td"+nametd+""+sT+"_"+j+"\" onmouseover=\"doMenu(this,"+nametd+")\" onmouseout=\"ti=setTimeout('clearMenu("+nametd+")',md)\"";
                sH+=(eval("typeof(url"+nametd+sT+"_"+j+")!=\"undefined\""))?" onclick=\"runMenu('"+eval("url"+nametd+sT+"_"+j)+"')\">":">";
                sH+=eval("td"+nametd+sT+"_"+j)+"</td></tr>";
                if (eval("typeof(td"+nametd+sT+"_"+j+"_1)!=\"undefined\""))
                        pT[p++]=sT+"_"+j;
        } // while
        sH+="</table>";
        document.write(sH);
   } //for
 if (vis_hid=='v')
    document.getElementById("mainmenu"+nametd).style.visibility="visible";
  }
  else
     document.write("<p>This page uses DHTML and DOM, but your browser doesn't support them.</p>");
}

  CreateMenu(171,'v');
  var menuTop=document.getElementById("mainmenu171").offsetTop+document.getElementById("mainmenu171").offsetHeight+95;      
  CreateMenu(1,'v');
