// JavaScript Document
$(document).ready(function(){
	$('#checkin').datepicker({minDate:0, dateFormat:"dd/mm/yy"});
	$('#checkout').datepicker({minDate:0, dateFormat:"dd/mm/yy"});
/*	$("#location").autocomplete("../inc/auto-complete.php", {
			width: 180,
			scroll:true,
			formatResult: function(data,value) {
				return value.split(";")[3];
			}	
			
		});
*/
		$('#frmSearch form').submit(function() {
			var noNights = (($("#checkout").datepicker('getDate') - $("#checkin").datepicker('getDate')) / 1000 / 60 / 60 / 24 );
			if ($("#checkin").val() !='' && $("#checkout").val() !='' && noNights < 0) {
				alert('CheckIn date can not be greater than CheckOut date');
				return false;
			} else if ($("#checkin").val() !='' && $("#checkout").val() !='' && noNights ==0) {
				alert('CheckIn and CheckOut can not be on the same day');
				return false;
			}
		});
});


/*function checkLocation() {
	if (document.frmSearch.location.value=="") {
		alert('Please correct the following problems to search:\n- You must select a location name from the list.');
		return false;
	}	
}
*/


