$(document).ready(function() {
  $('.fancybox').fancybox({
    'zoomOpacity'			: true,
    'overlayShow'			: true,
    'zoomSpeedIn'			: 500,
    'zoomSpeedOut'		: 500,
    'easingIn'				: 'easeOutBack',
    'easingOut'				: 'easeInBack',
    'transitionIn'    : 'elastic',
    'transitionOut'   : 'elastic',
    'centerOnScroll'  : 'true'
  });

	$('#subscribe-form .sign-up').each(function() {
		searchText = $(this).attr('title');

		$(this).focus(function() {
			if($(this).val()==searchText) {
				$(this).val('');
			}
		});

		$(this).blur(function() {
			if(empty($(this).val())) {
				$(this).val(searchText);
			}
		});
	});

	$("#date").datepicker({dateFormat: 'dd/mm/yy', minDate: 0});

  $("#subscribe").change(function() { toggleInterests() });
  toggleInterests();
});

function toggleInterests() {
  if ($('#subscribe').is(':checked')) {
    $('.mailchimp_interests:input').removeAttr('disabled');
  } else {
    $('.mailchimp_interests:input').attr('disabled', true);
  }
}

function empty(str) {
	if (str === "" || str === 0 || str === "0" || str === null || str === false || typeof str === 'undefined') {
		return true;
	}
	if (typeof str == 'object') {
		var key;
		for (key in str) {
			return false;
		}
		return true;
	}
	return false;
}