// Load Tooltip Plugin
RT.loadPlugin('tooltip');

document.observe('dom:loaded', function(){ 




    
    $$("td.cell-title").each(function(cellTitle){  
         
        
        var id = cellTitle.readAttribute('id');
    
    
        // Advanced Usage
        new RT.Tooltip(cellTitle, new Element('div').update(prepareFromPHP($('hover_' + id).select('.summary')[0].innerHTML)), {
            title:                          prepareFromPHP($('hover_' + id).select('.subject')[0].innerHTML),
            closeButton:                    '/images/main/close-blue.png',
            closeButtonHover:               '/images/main/close-red.png',
            offsetTop:                      -50,
            offsetLeft:                     300, 
            width:                          400,
            height:                         300,
            delay:                          false,
            placement:                      {
                element:                    'topLeft',
                tooltip:                    'topLeft'
            },
            beforeOpen:                     function(){
                                            if(!$('toggleViewSummaries').checked){ throw $break; }
            },
            afterUserClose:                     function(){
                                            $('toggleViewSummaries').checked = false; 
            }
            
        });
    
    });
        
        if ($('toggleViewSummaries')) {
            var tooltipMessage = 'Enabling summaries will display a preview of the first post in the discussion when the cursor is placed over the subject line.';

            new RT.Tooltip($('toggleViewSummaries').up(), tooltipMessage, {
                width:          280,
                placement:      {
                    element:        'topLeft',
                    tooltip:        'bottomRight'
                },
                stem:           'bottomRight',
                offsetTop:      -18,
                offsetLeft:     4,
                hook:           {element:$('toggleViewSummaries')}
            });
        }


});