$(document).ready(function()
{
	// Datepicker
	$('.datepicker').datepicker({
		inline:			true,
		dateFormat:		'dd-mm-yy'
//		showOn:			'both',
//		buttonImage:	'templates/css/vader/images/calendar.gif'
	});

	$("form#contactForm").validate();

	$("#reset").click(function()
	{
		document.getElementById('contactForm').reset();
	});
  
	$("#submit").click(function()
	{
		if( $("form#contactForm").valid() ) {
			$("form#contactForm").fadeTo("slow", 0.30, function()
			{
				$.ajax(
				{
					type: "POST",
      	  			url:  "plugins/sendmailRezerwacja.php",
      	  			data: { 
  	    				firstname:	$("#firstname").val(),
  	    				lastname:	$("#lastname").val(),
  	    				company:	$("#company").val(),
  	    				phone:		$("#phone").val(),
  	    				email:		$("#email").val(),
  	    				dateIn:		$("#dateIn").val(),
  	    				dateOut:	$("#dateOut").val(),
  	    				persons:	$("#persons").val(),
  	    				rooms:		$("#rooms").val(),
  	    				room_type:	$("#room_type").val(),
  	    				//time:		$("#time").val(),
  	    				message:	$("#message").val() 
  	    			},
  	    			success: function(msg) {
  	    				$("div#wrap").html('<p>' + msg + '</p>');
  	    				$("form#contactForm").fadeOut("slow");
  	    			},
  	    			error: function (XMLHttpRequest, textStatus, errorThrown) {
  	    				$("div#wrap").html('<p>Error</p>');
  	    				$("form#contactForm").fadeOut("slow");
  	    			}
				});
			});
		}
		else {
			alert("Error");
			return false;
		}
	});
});

