
// get dates for search boxes

function loadDates()
{
	var calendar = new Date();
	var calendar2 = new Date();
	var cal
	var cal2
    var date;  
	var date2;  
	var month;  
	var month2;  
	var year; 
	var year2; 
	//Here is the variable to change for to advance the arrival Date
	var advanceArrival = 21;   
	//Here is the variable to change for to advance the departure Date  
	var advanceDeparture = 23; 

	//Set the arrival Days

	calendar.setDate(calendar.getDate()+ advanceArrival);
	date = calendar.getDate();
	month = calendar.getMonth();
	year = calendar.getYear();
	//Set the Departure Days
	calendar2.setDate(calendar2.getDate()+advanceDeparture); 
	date2 = calendar2.getDate();
	month2 = calendar2.getMonth();
	year2 = calendar2.getYear();
	document.forms['frm_Search'].arrivalMonth.value=month + 1;
	document.forms['frm_Search'].arrivalDay.value=date;
	document.forms['frm_Search'].arrivalYear.value=year;
	document.forms['frm_Search'].departureMonth.value=month2 + 1;
	document.forms['frm_Search'].departureDay.value=date2;
	document.forms['frm_Search'].departureYear.value=year2;
	
}

function loadDates2()
{
	var calendar = new Date();
	var calendar2 = new Date();
	var cal
	var cal2
	var date;
	var date2;
	var month;
	var month2;
	var year;
	var year2;
	//Here is the variable to change for to advance the arrival Date
	 var advanceArrival = 21; 
	//Here is the variable to change for to advance the departure Date
	 var advanceDeparture = 23; 
	//Set the arrival Days
	calendar.setDate(calendar.getDate()+ advanceArrival);
	date = calendar.getDate();
	month = calendar.getMonth();
	year = calendar.getYear();
	//Set the Departure Days
	calendar2.setDate(calendar2.getDate()+advanceDeparture); 
	date2 = calendar2.getDate();
	month2 = calendar2.getMonth();
	year2 = calendar2.getYear();
	document.forms['frm_Search2'].arrivalMonth.value=month + 1;
	document.forms['frm_Search2'].arrivalDay.value=date;
	document.forms['frm_Search2'].arrivalYear.value=year;
	document.forms['frm_Search2'].departureMonth.value=month2 + 1;
	document.forms['frm_Search2'].departureDay.value=date2;
	document.forms['frm_Search2'].departureYear.value=year2;
}

function loadDates3()
{
	var calendar = new Date();
	var calendar2 = new Date();
	var cal
	var cal2
    var date;  
	var date2;  
	var month;  
	var month2;  
	var year; 
	var year2; 
	//Here is the variable to change for to advance the arrival Date
	var advanceArrival = 21;   
	//Here is the variable to change for to advance the departure Date  
	var advanceDeparture = 23; 

	//Set the arrival Days

	calendar.setDate(calendar.getDate()+ advanceArrival);
	date = calendar.getDate();
	month = calendar.getMonth();
	year = calendar.getYear();
	//Set the Departure Days
	calendar2.setDate(calendar2.getDate()+advanceDeparture); 
	date2 = calendar2.getDate();
	month2 = calendar2.getMonth();
	year2 = calendar2.getYear();
	document.forms['frm_Search'].departureMonth.value=month;
	document.forms['frm_Search'].departureDay.value=date;
	document.forms['frm_Search'].departureYear.value=year;
	document.forms['frm_Search'].returnMonth.value=month2;
	document.forms['frm_Search'].returnDay.value=date2;
	document.forms['frm_Search'].returnYear.value=year2;
}

function loadDates4()
{
	var calendar = new Date();
	var calendar2 = new Date();
	var cal
	var cal2
	var date;
	var date2;
	var month;
	var month2;
	var year;
	var year2;
	//Here is the variable to change for to advance the arrival Date
	 var advanceArrival = 21; 
	//Here is the variable to change for to advance the departure Date
	 var advanceDeparture = 23; 
	//Set the arrival Days
	calendar.setDate(calendar.getDate()+ advanceArrival);
	date = calendar.getDate();
	month = calendar.getMonth();
	year = calendar.getYear();
	//Set the Departure Days
	calendar2.setDate(calendar2.getDate()+advanceDeparture); 
	date2 = calendar2.getDate();
	month2 = calendar2.getMonth();
	year2 = calendar2.getYear();
	document.forms['frm_Search2'].pickUpMonth.value=month;
	document.forms['frm_Search2'].pickUpDay.value=date;
	document.forms['frm_Search2'].pickUpYear.value=year;
	document.forms['frm_Search2'].dropOffMonth.value=month2;
	document.forms['frm_Search2'].dropOffDay.value=date2;
	document.forms['frm_Search2'].dropOffYear.value=year2;
}

