function DyMenu( id ,  delay ,iedx,iedy,nsdx,nsdy, ieox,ieoy,nsox,nsoy ){

  this.id       =id;
  this.isIE    = false;
  this.version = null;
  this.Tree     =new Array();
  this.Timer    =null;
  this.Delay    =delay; // 1500
  this.iedx     =iedx;  // shift x 
  this.iedy     =iedy;  // shift y
  this.nsdx     =nsdx;  // shift x 
  this.nsdy     =nsdy;  // shift y
  
  this.ieox     =ieox;  // shift x
  this.ieoy     =ieoy;  // shift y
  this.nsox     =nsox;  // shift x
  this.nsoy     =nsoy;  // shift y
  this.offsetW  ='R';   // shift from Right side , L left Side 
 
  this.Rb       =new Array( null,null,null,null,null,null,null,null); 

  var ua = navigator.userAgent; var i; var s = "MSIE";
  if (   (i =ua.indexOf(s) )>=0   ) { this.isIE = true;  this.version = parseFloat(ua.substr(i + s.length));   }
 
  this.setoffsetW=function( k ) { this.offsetW=k; }
    
  this.Q=function(){ if( this.Timer!=null ) { clearTimeout(this.Timer); this.Timer=null; }    }	
  this.N=function(){ this.Q();   this.Timer=setTimeout( ""+this.id+".delay_clear()" , this.Delay  );   }	
  this.delay_clear=function (){  this.Timer=null; this.clear_tree();this.Hclear();      }
  this.Z=function (t){ this.clear_tree_node(t); }    	
  this.S=function () { this.clear_tree();this.Hclear(); }
  this.M=function ( ev, t , f ){  
  	 this.Q();  this.set_2tree(t,f);  

         var item=document.getElementById(t);
         if( item ){ 
         	
            var dx=0,dy=0;	
            if( this.isIE ){  // smsg( "over:"+t );
                               ev=window.event; 
                               var bt=ev.srcElement;           dx=this.iedx; dy=this.iedy; 
                               ev.cancelBubble = true;
                               ev.returnValue = false;
            }
            else           {  var bt=ev.currentTarget;         dx=this.nsdx; dy=this.nsdy; 
                              ev.preventDefault();
                              ev.stopPropagation();

            }
            var x=this.getPageOffsetLeft( bt );
            var y=this.getPageOffsetTop(  bt );
  	    var w=bt.offsetWidth;  

            this.H(bt); 
             
            if( this.Tree.length==1 ){
                  if( this.isIE ){ x+=this.ieox; y+=this.ieoy; }
                  else { x+=this.nsox; y+=this.nsoy; } 
            }else { x+=dx; y+=dy;  }   
             

            var pnode=this.getContainerWith( bt  , "DIV", "menu" ); 	   
            if( pnode!=null ){  
                  w=pnode.offsetWidth;
                  x=pnode.offsetLeft+dx;
                  y=pnode.offsetTop+dy;
                   
                  pnode=this.getContainerWith( bt  , "A", "menuItem" ); 
                  if( pnode!=null ){ y=y+pnode.offsetTop; }
                 // smsg( pnode.innerHTML );    
                 // smsg("pnode w ="+w+" x="+x+"  y="+y);
            }
             //{  
             //if( this.isIE ){ x+=this.ieox; y+=this.ieoy; } 
             //else  smsg("w="+w+" x="+x+"  y="+y); 
             //}
            if( this.offsetW =='L' ) this.setpos( item  ,x ,y );  
  	    else                     this.setpos( item  ,x+w ,y);

            //      smsg(t); 
  	    this.setdisplay( t ,"block" );
            if( this.isIE ){  this.fixIE(t); }
  	 }   
  }
  this.H=function( o ){
       var i=this.Tree.length; if( i<=0 ) return ;  i--;
       if( this.Rb[i]!=null ){
               this.remClassName( this.Rb[i],"dover"); 
               var h=this.findroot(  this.Rb[i] ); if( h!=null ) this.remClassName( h ,"rdover");
       } 
       this.Rb[i]=o;          this.setClassName( this.Rb[i],"dover");   

       var h=this.findroot(  this.Rb[i] ); if( h!=null ) this.setClassName( h ,"rdover");
  } 
  this.Hclear=function (){
       for( var i=0;i<this.Rb.length;i++){
           if( this.Rb[i]!=null ){
                   this.remClassName( this.Rb[i],"dover");  
                   var h=this.findroot(  this.Rb[i] ); if( h!=null ) this.remClassName( h ,"rdover");
                   this.Rb[i]=null;
           }
       }    
  }
  this.setClassName=function( el,name ){
       var list = el.className.split(" ");
       for (var i = 0; i < list.length; i++){ if( list[i] == name ) return ; }
       el.className=el.className+" "+name;    
  }
  this.remClassName=function( el,name ){
       var a=new Array();
       var list = el.className.split(" ");
       for (var i = 0; i < list.length; i++){  if( list[i] != name ) a.push( list[i] );   }
       el.className=a.join(" ");
  } 
  this.fixIE=function (t){
      var o=document.getElementById(t);
      if( parseInt(o.style.width)>0 ) return ;
      o.style.width=( o.offsetWidth*1+5 )+"px";
      var o2=o.getElementsByTagName("a");
      for(var i=0;i<o2.length;i++){ o2.item(i).style.width="100%"; }	
  }
  this.setpos=function (o,x,y){
    //  smsg("x= "+x+" y="+y);
      o.style.left=x+"px";  o.style.top=y+"px";
   }
  
  this.setdisplay=function(t,h){
    //smsg( "display :"+t )
    if(t){
          var o=document.getElementById(t);
          if( o )  o.style.display=h;
    }	 
  }
  this.findroot=function (el){
      if( el.nodeName=="DIV"  && el.id=="xyz" ) return el; 
      if( el.offsetParent != null ) return this.findroot( el.offsetParent );
      return null;  
  }
  this.set_2tree=function ( t,f ){  if( f=='' ) this.clear_tree();  else    this.clear_tree_node(f);   this.Tree.push(t); }
  this.clear_tree_node=function(f){
      var A = new Array();	
      var len=this.Tree.length;
      for(var i=len-1; i>=0 ;i-- ){   if( this.Tree[i]==f ) break;   this.setdisplay( this.Tree[i]  ,"none");  this.Tree[i]='';	 }
      for(var i=0; i<len ;i++ ){ if( this.Tree[i]!='' ) A.push( this.Tree[i]  );  } this.Tree=A;	
  }	
  this.clear_tree=function(){
       var len=this.Tree.length; for(var i=len-1; i>=0 ;i-- ){ this.setdisplay( this.Tree[i]  ,"none");  } this.Tree=new Array();	
  }	
  this.getPageOffsetLeft=function(el) {
      var x;  // Return the x coordinate of an element relative to the page.
      x = el.offsetLeft;  if (el.offsetParent != null)  x += this.getPageOffsetLeft(el.offsetParent);
      return x;
  }
  this.getPageOffsetTop=function(el) {
       var y;  // Return the x coordinate of an element relative to the page.
       y = el.offsetTop;  if (el.offsetParent != null)   y += this.getPageOffsetTop(el.offsetParent);
       return y;
  }
  this.getContainerWith=function(node, tagName, className) {
     // Starting with the given node, find the nearest containing element
     // with the specified tag name and style class.
     while (node != null) {
        if (node.tagName != null && node.tagName == tagName && this.hasClassName(node, className) ) return node;
        node = node.parentNode;
     }
     return node;
  }
  this.hasClassName=function(el, name) {
     var i, list;
     // Return true if the given element currently has the given class name
     list = el.className.split(" ");
     for (i = 0; i < list.length; i++) if (list[i] == name)   return true;
     return false;
  }


   
}
/**
function msg(s){
  var o=document.getElementById("pool999");
  o.value=s+"\n"+o.value; 
}
document.write("<div style='position:absolute;border:1px solid green;width:400px;height:300px;left:100px;top:300px;' ><textarea id=pool999 style='width:99%;height:99%;'></textarea></div>");
**/

