HoverWindow=function()
{
    this.Element=$('hoverwindow');
    this.Anchor;
    this.Parent;
    this.Width;
    this.Height;
    
    var _leaveTimer;
    var closeHandler;
    
    this.initialize=function(parent)
    {
        this.Element.parentNode.removeChild(this.Element);
        parent.appendChild(this.Element);
        this.Parent=parent;
        
        this.hide();
        
    }
    this.create=function(element,url)
    {
        this.Anchor=element;
        
        //url=uriEncode("<arguments>"+url+"</arguments>");
        url=uriEncode(url);
        context.request(HoverWindowHandler_URL+"?action=create&param="+url);
    }
    this.refresh=function(width,height,content)
    {
        closeHandler=Function.createDelegate(this,this.leave);
        this.Element.attachEvent("onmouseout",closeHandler);
        this.Anchor.attachEvent("onmouseout",closeHandler);
        
        var a=com.getLocation(this.Anchor);
        var p=com.getLocation(this.Parent);
        
        this.Element.innerHTML=content;
        this.Element.style.width=width+"px";
        this.Element.style.height=height+"px";
        this.Element.style.left=a[0]-p[0]+this.Parent.scrollLeft-5+20+"px";//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        this.Element.style.top=a[1]-p[1]+this.Parent.scrollTop-5+"px";
        
        this.Width=width;
        this.Height=height;
        if(this.close())this.show();
        //this.show();
    }
    this.leave=function()
    {
        _leaveTimer=window.setTimeout("javascript:hoverwindow.close();",300);
    }
    this.close=function()
    {
        if(_leaveTimer)window.clearTimeout(_leaveTimer);
        
        
        var e=com.getLocation(this.Element);
        var left=e[0]-20;//??????????????????????????????????????????????????????????????
        var top=e[1];
        var right=e[0]+this.Width;
        var bottom=e[1]+this.Height;
        var inElement=((com.mouseX>left)&&(com.mouseX<right)&&(com.mouseY>top)&&(com.mouseY<bottom));
        //window.status=com.mouseX+","+com.mouseY+","+left+","+top;
        var e2=com.getLocation(this.Anchor);
        var left2=e[0]-10;
        var top2=e[1];
        var right2=e[0]+this.Anchor.offsetWidth;
        var bottom2=e[1]+this.Anchor.offsetHeight;
        var inAnchor=((com.mouseX>left2)&&(com.mouseX<right2)&&(com.mouseY>top2)&&(com.mouseY<bottom2));
        //alert("|"+com.mouseX+","+com.mouseY+","+left+","+top+","+left2+","+top2);
        if(inElement||inAnchor)
        {
            return true;
        }
        
        this._close();
        return false;
    }
    this._close=function()
    {
        this.Element.innerHTML="";
        this.hide();
    }
    this.show=function()
    {
        this.Element.style.visibility="visible";
    }
    this.hide=function()
    {
        this.Element.style.visibility="hidden";
    }

}