﻿var menu = {    
    getTop:function(e){    
        var offset=e.offsetTop;    
        if(e.offsetParent!=null) 
        {
            offset+=getTop(e.offsetParent);    
        }
        return offset;    
    },
    getLeft:function(e){
        var offset=e.offsetLeft;    
        if(e.offsetParent!=null) 
        {
            offset+=getLeft(e.offsetParent);    
        }
        return offset;
    },
    getPosition: function(o){ 
        var temp={};
        temp.left=temp.right=temp.top=temp.bottom=0;
//        var oWidth=o.offsetWidth,oHeight=o.offsetHeight;
//        while(o!=document.body)
//        {
//            temp.left+=o.offsetLeft;
//            temp.top+=o.offsetTop;
//            var border=parseInt(o.offsetParent.currentStyle.borderWidth);
//            if(border)
//            {
//                temp.left+=border;
//                temp.top+=border;
//            }
//            o=o.offsetParent;
//        }
//        temp.right=temp.left+oWidth;
//        temp.bottom=temp.top+oHeight;   

        var p = $(o).position();
        temp.top = p.top; 
        temp.left = p.left; 
        temp.bottom = $(o).height();
        temp.right =  $(o).width(); 
        return temp;
    },
    OverEvent: function(obj,DownID,isLocation){
        if(isLocation==true)
        {
           var thisleft=this.getPosition(obj).left;
           var thistop=this.getPosition(obj).top; 
           var h=this.getPosition(obj).bottom;  
           $('#'+DownID+'').css('left',thisleft);
           $('#'+DownID+'').css('top',thistop+h); 
           //document.getElementById(DownID).style.left=thisleft;
           //document.getElementById(DownID).style.top=thistop+h-2;
           
        }
       document.getElementById(DownID).style.display='block';
    },
    DownEvent: function(DownID){ 
        document.getElementById(DownID).style.display='none';
    }    
};
