$(document).ready(function() {
	
	
	
    /*
     *
     * Image gallery initialization */
	
    $(".image-gallery a[rel*=lightbox], .element a[rel*=lightbox]").lightBox({ });
	
	
    /*
     *
     * Datepicker initialization */
	
    $("#date").datepicker({
	showOn: 'button',
	buttonImage: 'images/calendar.gif',
	buttonImageOnly: true,
	showAnim: 'fadeIn'
    });
	
	
    /*
     *
     * Form actions */
	
    $("#clear-form").click(function() {
	$("#name").val('');
	$("#email").val('');
	$("#subject").val('');
	$("#message").val('');
	$("#notes").val('');
	$("#time-hh").val('');
	$("#time-mm").val('');
	$("#date").val('');
	$("#phone").val('');
	$("#party-size").val('');
	return false;
    });
	
	
    /*
     *
     * Search bar */
	
    $("#search").click(function() {
	$("#search").val('');
    });
	
    $("#search").focusout(function() {
	if ($("#search").val() == '' ) {
	    $("#search").val('Search ...');
	}
		
    });


    /*
     * Contact form - AJAX call */
	
    $('#send-email').click(function() {
	$.post('lib/email.php', {
	    name: $('#name').val(),
	    email: $('#email').val(),
	    subject: $('#subject').val(),
	    message: $('#message').val()
	}, function(data) {
	    var response = '<div class="output-messages">'+ data +'</div>';
	    $('#contact-form div.output-messages').remove();
	    $('#contact-form').prepend(response);
	})
	return false;
    });

    /*
     * Reservations form - AJAX call */

    $('#send-reservation').click(function() {
	$.post('lib/reservations.php', {
	    partySize: $('#party-size').val(),
	    date: $('#date').val(),
	    timeHour: $('#time-hh').val(),
	    timeMinute: $('#time-mm').val(),
	    mealType: $('#meal-type').val(),
	    name: $('#name').val(),
	    email: $('#email').val(),
	    phone: $('#phone').val(),
	    notes: $('#notes').val()
	}, function(data) {
	    var response = '<div class="output-messages">'+ data +'</div>';
	    $('#reservations-form div.output-messages').remove();
	    $('#reservations-form').prepend(response);
	})
	return false;
    });
    
    
});
