//блоки и порядок их размещения
blocks=new Array('news','director','ban1');
//высота каждого соответсвующего блока
blocksh=new Array(277,330,180);
//начиная со второго параметра нужно передавать id пункта меню
p=new Array(0,0);
// выделенный подпункт меню
pu=0;
//-----------------------------------------------
smtop=new Array();
mv=new Array(0,"visible","hidden","hidden","hidden","visible","visible","visible","visible","visible");
mh=new Array(0,140,39,39,74,39,330,270,39,103);
mh1=new Array(0,180,0,0,0,46,83,83,57,77);
ph=new Array(0,39,39,39,39,39,39,39,39,39);

pp=p[1]*10+pu;
menuactive='y'+p[1];
openedmenuheight=ph[1];

function l(){
if(p[1]>0){
document.getElementById('y'+p[1]).style.borderLeft="6px solid #790000";
document.getElementById('y'+p[1]).style.paddingLeft="19px";
if(pu>0){
document.getElementById('p'+pp).style.backgroundImage="url(images/mnuara.gif)";
}}
openedmenuheight1=0;
if(pu>0){
for(i=1;i<p.length;i++){
document.getElementById('y'+p[i]).style.height=mh[p[i]];
document.getElementById('y'+p[i]+'s').style.visibility=mv[p[i]];
openedmenuheight1+=mh[p[i]]-ph[p[i]];
}}

//расстановка блоков
for (jj=0;jj<3;jj++){
if(document.getElementById(blocks[jj])){
document.getElementById(blocks[jj]).style.top=(523+openedmenuheight1)+"px";
openedmenuheight1+=blocksh[jj];
}}
document.getElementById('info').style.height=(550+openedmenuheight1)+"px";

for (i=1;i<ph.length;i++){
id="y"+i+"s";
openedmenuheight=0;
for(j=1;j<p.length;j++){
if(p[j]<i){
openedmenuheight+=mh1[p[j]];
}}
for(j=1;j<i;j++){openedmenuheight+=ph[i];}
if(i>4){openedmenuheight+=20;}
document.getElementById(id).style.top=(170+openedmenuheight)+"px";
smtop[i]=170+openedmenuheight;
}
}


function ac(id,pa) {
id1="y"+id;
if (id1!=menuactive) {
document.getElementById(id1).style.borderLeft="6px solid #790000";
document.getElementById(id1).style.paddingLeft="19px";}
if(pa>0){
k=false;
for(i=1;i<=p.length;i++){
if(id==p[i]){k=true;}
}
if(!k){for(i=1;i<=p.length;i++){if(p[i]>id){if(pu>0){document.getElementById("y"+p[i]+"s").style.top=smtop[p[i]]+mh[id]-ph[p[i]];}}}
document.getElementById(id1).style.height=mh[id];
document.getElementById(id1+"s").style.visibility="visible";
}}}

function aco(id,pa) {
id1="y"+id;
if (id1!=menuactive) {
document.getElementById(id1).style.borderLeft="none";
document.getElementById(id1).style.paddingLeft="25px";}
if(pa>0){k=false;for(i=1;i<=p.length;i++){if(id==p[i]){k=true;}}
if(!k){for(i=1;i<=p.length;i++){if(p[i]>id){document.getElementById("y"+p[i]+"s").style.top=smtop[p[i]];}}
document.getElementById(id1).style.height=ph[id];
document.getElementById(id1+"s").style.visibility="hidden";
}}}

