var oo4=false;
var ie4=false;
var nn4=false;

if (document.getElementById) { 
  oo4=true;
} else if (document.layers) { 
  nn4=true;
} else if (document.all) { 
  ie4=true;
} 


function moveTo(ident,xx) {
  if(oo4) {
    document.getElementById(ident).style.left = ''+xx+'px';
  } else if(nn4) {
    document.layers[ident].left = xx;
  } else if(ie4) {
    document.all[ident].style.left = xx;
  }

}

function init() {
  if(!oo4 && !nn4 && !ie4) {return;}
  document.onclick = mouseClick;

  if(nn4) {
  document.captureEvents(Event.MOUSECLICK);
  }
  if(oo4) {
    pozycja=(document.body.clientWidth/2)-360;
  } else if(nn4) {
    pozycja=(window.innerWidth/2)-360;
  } else if(ie4) {
    pozycja=(document.body.clientWidth/2)-360;
  }

  if (pozycja<30){pozycja=30;}
  moveTo("menuDiv1",parseInt(pozycja));
  moveTo("menuDiv2",parseInt(pozycja+62));
  moveTo("menuDiv3",parseInt(pozycja+148));
  moveTo("menuDiv4",parseInt(pozycja+210));
}

function mouseClick(e) {
  if(oo4) {
    zwin();
  } else if(nn4) {
    zwin();
  } else if(ie4) {
    if(event.srcElement.parentElement != document.all['belkaDiv']) {
      zwin();
    }
  }
  return true;
}


function zwin() {
    hideLayers('menuDiv1');
    hideLayers('menuDiv2');
    hideLayers('menuDiv3');
    hideLayers('menuDiv4');
}


function hideLayers(menuName) {
  if(oo4) {
    document.getElementById(menuName).style.visibility = "hidden";
  } else if (nn4) {
    document.layers[menuName].visibility = "hide";
  } else {
    document.all[menuName].style.visibility = "hidden";
  }
}

function popUp(menuName,on) {
    if(oo4) {
      if (document.getElementById(menuName)) {ok = true;}
      else {ok = false;}
    } else if (nn4) {
      if (document.layers['menuDiv4']) {ok = true;}
      else {ok = false;}
    } else {
      if (document.all['menuDiv4']) {ok = true;}
      else {ok = false;}
    }

    if (ok){
      hideLayers('menuDiv1');
      hideLayers('menuDiv2');
      hideLayers('menuDiv3');
      hideLayers('menuDiv4');
      if (on) {
        if (oo4) {
          document.getElementById(menuName).style.visibility = "visible";
        } else if (nn4) {
          document.layers[menuName].visibility = "show";
        } else {
          document.all[menuName].style.visibility = "visible";
        }
      } else {
        if (oo4) {
          document.getElementById(menuName).style.visiblity="hidden";
        } else if (nn4) {
          document.layers[menuName].visibility = "hide";
        } else {
          document.all[menuName].style.visibility = "hidden";
        }
      }
    }
}

init();
//window.onload=init();
