$.Require(["/scripts/special-offers/vlaCal.js","/css/stay/hotels/vlaCalendarOverlay.css"],function() {

	var todayAtMidnight=(new Date()).getDateAtFirst();
	
	$$(".vlaStartDate").each(function(item) {
		var self=$(item);
		var end=self.getParent("form").getElement(".vlaEndDate");
		self.calendar=new vlaDatePicker(self,{
			format:"m/d/y",
			twoDigitYear:false,
			alignX:"left",
			alignY:"bottom"/**/,
			offset:{x:0,y:-32},
			alternateHideFn:Browser.Engine.trident5,
			alternateShowFn:Browser.Engine.trident5,
			maxShownDate:todayAtMidnight.addMilliseconds(1000*60*60*24*336),//11 months from today
			minShownDate:todayAtMidnight,
			quickPickMonth:false,
			quickPickYear:false
		}).addEvent("pick",function(date,visible) {
			var startDate=new Date(self.value)
			var endDate=new Date(end.value)
			var now=new Date();
			now=new Date((now.getMonth()+1)+"/"+now.getDate()+"/"+now.getFullYear());//this gets todays date starting at midnight, instead of this exact second
			
			var param=new Date(date.month+"/"+date.day+"/"+date.year)
			//if the end/departure date is less than the newly selected start/arrival date...set it to blank
			if (endDate<param) end.calendar.setDate(param)
			
			//if they selected a start/arrival date before today (@ midnight), scoot them up to now
			if (now>startDate) {
				this.setDate(now)
				param=now;
			}
			
			//if end/departure date is blank or MM/DD/YYYY then set it to now+5days
			if (isNaN(endDate.getTime())) {
				var plus5days=1000*60*60*24*5
				plus5days=param.getTime()+plus5days
				end.calendar.setDate(new Date(plus5days))
			}
			
			//if the calendar is visible and we need to update a calendar overlay...do it
			if (visible&&typeof(cal)!="undefined")cal.updateCalendarFromInputBoxes.call(cal)
			
		});
	})
	$$(".vlaEndDate").each(function(item) {
		var self=$(item);
		var start=self.getParent("form").getElement(".vlaStartDate");
		self.calendar=new vlaDatePicker(self,{
			format:"m/d/y",
			twoDigitYear:false,
			alignX:"left",
			alignY:"bottom",
			offset:{x:0,y:-32},
			alternateHideFn:Browser.Engine.trident5,
			alternateShowFn:Browser.Engine.trident5,
			maxShownDate:new Date(todayAtMidnight.getTime()+(1000*60*60*24*336)),//11 months from today
			minShownDate:todayAtMidnight,
			quickPickMonth:false,
			quickPickYear:false
		}).addEvent("pick",function(date,visible) {
			if (new Date(start.value)>new Date(date.month+"/"+date.day+"/"+date.year)) this.setDate(new Date(start.value))
			if (visible&&typeof(cal)!="undefined")cal.updateCalendarFromInputBoxes.call(cal)
		});
	})
})