

$(document).ready(function(){

  $(".button").find("a").click(function(){
    $(this).parent().find("form:visible").slideUp("slow");
    $(this).parent().find("form:hidden").slideDown("slow");
    return false;    
  });
  var mend = $('#more-endorsements'); 
  mend.hide();
  $('#many-more').find('a').click(function(){
    $('#many-more').slideUp();
    $('#more-endorsements').slideDown();
    return false;
  });
  mend.find('a').click(function(){
    $('#more-endorsements').slideUp();
    $('#many-more').slideDown();
  });

// hide "events this week" box on homepage if there are no events scheduled
if ($('#home #week li').text() == "") {
  $('#week').hide();
  };  
});

/* -----------------------------------
   rotating home page items
   ----------------------------------- */
var image_count;
var current_image=0;

$(document).ready(function(){
  image_count = $("div.img-rotate").hide().size();
  $("div.img-rotate:eq("+current_image+")").show();
  setInterval(feature_rotate,10000); //time in milliseconds
});

function feature_rotate() {
  old_image = current_image%image_count;
  new_image = ++current_image%image_count;
  $("div.img-rotate:eq(" + new_image + ")").fadeIn("slow", function() {
    $("div.img-rotate:eq(" + old_image + ")").fadeOut("slow");
  });
}