$(document).ready(function() {
    
    Cufon.replace('#logo h1, #content h1, #content h2, #content h3, #content h4, #content h5');
	
    /*
     *
     * Image gallery initialization */
	
    $(".image-gallery a[rel*=lightbox], .element a[rel*=lightbox]").lightBox({ });
	
    /*
     *
     * Datepicker initialization */	

	$.datepicker.regional['de'] = {
		closeText: 'schlie�en',
		prevText: '&#x3c;zur�ck',
		nextText: 'Vor&#x3e;',
		currentText: 'heute',
		monthNames: ['Januar','Februar','M�rz','April','Mai','Juni',
		'Juli','August','September','Oktober','November','Dezember'],
		monthNamesShort: ['Jan','Feb','M�r','Apr','Mai','Jun',
		'Jul','Aug','Sep','Okt','Nov','Dez'],
		dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
		dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
		dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
		weekHeader: 'Wo',
		dateFormat: 'dd.mm.yy',
		firstDay: 1,
		isRTL: false,
		showMonthAfterYear: false,
		yearSuffix: ''};
	$.datepicker.setDefaults($.datepicker.regional['de']);


    $("#date").datepicker({
	firstDay: 1,
	showOn: 'button',
	buttonImage: 'images/calendar.gif',
	buttonImageOnly: true,
	showAnim: 'fadeIn',
	dateFormat: 'dd/mm/yy'
    });

    /*
     *
     * 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) {
	    if ( data === 'Email sent !' ) {
		$("#clear-form").click();
	    }
	    var response = '<div class="output-messages">'+ data +'</div>';
	    $('#reservations-form div.output-messages').remove();
	    $('#reservations-form').prepend(response);
	})
	return false;
    });
    
    

});




