if (jQuery) {
  (function($){
      $(function() {
        
          // dropdown nav
          // $('#secondary_navigation').AccessibleDropNav({targetId: '#navigation', copy: true, onlySetup: true});
        
          // email placeholder
          if ( !('placeholder' in document.createElement('input')) && document.getElementById && document.getElementById('sign_up_content') !== null ) 
          {
            // Email Signup Form Placeholder, only does this if "placeholder" HTML5 attr unavailable
            $('#sign_up_email_address').focus(function() {
                if ($(this).val() == 'Enter Your Email')
                    $(this).css({color:'#000'}).val('');
            }).blur(function() {
                if ($(this).val() === '')
                    $(this).css({color:'#ccc'}).val('Enter Your Email');
            }).css({color:'#ccc'}).val('Enter Your Email');
          }
          
          
          // home page code
          if (document.getElementById && document.getElementById('home-page') !== null) {

            
            
            // logo scroller.
            if (document.getElementById && document.getElementById('ga-box') !== null) {
              var logoScrolling = 0;
              var scrollTimer = null;
              var doScroll = function() {
                try {
                  var pos = jQuery('.ga-logos').css('background-position-x');
                  if (pos === '') // firefox fix
                    pos = jQuery('.ga-logos').css('background-position').split(' ')[0];
                  var cx = parseInt(pos, 10);
                  var newPos = (cx+(4*logoScrolling))+'px 0px';
                  jQuery('.ga-logos').css('background-position', newPos);
                } catch (e) {
                  // nada
                }
              };
              var logoScroll = function(direction) {
                logoScrolling = direction;
                scrollTimer = setInterval(doScroll, 50);
              };
              var stopLogoScroll = function() {
                logoScrolling = 0;
                if (scrollTimer !== null) {
                  clearInterval(scrollTimer);
                  scrollTimer = null;
                }
              };
              $('<div class="leftbutton">')
                .mouseover(function() {logoScroll(1);})
                .mouseout(function() {stopLogoScroll();})
                .appendTo('#logoslider');
              $('<div class="rightbutton">')
                .mouseover(function() {logoScroll(-1);})
                .mouseout(function() {stopLogoScroll();})
                .appendTo('#logoslider');
              
            }
            
            // BEGIN featured section.
            
            var cycleFreq = 5500;
            
            // whether or not the featured area has focus

            // change focus to what's moused over
            var features = $('ul.feature-menu a');
            var switch_to_feature = function(link_element) {
              features.removeClass('active');
              $(link_element).addClass('active');
              var target = $('#'+$(link_element).attr('data-target'));
              target.show();
              $('.feature').not(target).hide();
            };
            features.mouseover(function() {
              switch_to_feature(this);
            });

            var feature_timer = null;
            var autocycle_features = function() {
              var current_el = $('ul.feature-menu a.active');
              var next_el = current_el.parents('li').next();
              if (next_el.length === 0) {
                next_el = $('ul.feature-menu li').first();
              }
              switch_to_feature(next_el.find('a'));
            };
            feature_timer = setInterval(autocycle_features, cycleFreq);
              
            var feats_have_focus = false;
            $('#features')
            .mouseover(function() { 
              feats_have_focus = true; 
              if (feature_timer !== null) {
                clearInterval(feature_timer);
                feature_timer = null;
              }
            })
            .mouseout(function() { 
              feats_have_focus = false; 
              if (feature_timer === null) {
                feature_timer = setInterval(autocycle_features, cycleFreq);
              }
            });

            
            // TODO: should background-load the resources for the slides
            
          } // End home page code
          
          
          // Begin Wishes page mouseover effects

          if ($('body').hasClass('page_wishes') || $('body').hasClass('category-wish-kid')) {
            $('.wishes li').hover(
              function() {
                $(this).find('.wish-cta').show();
              },
              function() {
                $(this).find('.wish-cta').hide();
              });
          }

          // pagination thingy that predates this theme
          
          var holder = document.getElementById("page-split");
          if(holder) {
                  var pages = holder.getElementsByTagName("span");
                  pages[pages.length-1].innerHTML = "Next";
          }
          
      });
  })(jQuery);
}

