$(document).ready(function() {		
	var CheckCheckIn = function(){
		$(".error", $("#checkin").parent()).remove();
		if(!CheckInput( $("#checkin"), 'alphanumeric', 1, 'Checkin is required')) {
			$("#popupContact").css({height:"200px"});
		return false;
		}else{ $("#popupContact").css({height:"170px"}); return true };		
	};
	
	var CheckCheckOut = function(){
		$(".error", $("#checkout").parent()).remove();
		if(!CheckInput( $("#checkout"), 'alphanumeric', 1, 'Checkout is required')){
			$("#popupContact").css({height:"200px"});
			return false;			
		}else{
			$("#popupContact").css({height:"150px"});
			return true;
		}
	}
	
	$("#checkin").change(CheckCheckIn);
	$("#checkout").change(CheckCheckOut);	
	
	function CheckForm(){					
			var ret = true;						
			if(!CheckCheckIn()) ret = false;
			if(!CheckCheckOut()) ret = false;			
			return ret;		
	}
	
	
	function ajax_book(){		
		$('form#frm_book').ajaxSubmit({
			   complete: function(r){
				$("#response").html(r.responseText)
				$("#response").fadeIn();	
			   }
		}); 	
		
	}
	
	$("#check_book").click(function(){
		if(CheckForm()== true){
			ajax_book();
		}
		return false;							
	});
	
	$("#checkin").datepicker({changeMonth: true, changeYear: true, showButtonPanel: true, minDate: '+d' });//$("#checkout").datepicker();
	$("#checkout").datepicker({changeMonth: true, changeYear: true, showButtonPanel: true, minDate: '+d'});	
}); 