/**
 * Populates the check out date.
 * @param theForm - the form containing the check out date.
 */
function populateCheckOut(theForm)
{
	if(theForm.checkInDate.selectedIndex != 0 && theForm.checkInMonthYear.selectedIndex != 0) {
		if ((theForm.checkOutDate.selectedIndex == 0) ||
			(theForm.checkOutMonthYear.selectedIndex == 0) ||
			(theForm.checkOutMonthYear.selectedIndex < theForm.checkInMonthYear.selectedIndex) ||
			((theForm.checkOutMonthYear.selectedIndex == theForm.checkInMonthYear.selectedIndex) &&
			 (theForm.checkOutDate.selectedIndex <= theForm.checkInDate.selectedIndex))) {
			var monthYear= theForm.checkInMonthYear.value;
			var month = monthYear.substring(0,monthYear.length-4);
			var year = monthYear.substring(monthYear.length-4);
			var date = theForm.checkInDate.selectedIndex;
			var outDateObj = new Date(year, month, date+1);
			var year = outDateObj.getYear();

			if(year.toString().length == 3)
				year = 2000 + (outDateObj.getYear() % 100);
			theForm.checkOutMonthYear.value = "" + outDateObj.getMonth() + year;

			//We have set the checkOutMonthYear, now see how to set the date field
			if((theForm.checkOutMonthYear.selectedIndex != theForm.checkInMonthYear.selectedIndex) ||
				(outDateObj.getDate() > theForm.checkOutDate.selectedIndex)) {
				theForm.checkOutDate.selectedIndex = outDateObj.getDate();
			}
		}
	}
}