/**
 * @fileoverview
 * <b><i>effects.js</i></b>
 *
 * @author Martin Hristov <martin@netclime.com>
 * @version 1.0
 */

SECTION_GROUP.Effects   = {};

SECTION_GROUP.Animations = {};

SECTION_GROUP.Animations.Slide = {
   
   "effect": function ( holder, options ) {
      var sec_body = holder.getParent('.secBody');
      if (sec_body.getStyle('padding') != '0px 0px 0px 0px') {
         var inner_wrapper = holder.getElements('.secBodyInnerWrapper');
         inner_wrapper.setStyle('padding', sec_body.getStyle('padding'));
         sec_body.setStyle('padding', '0px');
      }
      return new Fx.Slide(holder, options);
   },

   "show": function ( fx ) {
      fx.cancel();
      fx.slideIn();
   },
   
   "hide": function ( fx ) {
      fx.cancel();
      fx.slideOut();
   },
   
   "reset": function ( fx ) {
      fx.cancel();
      fx.hide();
   },

   "options": {
      "transition":  Fx.Transitions.Cubic.easeOut,
      "section_state_classes": {active: 'active', inactive: 'noactive'},
      "onStart": function () {
         if ( this.to[0] == 0 ) {
            SECTION_GROUP.SetActiveSectionState(this.element.getProperty('root_id'), this.options.section_state_classes);
         }
      },
      "onComplete": function () {
         if ( this.to[0] < 0 ) {
            SECTION_GROUP.RemoveActiveSectionState(this.element.getProperty('root_id'), this.options.section_state_classes);
         }
      }
   }

};

SECTION_GROUP.Animations.Accordion = {
   
   "effect": function ( togglers, elements, options ) {
      for (var i = 0; i < elements.length; i++) {
         var sec_body = elements[i].getParent('.secBody');
         if (sec_body.getStyle('padding') != '0px 0px 0px 0px') {
            var inner_wrapper = elements[i].getElements('.secBodyInnerWrapper');
            inner_wrapper.setStyle('padding', sec_body.getStyle('padding'));
            sec_body.setStyle('padding', '0px');
         }
      }
      return new Accordion(togglers, elements, options);
   },

   "options": {
      "show": null,
      "opacity": false,
      "transition": Fx.Transitions.Cubic.easeInOut,
      "section_state_classes": {active: 'active', inactive: 'noactive'},
      "collapse_icon_cell_classes": {collapse: 'secIconCol', expand: 'secIconExp'},
      "onActive" : function () {
         SECTION_GROUP.SetActiveSectionState(this.elements[this.previous].getProperty('root_id'), this.options.section_state_classes);
         SECTION_GROUP.HideCollapseIcon(this.elements[this.previous].getProperty('collapse_icon_cell_id'));
      },
      "onComplete" : function () {
         for ( var i = 0; i < this.elements.length; i++ ) {
            if ( i != this.previous ) {
               SECTION_GROUP.RemoveActiveSectionState(this.elements[i].getProperty('root_id'), this.options.section_state_classes);
               SECTION_GROUP.DisplayCollapseIcon(this.elements[i].getProperty('collapse_icon_cell_id'), this.options.collapse_icon_cell_classes);
            } else {
               SECTION_GROUP.HideCollapseIcon(this.elements[i].getProperty('collapse_icon_cell_id'));
            }
         }
      }
   }

};


