// JavaScript Document
$(document).ready(function(){

	// lightbox
	$('a[rel^=lightbox]').lightBox();
	
	$("a.fancybox").click(function(event) {
		event.preventDefault();
		openVideo();	
	});

	$('.navitem').each(function() {
		$(this).mouseenter(function() {
			$(this).children('.dropdown').fadeIn(200);
		});
		$(this).mouseleave(function() {
			$(this).children('.dropdown').fadeOut(100);
		});
	});

	$('#newsletter_form').submit(function(){
		if( !validateFormField("#nf_email", "Please enter your email address.") )
			return false;
		return true;
	});
	
	

});

function validateFormField(name, message) {
	if( $(name).val() == "" ) {
		alert(message);
		$(name).focus();
		return false;
	}
	return true;
}

//we have to do some custom-ness because fancybox won't behave with embedded videos
function openVideo() {
	$.fancybox($("#video_content").html(), {
		'autoDimensions': true
	});
}
