$(document).ready(function() {

  var clearInputPrevious = '';
  // clear input on focus
  $('input').focus(function()
  {
    if( $(this).val()==$(this).attr('placeholder') )
    {
      clearInputPrevious = $(this).val();
      $(this).val('');
    }
  });
  // if field is empty afterward, add text again
  $('input').blur(function()
  {
    if($(this).val()=='')
    {
      $(this).val(clearInputPrevious);
    }
  });


  var clearTextareaPrevious = '';
  $('textarea').focus(function()
  {
    if( $(this).val()==$(this).attr('placeholder') )
    {
      clearTextareaPrevious = $(this).val();
      $(this).val('');
    }
  });
  // if field is empty afterward, add text again
  $('input').blur(function()
  {
    if($(this).val()=='')
    {
      $(this).val(clearTextareaPrevious);
    }
  });


  function getAbsolutePath() {
    var loc = window.location;
    var pathName = loc.pathname.substring(0, loc.pathname.lastIndexOf('/') + 1);
    return loc.href.substring(0, loc.href.length - ((loc.pathname + loc.search + loc.hash).length - pathName.length));
  }
  var pagePath = getAbsolutePath().toString();
  var pageLength = getAbsolutePath().length;

  // highlight the current root level menu item
  if( pagePath.substring(pageLength - 9) == 'specials/' )
  {
    $('.menu-specials').addClass('current-menu-item');
  }
  else if( pagePath.substring(pageLength - 5) == 'menu/' )
  {
    $('.menu-menu').addClass('current-menu-item');
  }


  if( $('li.widget_eme_list li p a').length )
  {
    $('li.widget_eme_list li p a').prepend('<div class="learn-more"><img src="http://c22design.com/Test/doitbuffalostyle/wp-content/themes/crwings/images/learn-more.png" /></div>');
  }


  $('li.widget_eme_list img').not('li.widget_eme_list .learn-more img').hover(
    function() {
      var enlargedImage = $(this).attr('src').slice(0,-10);
      //console.log(enlargedImage);
      $('#enlarged-image').append('<img src="'+enlargedImage+'.jpg" class="lrg-img" />');
    },
    function() {
      $('#enlarged-image .lrg-img').remove();
    }
  );
});
