var myDate = new Date(); 
var nextyear = (myDate.getFullYear() + 1);

$(document).ready(function(){
	
	// validate signup form on keyup and submit
	$("#bookingForm").validate({
		rules: {
			formname: "required",
			formemail: {
				required: true,
				email: true
			}
		},
		messages: {
			formname: "Please enter your name",
			lastname: "Please enter your lastname"
		}
	});
	
	
	$('#linkedStartDates').datepicker({ 
	    buttonImage: 'images/calendar.png',
	    buttonImageOnly: true, 
	    minDate: new Date(), 
	    maxDate: new Date(nextyear, 12 - 1, 31), 
	    beforeShow: readStartLinked, 
	    onSelect: updateStartLinked 
	}); 

	/*$('#linkedEndDates').datepicker({
	    buttonImage: 'images/calendar.png',
	    buttonImageOnly: true, 
	    minDate: new Date(), 
	    maxDate: new Date(nextyear, 12 - 1, 31), 
	    beforeShow: readEndLinked, 
	    onSelect: updateEndLinked 
	}); */
	
	$('#selectStartMonth, #selectStartYear').change(checkStartLinkedDays); 
});

// Prepare to show a date picker linked to three select controls 
function readStartLinked() { 
    $('#linkedStartDates').val( 
        $('#selectStartMonth').val() + '/' + 
        $('#selectStartDay').val() + '/' +  
        $('#selectStartYear').val() 
    ); 
    return {}; 
} 
 
// Update three select controls to match a date picker selection 
function updateStartLinked(date) { 
    $('#selectStartMonth').val(date.substring(0, 2)); 
    $('#selectStartDay').val(date.substring(3, 5)); 
    $('#selectStartYear').val(date.substring(6, 10)); 
} 
 
 
// Prevent selection of invalid dates through the select controls 
function checkStartLinkedDays() { 
    var daysInMonth = 32 - new Date($('#selectStartYear').val(), 
        $('#selectStartMonth').val() - 1, 32).getDate(); 
        $('#selectStartDay option').attr('disabled', ''); 
        $('#selectStartDay option:gt(' + (daysInMonth - 1) +')').attr('disabled', 'disabled'); 
    if ($('#selectStartDay').val() > daysInMonth) { 
        $('#selectStartDay').val(daysInMonth); 
    } 
} 

// validate the contact form when it is submitted
//$("#bookingForm").validate();



