﻿var Tip={
    offsetXY:{x:10,y:15},
    hID:'AVILETIP',
    containerStyle:{backgroundColor:'#CCCCCC',border:'solid 1px #000000',width:'500 px'},
  //  contentTemplate:'<table><tr><td>#TextContent<br /><img src="#ImgSource" /></td></tr></table>',
    contentTemplate:'<table><tr><td>#TextContent</td></tr></table>',
    _buildTip:function(){
        var t=this,d=document.createElement('div');
        d.id=t.hID;
        if(t.containerStyle){
            for(var s in t.containerStyle)
                d.style[s]=t.containerStyle[s];
        }
        d.style.position='absolute';
        document.body.appendChild(d);
        return d;
    },
    _getXY:function(e){
        e=e||window.event;m=document.documentElement;b=document.body;
        return e?{x:e.pageX||(e.clientX+(m.scrollLeft||b.scrollLeft)),y:e.pageY||(e.clientY+(m.scrollTop||b.scrollTop))}:{x:0,y:0}
    },
    $:function(id){
        return typeof(id)=='string'?document.getElementById(id):id;
    },
    show:function(e,c,m){
        var t=this,o=t.$(t.hID);
        if(!o)o=t._buildTip();
        //o.innerHTML=t.contentTemplate.replace('#TextContent',c).replace('#ImgSource',m);
         o.innerHTML=t.contentTemplate.replace('#TextContent',c);
        t.move(e);
    },
    move:function(e){
        var t=this,o=t.$(t.hID),p=t._getXY(e);
        if(o){
            with(o.style){
                display='';
                left=(p.x+t.offsetXY.x)+'px';
                top=(p.y+t.offsetXY.y)+'px';
            }
        }
    },
    hide:function(){
        var t=this;
        if(t.$(t.hID))t.$(t.hID).style.display='none';
    },
    dispose:function(){
        var t=this;
        if(t.$(t.hID))t.$(t.hID).parentNode.removeChild(t.$(t.hID));
        delete window['Tip'];
    }
}
