jQuery(document).ready(function($) {
   $("a[rel^='prettyPhoto']").prettyPhoto({animationSpeed:'fast'});
   $(".alt-list li:even").css("background-color","#eaeaea");
   $(".alt-list .next_holiday").css("background-color","#f99");

   $("a[rel^='show_contact_staff']").click( function() {
      animateStaffContact();
   });

   //Insert anchor/hash on all h1 title in content

   $("h1:first").before("<a name='top'></a>");

   $(".toc").text("");
   $(".entry .content h1").each( function(index) {
      var hashText = $(this).text().split(" ").join("_");
      hashText = hashText.toLowerCase();
      $(this).before("<a name='" + hashText + "'></a>");
      $(this).after("<span>[ <a href='#top'>Goto TOP</a> ]</span>");
      $(".toc").append("<li><a href='#" + hashText + "'>" + $(this).text() + "</a></li>");
   });
   $(".toc").html("<b>CONTENTS</b><ul>" + $(".toc").html() + "</ul>");

   $("a[href='#top']").click( function() {
      $("html, body").animate({scrollTop:0}, 1500);
   });

   $(".collapse").click( function() {
      alert("hi");
      $(this).children().hide("slow");
   });

   $("ul.economy_figure li").click( function() {
      if( $(this).children("ul").is(":hidden") ) {
         $("ul.economy_figure li").css("font-weight","normal");
         $("ul.economy_figure ul").hide("normal");
         $(this).css("font-weight","bold");
         $(this).children("ul").slideToggle("slow");
      }
      else {
         $(this).children("ul").slideToggle("normal");
         $(this).css("font-weight","normal");
      }
   });
});

function animateStaffContact() {  
   if( jQuery("#contact_staff").is(":hidden") ) {
      jQuery("#staff_list").slideUp('slow', function() {
         jQuery("#contact_staff").slideDown();
         //jQuery("a[rel^='show_contact_staff']").html("List of Embassy Staff")
      });
   }
   else {
      jQuery("#contact_staff").slideUp('slow', function() {
         jQuery("#staff_list").slideDown();
         //jQuery("a[rel^='show_contact_staff']").html("Email Embassy Staff")
      });      
   }
}


