code: function toggle(element, animation, callbackFn) {
      var nowVisible = element.style.display != 'none' || element.offsetLeft > 0;
  
      // create clone for reference
      var clone = element.cloneNode(true);
      var cleanup = function() {
          element.removeAttribute('data-animated');
          element.setAttribute('style', clone.getAttribute('style'));
          element.style.display = nowVisible ? 'none' : '';
  		if( callbackFn ) { callbackFn(); }
      };
  
      // store attribute so everyone knows we're animating this element
      element.setAttribute('data-animated', "true");
  
      // toggle element visiblity right away if we're making something visible
      if( ! nowVisible ) {
          element.style.display = '';
      }
  
      var hiddenStyles, visibleStyles;
  
      // animate properties
      if( animation === 'slide' ) {
          hiddenStyles = initObjectProperties(["height", "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom"], 0);
          visibleStyles = {};
  
          if( ! nowVisible ) {
              var computedStyles = window.getComputedStyle(element);
              visibleStyles = copyObjectProperties(["height", "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom"], computedStyles);
  
              // in some browsers, getComputedStyle returns "auto" value. this falls back to getBoundingClientRect() in those browsers since we need an actual height.
              if(!isFinite(visibleStyles.height)) {
                var clientRect = element.getBoundingClientRect();
                visibleStyles.height = clientRect.height;
              }
              css(element, hiddenStyles);
          }
  
          // don't show a scrollbar during animation
          element.style.overflowY = 'hidden';
          animate(element, nowVisible ? hiddenStyles : visibleStyles, cleanup);
      } else {
          hiddenStyles = { opacity: 0 };
          visibleStyles = { opacity: 1 };
          if( ! nowVisible ) {
              css(element, hiddenStyles);
          }
  
          animate(element, nowVisible ? hiddenStyles : visibleStyles, cleanup);
      }
  }
docs: Toggles the element using the given animation.
  
  @param element
  @param animation Either "fade" or "slide"