$(document).ready(function() {

// SMOOTH SCROLLING
  $('a[href*=#]').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') 
    && location.hostname == this.hostname) {
      var $target = $(this.hash);
      $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
      if ($target.length) {
        var targetOffset = $target.offset().top;
        $('html,body').animate({scrollTop: targetOffset}, 750);
        return false;
      }
    }
  });
	
// ADJUST SLIDE HEIGHT TO WINDOW HEIGHT
  // var windowHeight = $(window).height();
  // if(windowHeight < 600) {
  //   $("#wrapper section.slide").css('min-height', "600px");
  // }  else {
  //  $("#wrapper section.slide").css('min-height',((windowHeight - 150) + "px"));  
  // };
	
	$(window).scroll(function() {
		var offset = window.pageYOffset;

 // INTRO 
  	$('#first header').css({
  		"top" : (12+(offset/20))+"%"
  	});
  	
  	$('#firstImg').css({
  		"top" : 0 + (offset/1.5)
  	});


 // ABOUT CAMPMON 
  	$('#second section').css({
  		"top" : (-18.4+(offset/30))+"%"
  	});
  	
  	$('#ohfour').css({
  	  "top" : -209 + (offset/2.1)
  	});
	
  	$('#ohfive').css({
  	  "top" : -250 + (offset/2.0)
  	});

  	$('#ohsix').css({
  	  "top" : -294 + (offset/1.9)
  	});
  	
  	$('#ohseven').css({
  	  "top" : -342 + (offset/1.8)
  	});

  	$('#oheight').css({
  	  "top" : -392 + (offset/1.7)
  	});

  	$('#ohnine').css({
  	  "top" : -447 + (offset/1.6)
  	});

  	$('#ten').css({
  	  "top" : -507 + (offset/1.5)
  	});


 // UI DESIGNER
  	$('#third section').css({
  		"top" : (-75+(offset/25))+"%"
  	});

  	$('#thirdImg').css({
  		"top" : -2000 + (offset/1.5)
  	});
  	
  	$('#photoshopIcon').css({
  		"top" : -1160 + (offset/1.5)
  	});
  	$('#textmateIcon').css({
  		"top" : -1190 + (offset/1.4)
  	});
  	$('#csseditIcon').css({
  		"top" : -1220 + (offset/1.3)
  	});
  	$('#safariIcon').css({
  		"top" : -1240 + (offset/1.2)
  	});


 // WEB DESIGNER 
  	$('#fourth section').css({
  		"top" : (-75+(offset/35))+"%"
  	});
	
  	$('#fourthImg').css({
  		"top" : -1150 + (offset/2.5)
  	});		


  // HOW WE WORK
   	$('#fifth section').css({
   		"top" : (-60+(offset/55))+"%"
   	});

   	$('#fifthImg').css({
   		"top" : -2690 + (offset/1.5)
   	});

	});
	
	// VIDEO PLAYER
	  $('.videoLink').click(function() {
      $('.videoCurtain').fadeIn(250);
      $('.videoLarge').delay(300).fadeIn(500);
	    $('video').get(0).play();
	  });
	  
	  $('.videoCurtain').click(function() {
	    $('video').get(0).pause();
	    $('.videoLarge, #facebookModal, #applyModal').fadeOut(250);
	    $('.videoCurtain').delay(300).fadeOut(500);
	  });
	
  // FACEBOOK LIKE MODAL
	  $('#facebookLikeButton').click( function() {
      $('.videoCurtain').fadeIn(250);
	    $('#facebookModal').delay(300).fadeIn(500);
	  });
	  
	  $('#facebookModal span#closeWindow').click(function() {
  	  $('#facebookModal').fadeOut(250);
      $('.videoCurtain').delay(300).fadeOut(500);
    });
	
	// APPLY NOW BUTTON
	  $('#applyNowButton').click( function() {
      $('.videoCurtain').fadeIn(250);
	    $('#applyModal').delay(300).fadeIn(500);
	  });
	  
	  $('#applyModal span#closeWindow').click(function() {
  	  $('#applyModal').fadeOut(250);
      $('.videoCurtain').delay(300).fadeOut(500);
    });
	  
});


