//<Script Language="JavaScript">

var mstatus=true; 
var timer1=false; 
var mstep=4;
var cm=null;
var hide_delay=6;
var tstat=0;
isNS4 = (document.layers) ? true : false;
isIE4 = (document.all && !document.getElementById) ? true : false;
isIE5 = (document.all && document.getElementById) ? true : false;
isNS6 = (!document.all && document.getElementById) ? true : false;

function switchDiv(objElement,bolVisible){
   if(isNS4||isIE4){
        if(!bolVisible) {
            objElement.visibility ="hidden"
        } else {
            objElement.visibility ="visible"
        }     
    } else if (isIE5 || isNS6) {
          if(!bolVisible){
               objElement.style.display = "none";        
          } else {
               objElement.style.display = "";       
          }
    }
    return 1;
}

function getPos(el,sProp) {
   var iPos = 0;
   while (el!=null) {
         iPos+=el["offset" + sProp]
         el = el.offsetParent
   }
   return iPos
}


function getelementbyid(myid) {
   if (isNS4){
        objElement = document.layers[myid];
     }else if (isIE4) {
        objElement = document.all[myid];
     }else if (isIE5 || isNS6) {
             objElement = document.getElementById(myid);
     }
return(objElement);
}


function show(el, m) {
//        if (cm==null) { alert('cm!=0');} else  {alert('cm==0');}
        if (m!=null) { m=getelementbyid(m); }
        if ((el==null)  && (cm)) {
            mstatus=false;
            movefx();
//        } else if ((m!=cm) && (m)) {
        } else if ((m!=cm) && (m)) {
            if (cm!=null) switchDiv(cm,false);
            switchDiv(m,true); // сделать видимым  слой m
            fxel=el;             
            fxm=m;
            fxrect=0; 
            mstatus=true; 
            movefx();
  	}       
        if (m) cm=m;
        if (tstat==1) {
            clearTimeout(timer1);
            tstat=0
        }
}

function showUP(Base, SubMenu) {
        if (SubMenu!=null) { SubMenu=getelementbyid(SubMenu); }
        if ((Base==null)  && (cm)) {
            mstatus=false;
            moveUP();
        } else if ((SubMenu!=cm) && (SubMenu)) {
            if (cm!=null) switchDiv(cm,false);
            switchDiv(SubMenu,true); // сделать видимым  слой m
            tmpBase=Base;             
            tmpSub=SubMenu;
            fxrect=0; 
            mstatus=true; 
            moveUP();
  	}       
        if (SubMenu) cm=SubMenu;
        if (tstat==1) {
            clearTimeout(timer1);
            tstat=0
        }
}


function hidemenu(b) {
// aletr('b=');    document.images[3].scr="/img/banner-02.gif";
 if (b)  {
    tstat=1;
    timer1=setTimeout("show(null)",hide_delay);
 } else {
    tstat=0;
    show(null);
 }
}


function hidemenuUP(b) {
 if (b)  {
    tstat=1;
    timer1=setTimeout("showUP(null)",hide_delay);
 } else {
    tstat=0;
    showUP(null);
 }
}


function cancelhide() {
   if (!mstatus) { mstatus=1; }
   tstat=0;
   clearTimeout(timer1);
}

function movefx() {
    if ((mstatus) && (fxrect>fxm.offsetHeight)) {
        fxrect=fxm.offsetHeight;
        return 1;
     } 
     if ((!mstatus) && (fxrect<0)) {
         fxrect=0;
         switchDiv(fxm,false);
         mstatus=true;
         cm=null;
         return 1;
     } 
     if ((isIE5)||(isIE4)||(isNS4)||(isNS6)) {
         if (!isNS4) {
              fxm.style.left = getPos(fxel,"Left")+"px"; 
              fxm.style.clip='rect(' + (fxm.offsetHeight-fxrect) + ' '+ fxm.offsetWidth + ' ' + fxm.offsetHeight +' '+ 0 +')';
              fxm.style.top = getPos(fxel,"Top")+(fxel.offsetHeight-fxm.offsetHeight+fxrect+3)+"px"; 
         } else {
              fxm.left=getPos(fxel,"Left");
              fxm.clip.top=fxm.offsetHeight-fxrect;
              fxm.clip.bottom=fxm.offsetHeight;
              fxm.clip.left=0;
              fxm.clip.right=fxm.offsetWidth;
              fxm.top=getPos(fxel,"Top")+(fxel.offsetHeight-fxm.offsetHeight+fxrect+2); 
         }
         if (mstatus) {
              fxrect=fxrect+mstep;
              setTimeout('movefx()',1);
         } else {
              fxrect=fxrect-mstep;
              setTimeout('movefx()',1);
         }
         return 1; 
     } else {
         if (mstatus) {
             fxm.style.left =getPos(fxel,"Left")+"px";
             fxm.style.top = (getPos(fxel,"Top")+ fxel.offsetHeight) +"px";
         } else {
             switchDiv(fxm,false);
             cm=null;
             mstatus=true;
         }
         return 1 
     }
}


function moveUP() {
    if ((mstatus) && (fxrect>tmpSub.offsetHeight)) {
        fxrect=tmpSub.offsetHeight;
        return 1;
     } 
     if ((!mstatus) && (fxrect<0)) {
         fxrect=0;
         switchDiv(tmpSub,false);
         mstatus=true;
         cm=null;
         return 1;
     } 
     if ((isIE5)||(isIE4)||(isNS4)||(isNS6)) {
         if (!isNS4) {
              tmpSub.style.left = getPos(tmpBase,"Left")+"px"; 
              tmpSub.style.clip='rect(' + 0 + ' '+ tmpSub.offsetWidth + ' ' + fxrect +' '+ 0 +')';
//              tmpSub.style.clip='rect(' + (tmpSub.offsetHeight-fxrect) + ' '+ tmpSub.offsetWidth + ' ' + tmpSub.offsetHeight +' '+ 0 +')';
              tmpSub.style.top = getPos(tmpBase,"Top")-(fxrect+3)+"px"; 
         } else {
              alert ('fffdf');
              tmpSub.left=getPos(tmpBase,"Left");
              tmpSub.clip.top=tmpSub.offsetHeight-fxrect;
              tmpSub.clip.bottom=tmpSub.offsetHeight;
              tmpSub.clip.left=0;
              tmpSub.clip.right=tmpSub.offsetWidth;
              tmpSub.top=getPos(tmpBase,"Top")+(tmpBase.offsetHeight-tmpSub.offsetHeight+fxrect+2); 
         }
         if (mstatus) {
              fxrect=fxrect+mstep;
              setTimeout('moveUP()',1);
 
         } else {
              fxrect=fxrect-mstep;
              setTimeout('moveUP()',1);
         }         
         return 1; 
     } else { 
         alert ('newnewnew');
         if (mstatus) {
             tmpSub.style.left =getPos(tmpBase,"Left")+"px";
             tmpSub.style.top = (getPos(tmpBase,"Top") + tmpBase.offsetHeight) +"px";
         } else {
             switchDiv(tmpSub,false);
             cm=null;
             mstatus=true;
         }
         return 1 
   }
              alert ('newnewnew');

}

//</Script>
