$(document).ready(function(){

  $('#tagsList').jScrollPane({showArrows:true, dragMinHeight: 20, scrollbarWidth: 15, arrowSize: 16});

  var default_values = {};
  
  $('input, textarea').each(function(i) {
    var index = $(this).attr('name');
    var value = $(this).val();
    default_values[index] = value;
  });
  
  $('input, textarea').focus(function() {
    if ($(this).val() === default_values[$(this).attr('name')]) {
      $(this).val('');
    };
  });
  
  $('.hentry > p:first').addClass('excerpt').find('span').replaceWith('hook');
  var portions = $('.hentry > p:first').html();
  var excerpt = portions.split('hook')[0];
  // controlliamo se esiste un secondo elemento dell'array, se non esiste, ritorniamo una stringa vuota
  // senza questo controllo, qualora non fosse esistito un secondo elemento dell'array,  avrebbe stampato a video "undefined" al posto del testo che ci aspettavamo
  var notexcerpt = (portions.split('hook')[1]) ? portions.split('hook')[1] : '';
  $('.hentry > p:first').html("<strong>"+excerpt+"</strong> "+notexcerpt);

  // .show for post 7554, .external_script to let one embed snippet of codes like videos or widget ones
  $('.hentry > div').eq(1).not('.hentry > div:has(iframe),.external_script, .show').addClass('hidden');

  $('.hentry p:last:has(img), .hentry div:last p:has(img)').css({'margin-bottom': '-10px', 'float': 'left'});
  $('.hentry p:last:has(iframe), .hentry > div:has(iframe)').css("margin-bottom", "-5px");

  $('.hentry div iframe, .hentry p iframe').css({width: '600px', 'margin-left': '-10px', 'margin-bottom': '-10px'});

  $('li#linkedin').html('<a href="http://www.linkedin.com/shareArticle?mini=true&url=' + encodeURIComponent(location.href) + '&title=' + encodeURIComponent(document.title) + '&summary=' + encodeURIComponent(document.title) + '&source=' + encodeURIComponent(location.host) + '" title="pubblica questo articolo su LinkedIn" >pubblica questo articolo su LinkedIn</a>');

  $('li#stumbleupon').html('<a href="http://www.stumbleupon.com/submit?url=' + encodeURIComponent(location.href) + '%26title%3D' + encodeURIComponent(document.title) + '" title="pubblica questo articolo su StumbleUpon">pubblica questo articolo su StumbleUpon</a>');

  $('li#digg').html('<a href="http://www.digg.com/suubmit?url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)+'&bodytext='+encodeURIComponent(document.title)+'&media=news&topic=apple" title="pubblica questo l&apos;articolo su Digg">pubblica questo articolo su Digg</a>');
  
});
