
var Slidebox = new Class({

    initialize: function (className) {
      var boxes = $ES('div[class=' + className +']'); 

      if (boxes.length) {
        
        boxes.each(function (box){
          var head = box.getElement('h3');
          var content = new Element('div').injectAfter(head);
          
          var children = box.getChildren();
          for (var i = 0; i < children.length; i++) {
              if ( !(children[i] == content || children[i] == head) ) {
                content.adopt(children[i]);
              }
          }

          if (content.childNodes.length > 0) {
            var fx = new Fx.Slide(content, { 'duration': 500, 'transition': Fx.Transitions.Quart }); 
            head.addEvent('click', (function(){ this.toggle(); }).bind(fx))
          }
          else {
            content.remove();
          }

        });
      }
    }

}); 

// nacteni
window.addEvent('domready', function(){
  new Slidebox('slidebox');
});
