jQuery(document).ready(function($) {
  
  
  /*
  ** Order form product details tooltips
  */
  
  (function() {
    
    var labels = $('form li.product label[data-tooltip]');
    labels.each(function() {
      // Create and inject trigger.
      var trigger = $('<span class="tooltip-trigger"><img src="' + Ashe.HTTP_INC_ROOT + 'assets/icons/information.png" alt="Details" title=""/></span>');
      trigger.appendTo($(this));
    });
    
    // Call the tooltips.
    $('form li.product span.tooltip-trigger').tooltip({
      delay: 0,
      bodyHandler: function() {
        return $(this).parent('label').attr('data-tooltip');
      }
    });
    
  })();
  
  
  
  /*
  ** Equal height 'columns'
  **
  ** We'll be calling the equal heights function twice, once on domready, once on page load.
  ** If we do it just on domready, large images that haven't loaded yet in the content area may prevent it from doing its job.
  ** If we do it just on document load, it may take a while for the effect to kick in if there's slow-loading images, which is annoying.
  */

  (function() {
    
    var els = $('#main-content, #main-sidebar-content');
    
    els.equalHeight();
    
    $(window).load(function(e) {
      els.equalHeight();
    });

  })();
  
  
  
  /*
  ** Cyclers
  */
  
  /* Instantiate a Cycler for the testimonials. */
  (function() {
    
    var items = [
      '<li><blockquote><p>Ever since I moved to JCHost I can sleep at night knowing that there will not be any problems, and I have the best support provided by James the owner, he is very understanding and cares about my business, it\'s fantastic!  Thanks for everything JCHost!</p></blockquote><cite>Renan, <a href="http://TotalPremium.com.br">TotalPremium.com.br</a></cite></li>'
    ];
    
    if($('html.home').length) var testimonials = new Cycler({ wrapper: '#testimonials', timer: 6000, controlsLoc: 'before', pausedOverlay: true, items: items, animation: 'bottom' });
    else                      var testimonials = new Cycler({ wrapper: '#testimonials', timer: 6000, controlsLoc: 'before', pausedOverlay: true, items: items });
    
    testimonials.fixDimensions();
    
  })();
  
  
  
  /*
  ** Form effects: input/textarea focus.
  */
  
  (function() {
    
    var els = $('input[type="text"], input[type="password"], textarea');
    var old = {
      backgroundColor: els.css('backgroundColor'),
      color          : els.css('color')
    };
    
    els.bind('focus blur', function(e) {
      if($(this).css('backgroundColor') == old.backgroundColor) $(this).animate({ backgroundColor: '#ccda52' });
      else                                                      $(this).animate({ backgroundColor: old.backgroundColor });
    });
    
  })();
  
  
}); // end domready