$(document).ready(function(){

  var smallCaps = function smallCaps() {
    var skipwords = '&amp;,about,and,as,at,been,but,by,for,has,in,is,may,nor,not,of,on,or,so,some,the,to,with,yet,your,via,with';
    var sentence = $(this).text().split(' ');
    var word;
    var newsentence = '';

    for(var i=0, len=sentence.length; i<len; ++i){
      word = sentence[i];
      if(skipwords.indexOf(word)==-1 && isNaN(word[0])){
        newsentence = newsentence+'<span class="first-letter">'+word.substring(0,1)+'</span>'+word.substring(1,word.length);
      }
      else {
        newsentence = newsentence+'<span class="short-word">'+word+'</span>';
      }
      if(i==len-2) { newsentence = newsentence+'&nbsp;'; } //no widows
      else { newsentence = newsentence+' '; }
    }
    $(this).html(newsentence);
  }

  $.each($('#entries h3 a'), smallCaps);
  $.each($('h1'), smallCaps);     
  $.each($('#comments h3'), smallCaps);
  $.each($('#side h4'), smallCaps);

  $('#entries h3 a').hover(
    function () {
      $(this).append($(' <span class="permalink">&#8734;</span>'));
    }, 
    function () {
      $(this).find("span:last").remove();
    }
  );

  $('#header h2 a').hover(
    function () {
      $(this).append($(' <span class="return-home">&larr; return home</span>'));
    }, 
    function () {
      $(this).find("span:last").remove();
    }
  );
  
  $(".entry img.size-thumbnail:eq(4), .entry img.size-thumbnail:eq(9), .entry img.size-thumbnail:eq(14)").parent("a").css("margin-right","0");
  
});