var select_obj; function layerMenu(user_id, status){ var obj=document.all[user_id]; var _tmpx,_tmpy, marginx, marginy; _tmpx = event.clientX + parseInt(obj.offsetWidth); _tmpy = event.clientY + parseInt(obj.offsetHeight); _marginx = document.body.clientWidth - _tmpx; _marginy = document.body.clientHeight - _tmpy ; obj.style.posLeft = event.clientX; obj.style.posTop = event.clientY; if(status=='visible') { if(select_obj) { select_obj.style.visibility='hidden'; select_obj=null; } select_obj=obj; }else{ select_obj=null; } obj.style.visibility=status; }