function Hint(id, delay, width, hintHTML) {
    this.id = id;
    this.delay = (delay ? delay : 1000);
    this.width = (width ? (width == -1 ? null : width) : 200);
    this.popup = new popup(id + '_popup');
    this.timerid = null;
    this.x = 0;
    this.y = 0;
    
    var holder = $(id);
    if (holder) {
        holder._hint = this;
        this.popup.setHTML((hintHTML ? hintHTML : holder.title.replace('\n', '<br/>')));
        if (!hintHTML) holder.title = '';
        
        var h = this;
        Event.observe($(id), 'mouseover', function() {
            h.hide();
            h.startTimer();
        });
        
        Event.observe($(id), 'mousemove', function(event) {
            h.x = Event.pointerX(event);
            h.y = Event.pointerY(event);
        });
        
        Event.observe($(id), 'mouseout', function() {
            h.hide();
        });
    }
    
    this.show = function() {
        this.popup.show(this.x + 30, this.y + 1, this.width);
    }
    
    this.hide = function() {
        this.cancelTimer();
        this.popup.hide();
    }
    
    this.cancelTimer = function() {
        if (this.timerid) { 
            window.clearTimeout(this.timerid); 
            this.timerID = null;
        }
    }
    
    this.startTimer = function() {
        var h = this;
        this.timerid = window.setTimeout(function () { h.show(); }, this.delay);
    }
    
    
    
}


function getHint(id) {
    var h = $(id);
    return (h ? h._hint : null);
}
