$(document).ready(function() {


$(".nav-links li").mouseenter(function() {$(this).children(".sub-nav").addClass("drop-visible");});
$(".nav-links li").mouseleave(function() {$(this).children(".sub-nav").removeClass("drop-visible");});


$(".mobile-nav li").click(function() {$(this).children(".mobile-sub-nav").toggleClass("drop-visible");});


$(".mobile-expand").click(function() {$(".mobile-nav-modal").fadeIn("fast");});
$(".mobile-close").click(function() {$(".mobile-nav-modal").fadeOut("fast");});


$(".search-button").click(function() { $(".search-modal").fadeIn("fast", function() {$(".central-search").focus();}); });
$(".search-close").click(function() {$(".search-modal").fadeOut("fast");});


$(document).keyup(function(e) {
     if (e.keyCode == 27) { // escape key maps to keycode `27`
       $(".modal").fadeOut("fast");
    }
});

resize_video();



$(".vertical-spacing").each(function() {
	var height_to = $(this).height();
	$(this).css("margin-top","-" + (height_to/2) + "px");
});

$(window).resize(function() {
		$(".vertical-spacing").each(function() {
			var height_to = $(this).height();
			$(this).css("margin-top","-" + (height_to/2) + "px");
		});
		
		resize_video();
});
	



$(".form-call").click(function() {

	var form_url = $(this).data('form-url');

	$(".form-overlay").fadeIn();
	
	$(".form").load(form_url);

});



$(".form-close").click(function() {
	$(".form-overlay").fadeOut(400, function() {$(".form").html("")});
	$(".form-alt-overlay").fadeOut(400, function() {$(".form").html("")});
	$(".form-share-overlay").fadeOut(400, function() {$(".form").html("")});
});

$(".form-close-button").click(function() {
	$(".form-overlay").fadeOut(400, function() {$(".form").html("")});
	$(".form-alt-overlay").fadeOut(400, function() {$(".form").html("")});
	$(".form-share-overlay").fadeOut(400, function() {$(".form").html("")});
});

});




function resize_video() {

	$('.video-resize').each(function() {

		player_width = $(this).width();

		player_height = ((player_width*56.25)/100);

		$(this).height(player_height);
	
	});

}