var HtmlTips = new Class({
    
    Extends: Tips,
    
    initialize: function(elements, options) {
    
        if(!options) {
            options = {};
        }
        
        // force container classname to "tooltip"
        this.parent(elements, options);
        
    },
    
    attach: function(elements) {
        
        this.parent(elements);
        
        // override the default show/hide delay
        this.options.showDelay = 50;
        this.options.hideDelay = 50;
        this.options.className = 'tooltip';
        
        $$(elements).each(function(elm){

            // retrieve the currently set title
            var str = elm.retrieve('tip:title');
            
            if(str != null) {
                var arr_parts = str.split('::');
    
                // is this a title :: content style?
                if(arr_parts.length == 2) {
                
                    var str_title = arr_parts[0].trim();
                    var str_text = arr_parts[1].trim();
                    
                    // determine if title is using an element as its source
                    if(str_text.indexOf('id:') == 0) {
                    
                        // extract class name to retrieve content from
                        var str_id = str_text.substring(3);
                        var elm_tooltip = $(str_id);
                        
                        // if we've found the content, extract it and remove
                        if(elm_tooltip) {
                        
                            str_text = elm_tooltip.get('html');
                            
                            elm_tooltip.dispose();
                            elm_tooltip = null;
                        }
                    }
                    
                    // assign the title and content
                    elm.store('tip:title', str_title);
                    elm.store('tip:text', str_text);
                }
            }
            
        }, this);
    }
    
});
