// div menu 3 lvls
cm=null;
cm2=null;
hide_delay=0;
tstat1=0;
tstat2=0;

timer1=0;
timer2=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
	}

	if( sProp == 'Left' )
	  iPos += 5;

	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 show1(el,m) {

  if (cm!=null) {
    switchDiv(cm,false);
  }

  if( cm2 != null ) {
    switchDiv( cm2,false );
  }

  if( m!=null ) {
    m=getelementbyid(m);

//    el.className = "itemL1 activeL1";
    m.style.left = ( el.offsetWidth + getPos(el,"Left") - 4 ) + "px";
    m.style.top =  ( getPos(el,"Top") - 2 ) + "px";
    switchDiv(m,true);
    cm=m;
  }
}

function show2( el, m ) {

  if( cm2 != null ) {
    switchDiv( cm2,false );
  }

  if( m != null ){
    m = getelementbyid( m );
//    m.style.left = ( el.offsetWidth + getPos(el,"Left") ) + "px";
    m.style.left = ( 198 + getPos(el,"Left") ) + "px";
    m.style.top =  getPos(el,"Top")+"px";
    switchDiv(m,true);
    cm2 = m;
  }
}

function hidemenu( lvl, el ) {

  if( typeof( el ) != 'undefined' ) {
    el = getelementbyid( el );
    el.className = "itemL1";
  }

  timer1=setTimeout("show1(null,null)",hide_delay);
  tstat1 = 1;

  if( lvl == 2  && typeof( lvl ) != 'undefined' ) {
    timer2 = setTimeout("show2(null,null)",hide_delay);
    tstat2 = 1;
  }

  return 1;
}

function cancelhide( lvl, el ) {
  clearTimeout( timer1 );
  tstat1 = 0;

  if( typeof( el ) != 'undefined' ) {
    el = getelementbyid( el );
    el.className = "itemL1 activeL1";
  }

  if ( lvl == 2 && typeof( lvl ) != 'undefined' ) {
    clearTimeout( timer2 );
    tstat2 = 0;
  }

  return 1;
}