mstatus=true;
timer1=false;
mstep=100;
cm=null;
hide_delay=200;
tstat=0;
clsname=null;
td=null;
//clsname=null;

// Функция отображающая и скрывающая слои

// Вход:
// objElement - идентификатор(id) слоя;
// bolVisible - булева переменная:
// true  - отобразить слой;
// false - скрыть слой.

// Выход:
// 1


// P.S: В зависимости от типа браузера
// сценарий для манипуляции с видимостью слоёв
// несколько различается.

function switchDiv(objElement,bolVisible,el,bolEmpty){

if(isNS4||isIE4){
     if(!bolVisible) {
       objElement.visibility ="hidden";
       el.style.color = "#000000";
       el.style.cursor = "hand";
     } else {
       if (!bolEmpty) objElement.visibility ="hidden";
       else  objElement.visibility ="visible";
       el.style.color = "#cc0000";
       el.style.cursor = "hand";
     }     
} else if (isIE5/* || isNS6*/) {
      if(!bolVisible){
         objElement.style.visibility = "hidden";
         el.style.color = "#000000";
         el.style.cursor = "hand";
      } else {
        if (!bolEmpty) objElement.style.visibility = "hidden";
        else objElement.style.visibility = "visible";
        el.style.color = "#cc0000";
        el.style.cursor = "hand";
        }
}
else {
      if(!bolVisible){
         objElement.style.visibility = "hidden";
         el.style.color = "#000000";
         el.style.cursor = "pointer";
      } else {
        if (!bolEmpty) objElement.style.visibility = "hidden";
        else objElement.style.visibility = "visible";
        el.style.color = "#cc0000";
        el.style.cursor = "pointer";
        }
}

return 1;
}


      
// Функция возвращающая значение указанного ей 
// свойства объекта (не обязательно слоя).

// Вход:
// el    - идентификатор элемента;
// sProp - свойство (left,top...)

// Выход:
// Значение какого-нибудь свойства объекта.



function getPos(el,sProp) {
	var iPos = 0;
	while (el!=null) {
		iPos+=el["offset" + sProp]
		el = el.offsetParent
	}
	return iPos

}


// Функция отображающая|скрывающая

// Вход:
// el - яйчейка таблицы на которой 
// находится указатель;
// m  - наименование слоя, который надо
// отобразить под этой яйчейкой.

function show(el,m) {

if (m!=null) {
m=getelementbyid(m);
}

if (el!=null) clsname=el.className;

// получаем элемент в m


        if ((el==null) && (cm)) {
        mstatus=false;
        movefx();
// закрываем меню через movefx
          
        } else if ((m!=cm) && (m)) {
        if (cm!=null) {
          switchDiv(cm,false,cel,false);
        }
// пользователь перешёл на другой пункт основного меню
// немедлено сделать невидимым предыдущий (cm) видимый в данный момент слой.  
        if (m.innerHTML)
          switchDiv(m,true,el,true); // сделать видимым  слой m
        else
          switchDiv(m,true,el,false);
        fxel=el;             
        fxm=m;
        fxrect=0; // текущая высота области отсечения (см. ниже)

        // запоминаем значения в глобальных переменных
        // для использования в дальнейшем

        mstatus=true; // будем открывать меню с помощью movefx
        movefx();
	     }
        
        if (m) { cm=m; cel=el } 
        // запоминаем значение m в cm, el в cel (cm, cel - предыдущие значения) 

  if (tstat==1) {
  clearTimeout(timer1);
  tstat=0;
// если таймер timer1 запущен, останавливаем его
  }
 
}


// Функция "закрывающая" меню.

// Функция ничего не принимает на вход
// и возвращает 1.

function hidemenu(b) {
 if (b)  {
 tstat=1;
 if (!cm.innerHTML) switchDiv(cm,false,cel,false);
 timer1=setTimeout("show(null)",hide_delay);
 } else {
 tstat=0;
 show(null);
 }

}

// Функция останавливающая таймер запущенный
// прошлой функцией. Таким образом,
// меню не пропадает.

// Функция ничего не принимает на вход
// и возвращает 1.

function cancelhide() {

if (!mstatus) {
mstatus=1;
//cm=fxm;
}
 
tstat=0;
clearTimeout(timer1);
 

}




function movefx() {


if ((mstatus) && (fxrect>100)) {
fxrect=100;
return 1;
} 



if ((!mstatus) && (fxrect<0)) {
fxrect=0;
switchDiv(fxm,false,fxel);
mstatus=true;
cm=null;
return 1;
}

var bodydiv = getelementbyid('bodydiv');

if ((isIE5)||(isIE4)||(isNS6)) {
 fxm.style.top=getPos(fxel,"Top")+(fxel.offsetHeight)+/*(fxel.offsetTop)+*/'px';
 if ((getPos(bodydiv,"Left")+bodydiv.offsetWidth) < (getPos(fxel,"Left")+200)) min = fxel.offsetWidth - 200;
 else min = 0;
 fxm.style.left=getPos(fxel,"Left")+min+'px';
 if (isNS6) {
 fxm.style.MozOpacity = fxrect/100;
 } else {
 fxm.style.filter = 'alpha(opacity='+fxrect+')';
 }

  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,fxel);
  cm=null;
  mstatus=true;
  }
return 1 
}


}

