// When the page is ready
$(document).ready(function(){
  $("#research .abstract").hide();
  $("#talks .files").hide();
  $("#talks .abstract").hide();
  $(".bibtex").hide();

  $("#research.content li .actions")
    .append("<a class='toggle-abstract' href='' title='Show/Hide the Abstract'>Abstract</a>");
  $("#research.content li .actions")
    .append("<a class='toggle-bibtex' href='' title='Show/Hide the BibTeX'>BibTeX</a>");
  
  $(".actions a.toggle-abstract").click(function(event){
    $(this).parents("div").next("p.abstract").toggle("slow");
    
    // Stop the link click from doing its normal thing
    return false;
  });

  $(".actions a.toggle-bibtex").click(function(event){
    $(this).parents("div").next("p.abstract").hide("slow").next("p.bibtex").toggle("slow");
		return false;
	});

  $("#paper-info a.toggle-bibtex").click(function(event){
    $(this).next("p.bibtex").toggle("slow");
		return false;
	});

	
  $("#talks.content li .actions")
    .append("<a class='toggle-talk-abstract' href='' title='Show/Hide the abstract'>Abstract</a>");
  $("#talks.content li .actions")
    .append("<a class='toggle-talk-files' href='' title='Show/Hide the files'>Files</a>");
  $(".actions a.toggle-talk-files").click(function(event){
    $(this).parents("div").next(".files").toggle("slow");
    return false;
  });
  $(".actions a.toggle-talk-abstract").click(function(event){
    $(this).parents("div").next(".files").next(".abstract").toggle("slow");
    return false;
  });

	
});
