
function initHelp() { new accordion('help_menu',{ direction: 'vertical' }); }
document.observe('dom:loaded',initHelp);

var Comments = Class.create();
Comments.prototype = {
  
  initialize: function() {
    
    var th = this;
    
    $$('li.readmore a').each(function(elm){
      elm.observe('click',th.toggle_view.bindAsEventListener(th));
    });
    
  },
  
  toggle_view: function(e) {
    
    Event.stop(e);
    
    var hidden_ul = e.target.ancestors('ul')[1].next();
    
    if( hidden_ul.hasClassName('hide') ) {
      
      var anchor_text = e.target.innerHTML.replace('read more','show less');
      e.target.update(anchor_text);
      
      hidden_ul.setStyle({ 'display': 'none' });
      hidden_ul.removeClassName('hide');
      new Effect.BlindDown(hidden_ul,{ duration: 0.4 });
      
    } else {
      
      var anchor_text = e.target.innerHTML.replace('show less','read more');
      e.target.update(anchor_text);
      
      new Effect.BlindUp(hidden_ul,{
        duration: 0.4,
        afterFinish: function() {
          hidden_ul.addClassName('hide');
        }
      });      
      
    }
    
  }
  
};

var LiveHelp = Class.create({
  
  initialize: function() {
    
    Element.observe('live_chat','click',this.open_live_help.bindAsEventListener(this));
    
  },
  
  open_live_help: function(e) {
    
    Event.stop(e);
    
    var anchor = $('live_help_container').select('a').last();
    window.location = anchor.href;
    
  }
  
});

function initComments() { var comments = new Comments(); new LiveHelp(); }
document.observe('dom:loaded',initComments);