$(document).ready(function(){

  //For movie statistics
  $('a.slideTrigger').click(function() {
    var id = $(this).attr('id');
    $('#slideContainer' + id).slideToggle("slow");
  });

  //for prettyPhoto
  $("a[rel^='prettyPhoto']").prettyPhoto({ show_title: false, overlay_gallery: false, allow_resize: true });

  //for donate button
  $("a#donate").bind("click", function() {
    $("#paypalform").submit();
  });

  //Scroll to top nicely
  $('a[href=#top]').click(function() {
    $('html, body').animate({scrollTop:0}, 'slow');
    return false;
  });

  //lock menubar to top on scroll
  //var top = $('#navbar-bottom-wide').offset().top - parseFloat($('#navbar-bottom-wide').css('marginTop').replace(/auto/, 0));
  //$(window).scroll(function (event) {
  //  // what the y position of the scroll is
  //  var y = $(this).scrollTop();
  
  //  // whether that's below the form
  //  if (y >= top) {
  //    // if so, ad the fixed class
  //    $('#navbar-bottom-wide').addClass('fixed');
  //  } else {
  //    // otherwise remove it
  //    $('#navbar-bottom-wide').removeClass('fixed');
  //  }
  //});


  //tablesorter for toilet paper
  //$("#toilet-data").tablesorter();

  //For silky smooth marquee - http://remysharp.com/2008/09/10/the-silky-smooth-marquee/
  //$('marquee').marquee();

  $("a.contact").toggle(
    function () {
      $("#contact").animate({height: "225px"}, {queue:false, duration: 1700, easing: 'easeOutBounce'})
    },
    function () {
      $("#contact").animate({height: "0px"}, {queue:false, duration: 1700, easing: 'easeOutBounce'})
    }
  );

  $("a.navmenu-more-link").toggle(
    function () {
      $("#navmenu-more").animate({height: "130px"}, {queue:false, duration: 600, easing: 'swing'});
    },
    function () {
      $("#navmenu-more").animate({height: "0px"}, {queue:false, duration: 600, easing: 'swing'});
    }
  );

  //$(".topMenuAction").click( function() {
  //  if ($("#openCloseIdentifier").is(":hidden")) {
  //    $("#slider").animate({
  //      marginTop: "-31px"
  //    }, 300 );
  //    //$("#topMenuImage").html('<img src="http://static.tumblr.com/fkm6sn6/0n9lb7jpq/topnavbutton.png" alt="Show Navigation"/>');
  //    $("#openCloseIdentifier").show();
  //  } else {
  //    $("#slider").animate({
  //      marginTop: "0px"
  //    }, 300 );
  //    //$("#topMenuImage").html('<img src="http://static.tumblr.com/fkm6sn6/0n9lb7jpq/topnavbutton.png" alt="Hide Navigation"/>');
  //    $("#openCloseIdentifier").hide();
  //  }
  //});

  $('a[rel=tipsy]').tipsy({fade: true, gravity: 'sw'});

  $(".topMenuAction").click( function() {
    if ($("#slider").css("margin-top") == "0px") {
      $("#slider").animate({
        marginTop: "-31px"
      }, 300 );
      //$("#topMenuImage").html('<img src="http://static.tumblr.com/fkm6sn6/0n9lb7jpq/topnavbutton.png" alt="Show Navigation"/>');
      $("#openCloseIdentifier").show();
    } else {
      $("#slider").animate({
        marginTop: "0px"
      }, 300 );
      //$("#topMenuImage").html('<img src="http://static.tumblr.com/fkm6sn6/0n9lb7jpq/topnavbutton.png" alt="Hide Navigation"/>');
      $("#openCloseIdentifier").hide();
    }
  });

}); 
