// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

document.observe('dom:loaded', function() {
    $$('.import-messages').each(function(e) {
        if(e.parentNode.nodeName != 'DD') { 
          e.cleanWhitespace();
          var li_nodes = []
          for (var c = 0; c < e.childNodes.length; c++) {
            if(e.childNodes[c].nodeName == 'LI')
              li_nodes.push(e.childNodes[c])
          }
          
          if (li_nodes.length > 1) {
            li_nodes[0].addClassName('first');
            e.addClassName('collapsed');
    
            var s = document.createElement('span');
            s.textContent = '(' + (li_nodes.length-1) + ' more)';
            s.addClassName('toggle');
            s.observe('click', function(e) { e.currentTarget.parentNode.parentNode.toggleClassName('collapsed'); });          
            li_nodes[0].appendChild(s)
          }
        }
    });

    $$('#recent-activity h3').each(function(e) {
        e.addClassName('open').writeAttribute('title', 'Hide');
        e.observe('click', function(ev) {
            var title = this.hasClassName('open') ? 'Show' : 'Hide';
            this.toggleClassName('open').toggleClassName('closed').writeAttribute('title', title).next().toggle();
        });
    });
})
