// JavaScript Document
function bindCalendars () {
	$('.date-pick').each (function () {
		theid = $(this).attr('id'); 
		if (theid.indexOf('start-date') >= 0) {
			theendid = theid.replace('start-date','end-date');
			$('#'+theid).bind(
					'dpClosed', function(e, selectedDates) {
						var d = selectedDates[0];
						if (d) {
							d = new Date(d);
							$('#'+theendid).dpSetStartDate(d.addDays(1).asString());
						}
					}
			);
		} else {
			thestartid = theid.replace('end-date','start-date');
			$('#'+theid).bind(
					'dpClosed', function(e, selectedDates) {
						var d = selectedDates[0];
						if (d) {
							d = new Date(d);
							$('#'+thestartid).dpSetEndDate(d.addDays(-1).asString());
						}
					}
			);
		}
	});
}