$(document).ready(function() {
  /** 
    change the navigation menu html around a bit 
    NOTE: site_url variable is set in header.php
    TODO: do this using wordpress
   **/ 
  $('#navigation ul.menu li ul').parent().addClass('parent-menu');
  $('#navigation ul.menu li ul').parent().children('a').append(' <img src="' + site_url + '/images/arrow-down.png" />');

  /** some formatting for slider blocks **/
  /** for some reason, this messes up IE, so only do if not IE **/
  if (!  $.browser.msie) {
    $('.homepage #content-top .slider-block-li').each(function() {
      var li_height = $(this).height();
      console.info(li_height);
      $(this).children('.slider-li-interior').each(function() {
        var div_height = $(this).height();
        var margin = ( li_height - div_height ) / 2;
        if (margin > 0) {
          $(this).css('margin', margin + 'px 0');
        }
      });
    });
  }

  // easyslider doesn't work in IE7 and below
  if (! $.browser.msie || $.browser.version >= 8) {
    /** set up homepage sliders **/
    $("#slider1").easySlider({
      auto: true,
      continuous: true,
      controlsShow: false,
      vertical: true,
      pause: 7000,
      speed: 200
    });
    $("#slider2").easySlider({ 
      auto: true,
      controlsShow: false,
      continuous: true,
      vertical: true,
      pause: 11000,
      speed: 200
    });
  }

  /** social icon hover **/
  $('.homepage #content-top #social-and-search .social-icons li.icon').hover(
    function () {
      $(this).children().children('img.no-hover').hide();
      $(this).children().children('img.hover').show();
    },
    function () {
      $(this).children().children('img.no-hover').show();
      $(this).children().children('img.hover').hide();
    }
  );
  
  /** switch video play buttons **/
  $('.homepage #content-top .slider-block-li-left .attachment-post-thumbnail').hover(
    function () {
      $('.homepage #content-top .slider-block-li-left .video-play').hide();
      $('.homepage #content-top .slider-block-li-left .video-play-hover').show();
    },
    function () {
      $('.homepage #content-top .slider-block-li-left .video-play-hover').hide();
      $('.homepage #content-top .slider-block-li-left .video-play').show();
    }
  );
  $('.homepage #content-top .slider-block-li-left .video-play-hover').hover(
    function () {
      $('.homepage #content-top .slider-block-li-left .video-play').hide();
      $('.homepage #content-top .slider-block-li-left .video-play-hover').show();
      $('.homepage #content-top .slider-block-li-left .attachment-post-thumbnail').addClass('attachment-post-thumbnail-hover');
    },
    function () {
      $('.homepage #content-top .slider-block-li-left .video-play-hover').hide();
      $('.homepage #content-top .slider-block-li-left .attachment-post-thumbnail').removeClass('attachment-post-thumbnail-hover');
    }
  );

  /** subscribe box **/
  var subscribe = $('#feedburner-form .textfield');
  var subscribeDefault = 'subscribe via email';
  subscribe.val(subscribeDefault);
  subscribe.bind('focus', function(){if($(this).val()==subscribeDefault)$(this).val('');})
  subscribe.bind('blur', function(){if($(this).val()=='')$(this).val(subscribeDefault);})
});