function loadDates5()
{
	var calendar = new Date();
	var calendar2 = new Date();
	var cal
	var cal2
	var date;
	var date2;
	var month;
	var month2;
	var year;
	var year2;
	//Here is the variable to change for to advance the arrival Date
	 var advanceArrival = 21; 
	//Here is the variable to change for to advance the departure Date
	 var advanceDeparture = 23; 
	//Set the arrival Days
	calendar.setDate(calendar.getDate()+ advanceArrival);
	date = calendar.getDate();
	month = calendar.getMonth();
	year = calendar.getYear();
	//Set the Departure Days
	calendar2.setDate(calendar2.getDate()+advanceDeparture); 
	date2 = calendar2.getDate();
	month2 = calendar2.getMonth();
	year2 = calendar2.getYear();
	document.forms['frm_Search5'].arrivalMonth.value=month + 1;
	document.forms['frm_Search5'].arrivalDay.value=date;
	document.forms['frm_Search5'].arrivalYear.value=year;
	document.forms['frm_Search5'].departureMonth.value=month2 + 1;
	document.forms['frm_Search5'].departureDay.value=date2;
	document.forms['frm_Search5'].departureYear.value=year2;
}

// Checks if browser is Netscape 2.0x since the options array properties don't work with Netscape 2.0x
function isBrowserSupp() {
	// Get the version of the browser
	version =  parseFloat( navigator.appVersion );
	if ( ( version >= 2.0 ) && ( version < 2.1 ) && ( navigator.appName.indexOf( "Netscape" ) != -1 ) ) {
		return false;
	}else {
		return true;
	}
	return true;
}

function isLeapYear(yrStr){
	var leapYear=false;
	var year = parseInt(yrStr, 10);
	// every fourth year is a leap year
	if (year%4 == 0){
		leapYear=true;
		// unless it's a multiple of 100
		if (year%100 == 0)
			{
			leapYear=false;
			// unless it's a multiple of 400
			if (year%400 == 0){
				leapYear=true;
			}
		}
	}
	return leapYear;
}

function getDaysInMonth(mthIdx, YrStr)
{
	// all the rest have 31
	var maxDays=31
	// expect Feb. (of course)
	if (mthIdx==1){
		if (isLeapYear(YrStr)){
			maxDays=29;
		}else{
			maxDays=28;
		}
	}
	// thirty days hath...
	if (mthIdx==3 || mthIdx==5 || mthIdx==8 || mthIdx==10){
		maxDays=30;
	}
	return maxDays;
}

//the function which does some magic to the date fields
// return non-zero if it is the last day of the month
function adjustDate(mthIdx, Dt){
	var value=0;
	var today = new Date()
	var theYear = parseInt(today.getYear(),10)
	if (mthIdx < today.getMonth()) {
		theYear = (parseInt(today.getYear(), 10) + 1)
	}
	if(theYear<100){
		theYear = "19" + theYear
	}else{
		if((theYear-100) < 10){
			theYear = "0" + (theYear-100)
		}else{
			theYear = (theYear-100)+""
		}
		theYear = "20" + theYear
	}
	var numDays=getDaysInMonth(mthIdx, theYear);
	if (mthIdx==1){
		if (Dt.options.selectedIndex + 1 < numDays){
			return 0;
		}else{
			Dt.options.selectedIndex=numDays - 1;
			//check for leap year
			if (numDays==29){
				return 99;
			}else{
				return 1;
			}
		}
	}
	if (Dt.options.selectedIndex + 1 < numDays){
		value=0;
	}else{
		if (Dt.options.selectedIndex + 1 > numDays){
			Dt.options.selectedIndex--;
			value=3;
		}else{
			//index is 31 or 30
			value=2;
		}
	}
	return value;
}

//changes departure month when arrival month is changed
function amadChange(inM,inD,inY,outM,outD,outY){
	if (!isBrowserSupp()){
			return;
	}
	var res = adjustDate(inM.options.selectedIndex, inD);
	if (res != 0){
	   outD.options.selectedIndex=0;
	   if (outM.options.selectedIndex==11){
			outM.options.selectedIndex=0
	   }
	   else{
			outM.options.selectedIndex=inM.options.selectedIndex + 1;
	   }
	}else{
		outM.options.selectedIndex = inM.options.selectedIndex;
		outD.options.selectedIndex = inD.options.selectedIndex+1;
	}
	return;
}

function dmddChange(outM,outD,outY){
	if (!isBrowserSupp()){
		return;
	}
	adjustDate(outM.options.selectedIndex,outD);
	return;
}

 function validateAir(){
	alert
	if(document.forms['AvailRequester'].destinationCity.value == "Orlando, FL, US"){
		window.document.forms['AvailRequester'].destinationCity.value='MCO';
	}
	}
