$(document).ready(function($) {
  $(".valForm").val("true");
  
  landscape = new rockSlide("#landscape", "fade", 700, 5000);
  $(".arrow.left.landscape").click(function(){
    landscape.previous();
  });
  $(".arrow.right.landscape").click(function(){
    landscape.next();
  });
  
  portrait = new rockSlide("#portrait", "fade", 700, 5000);
  $(".arrow.left.portrait").click(function(){
    portrait.previous();
  });
  $(".arrow.right.portrait").click(function(){
    portrait.next();
  });
  
  if($(window).width() <= 1024){
    $(".pageAnimation img").animate({width: "100%"}, {duration: 10000, easing: "linear" });
  }
  
  if($(window).width() < 768){
    $(window).scroll(function(){
      $(".top").hide();
      if($(window).scrollTop() > 50){
        $(".top").show();
      }
        
      var windowBottom = $(this).scrollTop() + $(this).innerHeight() + 200;
      $(".fade").each(function() {
        /* Check the location of each desired element */
        var objectBottom = $(this).offset().top + $(this).outerHeight();
        
        /* If the element is completely within bounds of the window, fade it in */
        if (objectBottom < windowBottom) { //object comes into view (scrolling down)
          if ($(this).css("opacity")==0) {$(this).fadeTo(500,1);}
        } else { //object goes out of view (scrolling up)
          //if ($(this).css("opacity")==1) {$(this).fadeTo(500,0);}
        }
      });
    }).scroll(); //invoke scroll-handler on page-load
  }
});

var menuExpanded = false;
function toggleMenu() {
  if (menuExpanded) {
    $(".menuItem").fadeOut();
    menuExpanded = false;
  } else {
    $(".menuItem:not(.homeButton)").fadeIn();
    menuExpanded = true;
  }
}