$(document).ready( function() { 

	$('#sub-form').submit( function(ev) {

		try {
			$.fancybox({
				'type':				'iframe',
				'href':				$(this).attr('action') + '?' +  $("input[name=email]").val(),
				'width':			900,
				'height':			420,
				'title': 			"Newsletter Sign-up Confirmation",
				'titlePosition': 	"over",
				'transitionIn': 	'none',
				'transitionOut': 	'none'
			});
			return false;
		} catch (e) { }
		
	});
	
	try {
	
		$("#searchForm").submit( function(ev) {
			
			try {
			
				v1 = $('#destinationBox').val();
				v2 = $('#durationBox').val();
				v3 = $('#f1').val();
				
				if (v1 == "|" || v2 == "|" || v3 == "|") {
					
					$('#searchError').css('display','block');
					
					message = "There was a problem with your holiday search:\n";
					if (v1 == "|") 
						message += "<br /><b>You must select a destination</b>\n";
					if (v2 == "|")
						message += "<br /><b>You must select a trip duration</b>\n";
					if (v3 == "|")
						message += "<br /><b>You must select a departure airport</b>\n";
					
					$('#searchError').html(message);
					
					return false;
					
				}
			
			} catch (e) {
				alert(e.message);
				return false;
			}
			
		});
	
	} catch (e) {
		return false;
	}
	
});
