
jQuery(document).ready(function() {

//    Date.format = 'yyyy-mm-dd';
  
	jQuery.getScript('http://static.europenethotels.com/script/jquery.js', function() {

		jQuery.getScript('http://static.europenethotels.com/script/jquery.ui.js', function() {
		  
			jQuery.getScript('http://static.europenethotels.com/script/jquery.datepicker.js', function() {
			
				  date  = new Date();
				  day   = (date.getDate()<10) ? '0'+date.getDate() : date.getDate();
				  month = (date.getMonth()<9) ? '0'+(date.getMonth()+1) : date.getMonth()+1;
				  $('.date-pick').datePicker({startDate: day+'/'+month+'/'+date.getFullYear(), endDate: '31/12/'+(date.getFullYear()+5), clickInput: true});
				  $('#checkin').bind('dpClosed',
					function(e, selectedDates) {
					  var ci = selectedDates[0];
					  var co = $('#checkout').dpGetSelected();
					  if (ci>=co) {
						ci = new Date(ci);
						$('#checkout').dpSetSelected(ci.addDays(1).asString()).val(ci.asString());
					  }
					}
				  );
				  $('#checkout').bind('dpClosed',
					function(e, selectedDates) {
					  var co = selectedDates[0];
					  var ci = $('#checkin').dpGetSelected();
					  if (co<=ci) {
						co = new Date(co);
						$('#checkin').dpSetSelected(co.addDays(-1).asString()).val(co.asString());
					  }
					}
				  );
				
			});
		});
	});
});