
function a() {
  var anchor = self.document.location.hash.substring(1);
  if(anchor == '')
    return false;
  else
    return anchor;
}

function urls() {
  var furl = window.location.href.split('/');
  return furl.length;
}

$(document).ready(function() {
    $("#toc").hide();
    $("#toggle").addClass("active");
    $("#tgl").click(function() {

        //alert($("#toc").css('display'));
        var s = $("#toc").css('display');
        $("#toggle").toggleClass("active");
        if(s == "" || s == undefined || s == 'none') {
            $("#toc").slideDown();
        } else {
            $("#toggle").removeClass("active");
            $("#toc").slideUp();
        };
        return false;
    });

    $(".blog").each(function() {
      var all = $(this);
        $(this).find('.topic').click(function() {
          if($(all).find('.body').css('display') == 'none') {
              $(all).find('.body').slideDown();
              $(all).find('.date').show();
          } else {
              $(all).find('.body').slideUp();
              $(all).find('.date').hide();
          }
          //$(all).find('.permalink').toggle();

        });
    });

    $(".post > .blog").each(function() {
      var all = $(this);
        $(this).hover(
         function () {
           $(all).find('.permalink').show();
         },
         function (){
           $(all).find('.permalink').hide();
         }

      )});



  if(urls() == 4) {
      $(".blog > .body:gt(0)").hide();
      //$(".blog > .permalink").hide();
      $(".blog > .date:gt(0)").hide();
  }


  if(a()) {
    var telem = $("#" + a());
    $(telem).highlightFade('#FF6519');
  }


});
