/* Author: 

*/

$(document).ready(function() {
  $('.slider').slider({
    afterControls: '<a href="https://dplenergygo.com" class="get-started ignore" data-item="3">Get Started</a>',
    animation_func: function($current, $next, options) {
      var anim_settings = $.extend({
            speed: 1000
          }, options);
          
      function post_animate() {
        var $this = $(this);
        
        $this.removeClass('current')
          .removeAttr('style');
        $this.siblings('.next')
          .addClass('current')
          .removeClass('next');
      }
      
      $current.fadeOut(anim_settings.speed, post_animate);
      
    }
  });
  
  // Accordion
  var $faqContainer = $('#vertical_container'),
      $faqs = $faqContainer.find('li:not(.featured)');
    
  $faqs
    .bind('open', function(e) { 
      var $li = $(this), 
      $content = $li.find('.accordion_content');

      $li.addClass('open');
      $content.animate({
        'height': $content.data('height')
      });
    })
    .bind('close', function(e) {
      var $li = $(this), 
      $content = $li.find('.accordion_content');

      if (!$content.data('height')) { 
        $content.data('height', $content.height());
      }

      $li.removeClass('open');
      $content.animate({
        'height': 0
      });
    });

  $faqContainer.delegate('li:not(.featured)', 'click', function(e) {
    e.preventDefault();
    
    var $target = $(e.target).closest('li');

    if ($target.hasClass('open')) {
      $target.trigger('close');
    } else {
      $target.trigger('open')
        .siblings(':not(.featured)').trigger('close');
    }
  });
  $faqs.trigger('close');
  
  
  // content switcher
  $('.res-bus-switch').find('a').bind('click', function(e) {
    e.preventDefault();
    
    if(!$(this).hasClass('active')){
      $(this).addClass('active').siblings().removeClass('active');
      $('.page-data').find('.toggle-content').toggleClass('open closed');
    }
  });
  
  
  // hover intent
  $('ul.sf-menu').superfish();
  
  //$('#contact-form').h5Validate();
});


// Event.observe(window, 'load', loadAccordions, false);
// 
// function loadAccordions() {
//   var bottomAccordion = new accordion('vertical_container');
// } 
// 
// var verticalAccordions = $$('.accordion_toggle');
// verticalAccordions.each(function(accordion) {
//   $(accordion.next(0)).setStyle({
//     height: '0px'
//   });
// });
