total_punkt=4;
arr=new Array(total_punkt);
speed=5;
var timerId;

function InitMenu(){
  var x=0;
  var y=0; 

  var obj=document.getElementById('ankor'); 
  while(obj){ 
     var d=obj.tagName; 
     y+=parseInt(obj.offsetTop);   
     x+=parseInt(obj.offsetLeft); 
     obj=obj.offsetParent;    
  }
  panel=document.getElementById('panel1');
  panel.style.display='block'; 
  panel.style.top=-2;
  panel.style.left=x; 
  
  for (i=1; i<=total_punkt; i++){
    obj_p=document.getElementById('punkt'+i);
	obj_s=document.getElementById('submenu'+i);  
	obj_p.style.display='block';
	obj_s.style.display='block';	
	
 	hp=obj_p.offsetHeight;
    hs=obj_s.offsetHeight;	
	
    obj_p.style.top=y;
    dy=hs-hp;
    obj_s.style.top=y-dy;
	obj_p.style.left=x;
	obj_s.style.left=x+6;
	x=x+obj_p.offsetWidth;
	

/*	cl=hs;	
	str_cl='rect('+cl+' 100% 100% 0)';
	obj_s.style.clip=str_cl;*/
	
    arr[i-1]=0;
  }	
  
  if (timerId!=undefined) clearInterval(timerId);
  timerId=setInterval('timer()',10);  
}//InitMenu

function menu(name){
  ev=name.substring(0,name.length-1);
  el=name.substring(name.length-1,name.length);  
  if (ev=='sh'){
    for (i=1; i<=total_punkt; i++) arr[i-1]=0;
    arr[el-1]=1; 
  }
  if (ev=='hi'){
    arr[el-1]=0; 
  }
}//menu

function timer(){
  for (i=1; i<=total_punkt; i++){
    obj_p=document.getElementById('punkt'+i);
	obj_s=document.getElementById('submenu'+i);
	yp=parseInt(obj_p.style.top);
	ys=parseInt(obj_s.style.top);  
 	hp=obj_p.offsetHeight;
    hs=obj_s.offsetHeight;
    if (arr[i-1]==1){
	  if (ys<(yp+hp)){ys+=speed; obj_s.style.top=ys;}
	  else{obj_s.style.top=yp+hp;}
	} 
    if (arr[i-1]==0){
	  if (ys>yp-(hs-hp)){ys-=speed; obj_s.style.top=ys;}
	  else{obj_s.style.top=yp-(hs-hp);}
	} 

/*	cl=(yp+hp)-ys;
	str_cl='rect('+cl+' 100% 100% 0)';
	obj_s.style.clip=str_cl;	*/
  }//i
}