<!--
function getDateToday() {
	var today = new Date();
	var today_day = today.getDate();
	if(today_day < 10) {
		today_day = '0' + today_day;
	}
	var today_month = today.getMonth()+1;
	if(today_month < 10) {
		today_month = '0' + today_month;
	}
	var today_year = today.getYear();
//	----------------------------------------------------------------------
//	Update year for Mozilla and Netscape
//	----------------------------------------------------------------------
	if(today_year.toString().length < 4) {
//		alert("You must be using Mozilla or Netscape because the Year is messed up: "+today_year);
		today_year = today_year+1900;
//		alert("The year has been updated for Mozilla and Netscape: "+today_year);
	}
	return today_month + '/' + today_day + '/' + today_year;						 
}
// ----------------------------------------------------------------------
// Validation for all phone edits update page
// ----------------------------------------------------------------------
function valPhone(arg1) {
	if(isNaN(eval(arg1).value)) {
		eval(arg1).value = "";
		eval(arg1).focus();			
	}
}
// ----------------------------------------------------------------------
// Validation for all email
// ----------------------------------------------------------------------
function valEmail(arg1) {
	var email_reg_exp = /^[a-z][\w\.]*@[\w\.-]+\.[a-z]{2,3}/i;
	if(arg1 == '' || !email_reg_exp.test(arg1)) {
		return true;
	}
}
// ----------------------------------------------------------------------
// Validation for all dates
// ----------------------------------------------------------------------
function valDate(arg1) {
	var date = arg1.split('/');
	if((parseFloat(date[0]) == 2 && parseFloat(date[1]) == 29 && parseFloat(date[2])%4 > 0) || date.length != 3 || date[0].length != 2 || isNaN(date[0]) || date[0] < 1 || date[0] > 12 || date[1].length != 2 || isNaN(date[1]) || date[1] < 1 || date[1] > 31 || date[2].length != 4 || isNaN(date[2]) || date[2] < 1900) {
		return true;
	}
}
// ----------------------------------------------------------------------
// Validation for all time
// ----------------------------------------------------------------------
function valTime(arg1) {
	var time = arg1.split(':');
	if(time.length != 2 || time[0].length != 2 || isNaN(time[0]) || time[0] < 0 || time[0] > 24 || time[1].length != 2 || isNaN(time[1]) || time[1] < 0 || time[1] > 59) { 
		return true;
	}
}
// ----------------------------------------------------------------------
// Validation for all numbers
// ----------------------------------------------------------------------
function valNum(arg1,arg2) {
	if(arg1 == '' || isNaN(arg1) || arg1 < 0) {
		if(arg2 != null) {
			if(arg1 == 0) { 
				return true;
			}
		}
		else {
			return true;
		}
	}
}
// ----------------------------------------------------------------------
// Validation for logon page
// ----------------------------------------------------------------------
function valLogon() {
	var response = 'The following fields are required or have been incorrectly submitted:\n';
	with(document.member_logon) {
		if(un.value == '') {
			response += '\nID (Required)';
		}
		if(pw.value == '') {
			response += '\nPW (Required)';
		}
		if(response == 'The following fields are required or have been incorrectly submitted:\n') {
			return true;
		}
		else {
			alert(response);
			return false;
		}
	}
}
// ----------------------------------------------------------------------
// Validation for change password page
// ----------------------------------------------------------------------
function valChangePassword() {
	var response = 'The following fields are required or have been incorrectly submitted:\n';
	with(document.update_password) {
		if(pw.value == '' || pwc.value == '') {
			if(pw.value == '') {
				response += '\nPassword (Required)';
			}
			if(pwc.value == '') {
				response += '\nConfirm Password (Required)';
			}
		}
		else {
			if(pw.value != pwc.value) {
				response += '\nPasswords Do Not Match';
			}
		}
		if(response == 'The following fields are required or have been incorrectly submitted:\n') {
			return true;
		}
		else {
			alert(response);
			return false;
		}
	}
}
// ----------------------------------------------------------------------
// Validation for admin update page
// ----------------------------------------------------------------------
function valAdmin() {
	var response = 'The following fields are required or have been incorrectly submitted:\n';
	with(document.update_admin) {		
		var ph1 = ph11.value + ph12.value + ph13.value;
		var ph2 = ph21.value + ph22.value + ph23.value;
		var fax = fax1.value + fax2.value + fax3.value;		
		if(eun.value == '') {
			response += '\nUsername (Required)';
		}
		if(first_name.value == '') {
			response += '\nFirst Name (Required)';
		}
		if(last_name.value == '') {
			response += '\nLast Name (Required)';
		}	
		if(ph1.length < 10) {
			response += '\nPrimary Phone (Incomplete)';
		}
		if(ph2.length > 0 && ph2.length < 10) {
			response += '\nAlternate phone (Incomplete)';
		}	
		if(fax.length > 0 && fax.length < 10) {
			response += '\nFax (Incomplete)';
		}				
		if(valEmail(email.value)) {
			response += "\nEmail (Not a valid address)";			
		}		
		if(response == 'The following fields are required or have been incorrectly submitted:\n') {
			return true;
		}
		else {
			alert(response);
			return false;
		}
	}
}
// ----------------------------------------------------------------------
// Validation for adding of aircrafts on the manage page
// ----------------------------------------------------------------------
function valAddAircraft() {
	var response = 'The following fields are required or have been incorrectly submitted:\n';	
	with(document.add_aircraft) {
		if(aircraft_id.options[aircraft_id.selectedIndex].value == '1') {
			response += "\nAircraft (Required)";
		}
		if(response == 'The following fields are required or have been incorrectly submitted:\n') {
			return true;
		}
		else {
			alert(response);
			return false;
		}	
	}
}
// ----------------------------------------------------------------------
// Validation for aircraft update page
// ----------------------------------------------------------------------
function valAircraft() {
	var response = 'The following fields are required or have been incorrectly submitted:\n';	
	with(document.update_aircraft) {
		if(tail_number.value == '') {
			response += "\nTail Number (Required)";
		}
		if(serial_number.value == '') {
			response += "\nSerial Number (Required)";
		}		
		if(valNum(rate_mile.value)) {
			response += "\nRate [Mile] (Not a valid entry)";
		}		
		if(valNum(rate_hour.value)) {
			response += "\nRate [Hour] (Not a valid entry)";
		}		
		if(valNum(rate_landing.value)) {
			response += "\nRate [Landing] (Not a valid entry)";
		}		
		if(valNum(rate_standby.value)) {
			response += "\nRate [Standby] (Not a valid entry)";
		}				
		if(valNum(rate_overnight.value)) {
			response += "\nRate [Overnight] (Not a valid entry)";
		}		
		if(response == 'The following fields are required or have been incorrectly submitted:\n') {
			return true;
		}
		else {
			alert(response);
			return false;
		}
	}
}	
// ----------------------------------------------------------------------
// Validation for aircraft MX update page
// ----------------------------------------------------------------------
function valAircraftMX() {
	var response = 'The following fields are required or have been incorrectly submitted:\n';	
	with(document.update_aircraft_mx) {
		if(valDate(standby_altimeter.value)) {
			response += "\nStandby Altimeter (Not a valid date)";
		}
		if(valDate(pitot_static_cert.value)) {
			response += "\nPitot-Static Cert (Not a valid date)";
		}
		if(valDate(weight_balance.value)) {
			response += "\nWeight Balance (Not a valid date)";
		}
		if(valDate(altimeter_dadc_1.value)) {
			response += "\nNo 1. Altimeter/DADC (Not a valid date)";
		}
		if(valDate(altimeter_dadc_2.value)) {
			response += "\nNo 2. Altimeter/DADC (Not a valid date)";
		}
		if(valDate(transponder_1.value)) {
			response += "\nNo. 1 Transponder (Not a valid date)";
		}
		if(valDate(transponder_2.value)) {
			response += "\nNo. 2 Transponder (Not a valid date)";
		}
		if(valDate(life_vest.value)) {
			response += "\nLife Vest (Not a valid date)";
		}	
		if(valDate(life_rafts.value)) {
			response += "\nLife Rafts (Not a valid date)";
		}	
		if(valDate(battery_elt.value)) {
			response += "\nELT (Battery) (Not a valid date)";
		}	
		if(valDate(oxygen_bottle.value)) {
			response += "\nOxygen Bottle (Not a valid date)";
		}			
		if(valDate(service_date_inspection.value)) {
			response += "\nLast Service [Inspection] (Not a valid date)";
		}
		if(valDate(service_date_ad.value)) {
			response += "\nLast Service [AD] (Not a valid date)";
		}
		if(valDate(service_date_tbo.value)) {
			response += "\nLast Service [TBO] (Not a valid date)";
		}	
		if(response == 'The following fields are required or have been incorrectly submitted:\n') {
			return true;
		}
		else {
			alert(response);
			return false;
		}
	}
}			
// ----------------------------------------------------------------------
// Validation for adding of engines on the manage page
// ----------------------------------------------------------------------
function valAddEngine() {
	var response = 'The following fields are required or have been incorrectly submitted:\n';	
	with(document.add_engine) {
		if(engine_id.options[engine_id.selectedIndex].value == '1') {
			response += "\nEngine (Required)";
		}
		if(response == 'The following fields are required or have been incorrectly submitted:\n') {
			return true;
		}
		else {
			alert(response);
			return false;
		}	
	}
}
// ----------------------------------------------------------------------
// Validation for engine update page
// ----------------------------------------------------------------------
function valEngine() {
	var response = 'The following fields are required or have been incorrectly submitted:\n';	
	with(document.update_engine) {
		if(serial_number.value == '') {
			response += "\nSerial Number (Required)";
		}					
		if(response == 'The following fields are required or have been incorrectly submitted:\n') {
			return true;
		}
		else {
			alert(response);
			return false;
		}
	}
}
// ----------------------------------------------------------------------
// Validation for engine MX update page
// ----------------------------------------------------------------------
function valEngineMX() {
	var response = 'The following fields are required or have been incorrectly submitted:\n';	
	with(document.update_engine_mx) {
		if(is_apu.value == '1') {		
			if(valNum(apu_hobbs_start.value)) {
				response += "\nHobbs Start (Not a valid entry)";
			}	
			if(valNum(apu_hobbs_stop.value)) {
				response += "\nHobbs Stop (Not a valid entry)";
			}	
			if(valNum(apu_cycles.value)) {
				response += "\nCycles (Not a valid entry)";
			}				
		}
		else {
			if(valDate(service_date_inspection.value)) {
				response += "\nLast Service [Inspection] (Not a valid date)";
			}			
		}
		if(response == 'The following fields are required or have been incorrectly submitted:\n') {
			return true;
		}
		else {
			alert(response);
			return false;
		}
	}
}	
// ----------------------------------------------------------------------
// Validation for adding of flight log on the manage page
// ----------------------------------------------------------------------
function valAddFlightLog() {
	var response = 'The following fields are required or have been incorrectly submitted:\n';	
	with(document.add_flight_log) {
		if(legs.value == '') {
			response += "\nLegs (Required - Space Deliminated)";
		}	
		if(aircraft_id.options[aircraft_id.selectedIndex].value == '1') {
			response += "\nAircraft (Required)";
		}		
		if(response == 'The following fields are required or have been incorrectly submitted:\n') {
			return true;
		}
		else {
			alert(response);
			return false;
		}	
	}
}
// ----------------------------------------------------------------------
// Validation for flight log update page
// ----------------------------------------------------------------------
function valFlightLog() {
	var response = 'The following fields are required or have been incorrectly submitted:\n';	
	with(document.update_flight_log) {
		var leg_id = leg_ids.value.split(':');
		var pilot = pilots.value.split(':');
		var aPilotCount = pilot_count.value.split(':');
		var pilots_lost = '';
		var pilot_response = '';		
		var pilots_true;	
		var pilot_confirm;
		var temp_i;
		if(flight_id.value == '') {
			response += "\nFlight ID (Required)";				
		}		
		for(var i in leg_id) {
			pilots_true = false;
			temp_i = parseFloat(i) + 1; 
			if(valDate(eval('out_date_' + leg_id[i]).value)) {
				response += "\nOut Date " + temp_i + " (Not a valid date)";				
			}	
			if(valDate(eval('in_date_' + leg_id[i]).value)) {
				response += "\nIn Date " + temp_i + " (Not a valid date)";				
			}
			if(eval('out_airport_' + leg_id[i]).value == '') {
				response += "\nOut Airport " + temp_i + " (Required)";				
			}	
			if(eval('in_airport_' + leg_id[i]).value == '') {
				response += "\nIn Airport " + temp_i + " (Required)";				
			}
			if(valTime(eval('zulu_out_' + leg_id[i]).value)) {
				response += "\nZulu Out " + temp_i + " (Not a valid time)";				
			}			
			if(valTime(eval('zulu_in_' + leg_id[i]).value)) {
				response += "\nZulu In " + temp_i + " (Not a valid time)";				
			}					
			if(valTime(eval('zulu_off_' + leg_id[i]).value)) {
				response += "\nZulu Off " + temp_i + " (Not a valid time)";				
			}
			if(valTime(eval('zulu_on_' + leg_id[i]).value)) {
				response += "\nZulu On " + temp_i + " (Not a valid time)";				
			}
			if(mode.value == 0) {
				if(valNum(eval('hobbs_start_' + leg_id[i]).value,true)) {
					response += "\nHobbs Start " + temp_i + " (Not a valid entry)";				
				}					
				if(valNum(eval('hobbs_stop_' + leg_id[i]).value,true)) {
					response += "\nHobbs Stops " + temp_i + " (Not a valid entry)";				
				}						
			}	
			if(eval('segment_purpose_id_' + leg_id[i]).options[eval('segment_purpose_id_' + leg_id[i]).selectedIndex].value == 1) {
				response += "\nSegment Purpose " + temp_i + " (Required)";				
			}			
			if(eval('approach_type_id_' + leg_id[i]).options[eval('approach_type_id_' + leg_id[i]).selectedIndex].value == 1) {
				response += "\nApproach Type " + temp_i + " (Required)";				
			}
			if(aPilotCount[i] == 1) {
				if(eval('pilot_id_' + leg_id[i] + '_0').options[eval('pilot_id_' + leg_id[i] + '_0').selectedIndex].value == 1) {
					response += "\nPilot 1 [Leg " + temp_i + "] (Required)";				
				}
				if(eval('seat_position_id_' + leg_id[i] + '_0').options[eval('seat_position_id_' + leg_id[i] + '_0').selectedIndex].value == 1) {
					response += "\nSeat 1 [Leg " + temp_i + "] (Required)";				
				}
				if(valNum(eval('imc_time_' + leg_id[i] + '_0').value)) {
					response += "\nIMC 1 [Leg " + temp_i + "] (Not a valid entry)";				
				}
				if(valNum(eval('day_time_' + leg_id[i] + '_0').value)) {
					response += "\nDay 1 [Leg " + temp_i + "] (Not a valid entry)";				
				}	
				if(valNum(eval('night_time_' + leg_id[i] + '_0').value)) {
					response += "\nNight 1 [Leg " + temp_i + "] (Not a valid entry)";				
				}
/*				
				if(i == 0) {
					if(valDate(eval('on_duty_date_' + leg_id[i] + '_0').value)) {
						response += "\nDuty On Date 1 [Leg " + temp_i + "] (Not a valid date)";				
					}	
					if(valTime(eval('on_duty_time_' + leg_id[i] + '_0').value)) {
						response += "\nDuty On Time 1 [Leg " + temp_i + "] (Not a valid time)";				
					}
				}
				if(i == leg_id.length-1) {
					if(valDate(eval('off_duty_date_' + leg_id[i] + '_0').value)) {
						response += "\nDuty Off Date 1 [Leg " + temp_i + "] (Not a valid date)";				
					}	
					if(valTime(eval('off_duty_time_' + leg_id[i] + '_0').value)) {
						response += "\nDuty Off Time 1 [Leg " + temp_i + "] (Not a valid time)";				
					}	
				}
*/				
			}
			else {
				for(j=0;j<aPilotCount[i];j++) {
					if(eval('pilot_id_' + leg_id[i] + '_' + j).options[eval('pilot_id_' + leg_id[i] + '_' + j).selectedIndex].value != 1) {
						pilots_true = true;
						if(eval('seat_position_id_' + leg_id[i] + '_' + j).options[eval('seat_position_id_' + leg_id[i] + '_' + j).selectedIndex].value == 1) {
							response += "\nSeat " + (j+1) + " [Leg " + temp_i + "] (Required)";				
						}
						if(valNum(eval('imc_time_' + leg_id[i] + '_' + j).value)) {
							response += "\nIMC " + (j+1) + " [Leg " + temp_i + "] (Not a valid entry)";				
						}
						if(valNum(eval('day_time_' + leg_id[i] + '_' + j).value)) {
							response += "\nDay " + (j+1) + " [Leg " + temp_i + "] (Not a valid entry)";				
						}	
						if(valNum(eval('night_time_' + leg_id[i] + '_' + j).value)) {
							response += "\nNight " + (j+1) + " [Leg " + temp_i + "] (Not a valid entry)";				
						}
						
/*						
						if(i == 0) {
							if(valDate(eval('on_duty_date_' + leg_id[i] + '_' + j).value)) {
								response += "\nDuty On Date " + (j+1) + " [Leg " + temp_i + "] (Not a valid date)";				
							}	
							if(valTime(eval('on_duty_time_' + leg_id[i] + '_' + j).value)) {
								response += "\nDuty On Time " + (j+1) + " [Leg " + temp_i + "] (Not a valid time)";				
							}
						}
						if(i == leg_id.length-1) {
							if(valDate(eval('off_duty_date_' + leg_id[i] + '_' + j).value)) {
								response += "\nDuty Off Date " + (j+1) + " [Leg " + temp_i + "] (Not a valid date)";				
							}	
							if(valTime(eval('off_duty_time_' + leg_id[i] + '_' + j).value)) {
								response += "\nDuty Off Time " + (j+1) + " [Leg " + temp_i + "] (Not a valid time)";				
							}	
						}
*/						
					}			
				}
				if(!pilots_true) {
					pilots_true = true;
					if(pilots_lost != '') {
						pilots_lost += "\n";
					}
					pilots_lost += 'Leg ' + temp_i;
					pilot_response += "\nAt Least a Single Pilot [Leg " + temp_i + "] (Required)";
				}
			}
										
		}
		if(pilots_lost != '') {
			var pilot_confirm = confirm("At least one pilot is required per leg.\n\nThe following legs do not have at least a single declared pilot:\n\n" + pilots_lost + "\n\nThese legs will be removed during the processing of this flight log.\n\nClick \"OK\" to continue or \"Cancel\" to complete each required Leg.");
			if(!pilot_confirm) {
				response += "\n" + pilot_response;				
			}
		}
		if(response == 'The following fields are required or have been incorrectly submitted:\n') {
			return true;
		}
		else {
			alert(response);
			return false;
		}
	}
}
// ----------------------------------------------------------------------
// Validation for adding of flight log on the manage page
// ----------------------------------------------------------------------
function valAddQuote() {
	var response = 'The following fields are required or have been incorrectly submitted:\n';	
	with(document.add_quote) {
		if(legs.value == '') {
			response += "\nLegs (Required - Space Deliminated)";
		}
		if(aircraft_id.options[aircraft_id.selectedIndex].value == '1') {
			response += "\nAircraft (Required)";
		}	
		if(response == 'The following fields are required or have been incorrectly submitted:\n') {
			return true;
		}
		else {
			alert(response);
			return false;
		}	
	}
}

// ----------------------------------------------------------------------
// Validation for pilot medical
// function checkPilotMedical(medClass, medDate, birthDate, departDate)
//   Parameters:
//     medClass = integer, medical class 1,2,3
//     medDate = Date class, date of medical certificate
//     birthDate = Date class, date of birth
//     departDate = Date class, date of departure - or date to test
//   Return string:
//     'noBirthDate'
//     'noMedDate'
//     'expired,yyyy-mm-dd'
//     'badClass,nn'
//     'yyyy-mm-dd' will expire on
//	Added: Kent Behrends, kent AT bci DOT com, 2009-04-14 - mantis # 126
// ----------------------------------------------------------------------
function checkPilotMedical(medClass, tMedDate, tBirthDate, tDepartDate) {
	var oneDay = 1000*60*60*24;			// One day in getTime format
	var fortyYears = oneDay*365.25*40;	// Forty years in getTime format
	var medDateExpire = new Date();
	var monthsToExpire=12;
	var fortyDate = new Date();
	var overForty;
	
	var aMedDate = tMedDate.split('-');
	var medDate = new Date(aMedDate[0],aMedDate[1]-1,aMedDate[2]);
	var aBirthDate =tBirthDate.split('-');
	var birthDate = new Date(aBirthDate[0],aBirthDate[1]-1,aBirthDate[2]);
	var aDepartDate =tDepartDate.split('/');
	var departDate = new Date(aDepartDate[2],aDepartDate[0]-1,aDepartDate[1],aDepartDate[0],aDepartDate[1]);

	// Is pilot over 40 ?
	fortyDate.setTime(birthDate.getTime()+fortyYears);
	overForty = (departDate >= fortyDate);

	// Length of time med cert is good is based on class and age
	switch (medClass) {
		case 1: // Class 1
			if(overForty) { monthsToExpire = 6; } else { monthsToExpire = 12; }
			break;
		case 2: // Class 2
			monthsToExpire = 12;
			break;
		case 3: // Class 3
			if(overForty) { monthsToExpire = 2*12; } else { monthsToExpire = 5*12; }
			break;
		default:
			monthsToExpire = 12;	// unknown class, assume 1 year			
	}

	// Is med cert expired?
	medDateExpire = new Date(medDate.getFullYear(),medDate.getMonth()+monthsToExpire+1,0); // end of the month
	
	// format expired date for return as yyyy-mm-dd
	medDateExpireReturn = medDateExpire.getFullYear()+"-";
	if(medDateExpire.getMonth() < 10) medDateExpireReturn += '0';
	medDateExpireReturn += (medDateExpire.getMonth()+1)+"-";
	if(medDateExpire.getDate() < 10) medDateExpireReturn += '0';
	medDateExpireReturn += medDateExpire.getDate();
	
	// Expired?
	if  (departDate > medDateExpire) return 'expired,'+medDateExpireReturn;						
	
	// Is class valid? commercial pilot can only have class 1 or class 2
	if(!((medClass == 1) || (medClass == 2))) return 'badClass,'+medClass;
	
	// If all ok, return the expired date
	return(medDateExpireReturn);
}

// ----------------------------------------------------------------------
// Validation for quote update page
// ----------------------------------------------------------------------
function valQuote() {
	var response = 'The following fields are required or have been incorrectly submitted:\n';	
	var strEnduranceResponse = 'The quoted flight plan for the following legs exceeds the FUEL MAX CAPACITY for this aircraft:\n';	
	with(document.update_quote) {		
// 		----------------------------------------------------------------------
// 		Get currently chosen aircraftID
// 		----------------------------------------------------------------------
		var intAircraftId = aircraft_id.options[aircraft_id.selectedIndex].value;
		var intFuelStopInc = parseFloat(fuel_stop_time.value);
		var intReserveTime = parseFloat(reserve_time.value);	
// 		----------------------------------------------------------------------
// 		Isolate aircraft array row and capture fuel burn data
// 		----------------------------------------------------------------------
		for(i=0;i<aircraft.length;i++) {
			if(aircraft[i][0] == intAircraftId) {
				break;
			}
		}
		var floatMaxFuelCapacity = aircraft[i][11];
		var floatFuelBurn1 = aircraft[i][12];
		var floatFuelBurn2 = aircraft[i][13];
		var floatFuelBurn3 = aircraft[i][14];
		var floatFuelBurn1PerMin = floatFuelBurn1/60;
		var floatFuelBurn2PerMin = floatFuelBurn2/60;
		var floatFuelBurn3PerMin = floatFuelBurn3/60;		
// 		----------------------------------------------------------------------
// 		Isolate pilot array rows and populate a new aPilot "data" array
//		aPilot = array([Pilot ID,'Pilot Name',MaxFlight,MaxDuty,TotalFlightTime,TotalDutyTime,med_class, med_date, pilot_birthdate])
// 		----------------------------------------------------------------------
		var aPilot = new Array();
		for(i=0;i<pilot.length;i++) {
			if(pilot[i][0] == intAircraftId) {
				aPilot.push([pilot[i][1],pilot[i][2],pilot[i][3],pilot[i][4],0,0,pilot[i][5],pilot[i][6],pilot[i][7]]);
			}
		}
// 		----------------------------------------------------------------------
// 		Extract an array of leg ids
// 		----------------------------------------------------------------------
//		var intAircraftId = aircraft_id.options[aircraft_id.selectedIndex].value;		
		var aLegId = leg_ids.value.split(':');
		var aLegPilot = pilots.value.split(':');
		var aLegPilotId;	
// 		----------------------------------------------------------------------
// 		Validate Leg Data
//		Loop through Legs [i]
//		----------------------------------------------------------------------
		var strTotalFlightTime;
		var strTotalDutyTime;
		var floatTotalFlightTime;
		var floatTotalDutyTime;
		var floatTempMin;
		var intTempHour;
		var floatTotalTimeHr;
		var floatTotalTimeMin; 
		var boolPilotFound;
		var intTempIndex;
		var strETE;		
		var aETE;
		var floatETE
		var boolMaxReached;
		var intHrWhenMaxReached;
		var floatEndurance;
		var intMinReserve = 45;
		for(i=0;i<aLegId.length;i++) {
			boolMaxReached = false
			floatEndurance = 0;
// 			----------------------------------------------------------------------
// 			Validate Leg Data
//			----------------------------------------------------------------------				
			if(eval('out_airport_'+aLegId[i]).value == '') {
				response += "\nLeg "+(i+1)+" Out Airport (Required)";				
			}	
			if(eval('in_airport_'+aLegId[i]).value == '') {
				response += "\nLeg "+(i+1)+" In Airport (Required)";			
			}			
			if(valDate(eval('out_date_'+aLegId[i]).value)) {
				response += "\nLeg "+(i+1)+" Out Date (Not a valid date)";				
			}	
			if(valTime(eval('etd_'+aLegId[i]).value)) {
				response += "\nLeg "+(i+1)+" ETD (Not a valid time)";			
			}			
			if(valTime(eval('eta_'+aLegId[i]).value)) {
				response += "\nLeg "+(i+1)+" ETA (Not a valid time)";			
			}	
			if(valDate(eval('in_date_'+aLegId[i]).value)) {
				response += "\nLeg "+(i+1)+" In Date (Not a valid date)";				
			}		
// 			----------------------------------------------------------------------
//			If the leg does not contain at least one fuel stop
//			Validate Endurance	
// 			----------------------------------------------------------------------	
			if(eval('fuel_stops_'+aLegId[i]).options[eval('fuel_stops_'+aLegId[i]).selectedIndex].value < 1) {
				strETE = eval('ete_'+aLegId[i]).value;
				aETE = strETE.split(':');
				floatETE = Math.floor(parseFloat(parseFloat(aETE[0])+'.'+parseFloat(aETE[1]))*60);	
				for(var j=0;j<floatETE;j++) {
					if(j < 60) {
						floatEndurance += floatFuelBurn1PerMin;
					}
					else if(j >= 60 && j < 120) {
						floatEndurance += floatFuelBurn2PerMin;
					}
					else {
						floatEndurance += floatFuelBurn3PerMin;
					}
					if(floatEndurance >= floatMaxFuelCapacity && !boolMaxReached) {
						boolMaxReached = true;
						if(intHrWhenMaxReached == null) {
							intHrWhenMaxReached = Math.round(j/60*10)/10;
						}
						strEnduranceResponse += "\nLeg "+(i+1)+" ["+eval('out_airport_'+aLegId[i]).value+"-"+eval('in_airport_'+aLegId[i]).value+"]";
					}
					j++;
				}		
			}
// 			----------------------------------------------------------------------
//			if this is a scheduled quote	
// 			----------------------------------------------------------------------
			if(scheduled.checked) {
				if(aLegPilot[i] == '' || aLegPilot[i] == '1') {
					response += "\nLeg "+(i+1)+" Pilot (Required)";
				}
// 				----------------------------------------------------------------------
// 				Calculate pilot total flight times
//				Loop through pilots per leg [j]	
//				Loop through pilot data array
//				----------------------------------------------------------------------			
				aLegPilotId = aLegPilot[i].split(',');		
				for(j=0;j<aLegPilotId.length;j++) {
// 					----------------------------------------------------------------------
//					Initialize search for pilot criteria
//					----------------------------------------------------------------------						
					boolPilotFound = false;
					intTempIndex=0;
					for(k=0;k<aPilot.length;k++) {
						if(aPilot[k][0] == aLegPilotId[j]) {
// 							----------------------------------------------------------------------
// 							Mark pilot as found
//							----------------------------------------------------------------------	
							boolPilotFound = true;
							intTempIndex = k;
							k = aPilot.length-1;
						}
					}
					if(boolPilotFound) {
// 						----------------------------------------------------------------------
//						If less than 10 hours of time exists between on time of prev leg and off time of current leg
// 						Incrament Total Flight Time
//						----------------------------------------------------------------------	
						if(i < aLegId.length-1) {		
// 							----------------------------------------------------------------------
//							Get focus date and time date
//							----------------------------------------------------------------------	
							var intMaxCheck = 10;				
							var aCurrentDate = eval('in_date_'+aLegId[i]).value.split('/');
							var aCurrentTime = eval('eta_'+aLegId[i]).value.split(':');	
							var dateCurrent = new Date(aCurrentDate[2],aCurrentDate[0]-1,aCurrentDate[1],aCurrentTime[0],aCurrentTime[1]);
							var aNextDate = eval('out_date_'+aLegId[i+1]).value.split('/');
							var aNextTime = eval('etd_'+aLegId[i+1]).value.split(':');					
							var dateNext = new Date(aNextDate[2],aNextDate[0]-1,aNextDate[1],aNextTime[0],aNextTime[1]);
							var intMilliSecDiff = dateNext-dateCurrent;
							var floatHourDiff = intMilliSecDiff/1000/3600;
						}
						if(floatHourDiff < intMaxCheck || i == aLegId.length-1) {
							floatTotalFlightTime = eval('ete_'+aLegId[i]).value.split(':');
							floatTempMin = floatTotalFlightTime[1]/60;
							intTempHour = Math.floor(floatTempMin);
							floatTotalTimeHr = parseFloat(floatTotalFlightTime[0])+intTempHour;
							floatTotalTimeMin = floatTempMin-intTempHour; 
							aPilot[intTempIndex][4] += floatTotalTimeHr+floatTotalTimeMin;
//							----------------------------------------------------------------------
//							Incrament Total Duty Time [Flight Time]
//							----------------------------------------------------------------------	
							floatTotalDutyTime = eval('ete_'+aLegId[i]).value.split(':');
							floatTempMin = floatTotalDutyTime[1]/60;
							intTempHour = Math.floor(floatTempMin);
							floatTotalTimeHr = parseFloat(floatTotalDutyTime[0])+intTempHour;
							floatTotalTimeMin = floatTempMin-intTempHour; 
							aPilot[intTempIndex][5] += floatTotalTimeHr+floatTotalTimeMin;	
						}
//		 				----------------------------------------------------------------------
//	 					Check pilot medical
//							Added: Kent Behrends, kent AT bci DOT com, 2009-04-07 - mantis # 126
//						----------------------------------------------------------------------
						// Has the pilot's birdatdate been entered?
						/*
                        //Commented By Pavan Sharma 1/11/2010 to remove old medical validations on account of ERK related changes
                        if(aPilot[intTempIndex][8] == "0000-00-00") {
							response += "\n"+aPilot[intTempIndex][1]+"'s birthdate has not been entered. Unable to validate medical certificate.";
						}
						else {
							
							var medClass = aPilot[intTempIndex][6]-1;
							var tMedDate = aPilot[intTempIndex][7];
							var tBirthDate = aPilot[intTempIndex][8];
							var tDepartDate = eval('out_date_'+aLegId[0]).value;
							
							var medStat = checkPilotMedical(medClass, tMedDate, tBirthDate, tDepartDate).split(',');

							switch (medStat[0]) {
								case 'noBirthdate':
									response += "\n"+aPilot[intTempIndex][1]+"'s birthdate has not been entered. Unable to validate medical certificate.";
									break;
								case 'expired':
									response += "\n"+aPilot[intTempIndex][1]+"'s class medical expired on "+medStat[1];
									break;
								case 'badClass':
									response += "\n"+aPilot[intTempIndex][1]+"'s class medical class of "+medStat[1]+" is invalid for a commercial pilot.";
									break;
							}
						}  */
					}
				}
//				----------------------------------------------------------------------
//				Incrament Total Duty Time if the next leg has the current pilot
//				----------------------------------------------------------------------				
				if(aLegPilot[i+1] != null) {
					aLegPilotId = aLegPilot[i+1].split(',');
					boolPilotFound = false;
					for(j=0;j<aLegPilotId.length;j++) {
						
						if(aPilot[intTempIndex][0] == aLegPilotId[j]) {
							boolPilotFound = true;
							j = aLegPilotId.length-1;
						}					
					}
					if(boolPilotFound && (floatHourDiff < intMaxCheck)) {
						aPilot[intTempIndex][5] += floatHourDiff;
					}
				}
			}
		}
		if(strEnduranceResponse != 'The quoted flight plan for the following legs exceeds the FUEL MAX CAPACITY for this aircraft:\n') {
			response += "\nFuel Stops (Required)";
			alert(strEnduranceResponse+"\n\nThe FUEL MAX CAPACITY for this aircraft was reached after "+intHrWhenMaxReached+" hours of flight time\n\nYOU MUST ADD AN APPROPRIATE NUMBER OF FUEL STOPS TO EACH LEG!");
		}
// 		----------------------------------------------------------------------
//		if this is a scheduled quote validate pilot flight and duty time
// 		----------------------------------------------------------------------
		if(scheduled.checked) {		
// 			----------------------------------------------------------------------
// 			Validate individual pilot flight and duty time
//			Loop through pilot data array
//			----------------------------------------------------------------------
			for(i=0;i<aPilot.length;i++) {
// 				----------------------------------------------------------------------
// 				Create hr report message
//				----------------------------------------------------------------------	
				strTotalFlightTime = Math.round(aPilot[i][4]*10)/10+' hr';
				strTotalDutyTime = Math.round(aPilot[i][5]*10)/10+' hr';
				if(floatTotalFlightTime != 1) {
					strTotalFlightTime += 's';
				}
				if(floatTotalDutyTime != 1) {
					strTotalDutyTime += 's';
				}	
//	 			----------------------------------------------------------------------
// 				Check pilot times
//				----------------------------------------------------------------------					
				if(aPilot[i][4] > aPilot[i][2]) {
					response += "\n"+aPilot[i][1]+"'s  TOTAL FLIGHT TIME  of "+strTotalFlightTime+"  EXCEEDS  his/her  MAX FLIGHT TIME  of "+aPilot[i][2]+" hr";
					if(aPilot[i][2] != 1) {
						response += "s";
					}				
				}				
				if(aPilot[i][5] > aPilot[i][3]) {
					response += "\n"+aPilot[i][1]+"'s  TOTAL DUTY TIME  of "+strTotalDutyTime+"  EXCEEDS  his/her  MAX DUTY TIME  of "+aPilot[i][3]+" hr";
					if(aPilot[i][3] != 1) {
						response += "s";
					}				
				}				
			}
		}
		if(response == 'The following fields are required or have been incorrectly submitted:\n') {
			add_fees.value = '';
			for(i=1;i<add_fees_detail.options.length;i++) {
				if(add_fees.value != '') {
					add_fees.value += ':^-^:';
				}
				if(document.getElementById('sae')!=null){
				add_fees.value += add_fees_detail.options[i].value + ':^,^:' + add_fees_amount.options[i].value;
				}else{
                 add_fees.value += add_fees_detail.options[i].text + ':^,^:' + add_fees_amount.options[i].value;
				}
			}
			return true;
//			return false;			
		}
		else {
			alert(response);
			return false;
		}	
	}
}
// ----------------------------------------------------------------------
// Validation for adding of a leg to a flight log or quote
// ----------------------------------------------------------------------
function valAddLeg() {
	var response = 'The following fields are required or have been incorrectly submitted:\n';	
	with(document.formAddLegs) {
		if(formStrNewLegs.value == '') {
			response += "\nLegs (Required - Space Deliminated)";
		}		
		if(response == 'The following fields are required or have been incorrectly submitted:\n') {
			return true;
		}
		else {
			alert(response);
			return false;
		}	
	}
}
//----------------------------------------------------------------------
//Validation for adding of member on the manage page
//----------------------------------------------------------------------
function valAddMember() {
	var response = 'The following fields are required or have been incorrectly submitted:\n';		
	with(document.add_member) {
		view_type_id.value = document.view_type_list.view_type_id.options[document.view_type_list.view_type_id.selectedIndex].value;
		if(member_type_id.options[member_type_id.selectedIndex].value == 1) {
			response += "\nPrimary Member Type (Required)";
		}
		if(response == 'The following fields are required or have been incorrectly submitted:\n') {
			return true;
		}
		else {
			alert(response);
			return false;
		}		
	}	
}
//----------------------------------------------------------------------
//Validation for adding an Audit
//----------------------------------------------------------------------
function valAddAudit() {
	return true;
}
//----------------------------------------------------------------------
//Validation for adding a Risk Assessment
//----------------------------------------------------------------------
function valAddRisk() {
	return true;
}
// ----------------------------------------------------------------------
// Validation for adding of member on the manage page
// ----------------------------------------------------------------------
function valMemberType() {
	var response = 'The following fields are required or have been incorrectly submitted:\n';		
	with(document.update_member_type) {	
		if(member_type_id.options[member_type_id.selectedIndex].value == 1) {
			response += "\nPrimary Member Type (Required)";
		}
		if(response == 'The following fields are required or have been incorrectly submitted:\n') {
			return true;
		}
		else {
			alert(response);
			return false;
		}	
	}	
}
// ----------------------------------------------------------------------
// Validation for member update page
// ----------------------------------------------------------------------
function valMember() {
	var response = 'The following fields are required or have been incorrectly submitted:\n';
	with(document.update_member) {
		var ph1 = ph11.value + ph12.value + ph13.value;
		var ph2 = ph21.value + ph22.value + ph23.value;
		var fax = fax1.value + fax2.value + fax3.value;		
		if(eun.value == '') {
			response += "\nUsername (Required)";
		}
		if(broker_info.value) {
			if(broker_name.value == '') {
				response += "\nCompany (Required)";
			}
			if(broker_alias.value == '') {
				response += "\nSite Alias (Required)";
			}						
		}
		else {
			if(first_name.value == '') {
				response += "\nFirst Name (Required)";
			}
			if(last_name.value == '') {
				response += "\nLast Name (Required)";
			}
		}
		// Modified: Kent Behrends, kent@bci.com, 2007-05-04 - Less validation on Passengers see wiki page LevelFlightPassengerReqFields
		// Modified: Kent Behrends, kent@bci.com, 2008-08-09 - As requested, remove most required fields from Customer
		if(!((member_type_id.value == 9) || (member_type_id.value == 12))) {
			if(ph1.length == 0 && non_us_phone.value == '') {
				response += '\nPrimary Phone or Non-US Phone (Required) here';
			}				
			else if(ph1.length > 0 && ph1.length < 10) {
				response += '\nPrimary Phone (Incomplete)';
			}
			if(ph2.length > 0 && ph2.length < 10) {
				response += '\nAlternate phone (Incomplete)';
			}	
			if(fax.length > 0 && fax.length < 10) {
				response += '\nFax (Incomplete)';
			}						
			if(valEmail(email.value)) {
				response += "\nEmail (Not a valid address)";			
			}	
			if(street1.value == '') {
				response += '\nAddress: Street 1 (Required)';
			}
			if(city.value == '' && non_us_city.value == '' && country.options[country.selectedIndex].value == 1) {
				response += '\nAddress: City (Required)';
			}
			if(state.options[state.selectedIndex].value == 1 && non_us_city.value == '' && country.options[country.selectedIndex].value == 1) {
				response += '\nAddress: State (Required)';
			}
			if(non_us_city.value == '' && city.value == '' && state.options[state.selectedIndex].value == 1 && country.options[country.selectedIndex].value != 1) {
				response += '\nAddress: Non-US City (Required)';			
			}
			if(country.options[country.selectedIndex].value == 1 && non_us_city.value == '' && city.value == '' && state.options[state.selectedIndex].value == 1 && non_us_city.value != '') {
				response += '\nAddress: Non-US Country (Required)';			
			}		
			if((city.value != '' && non_us_city.value != '') || (city.value != '' && country.options[country.selectedIndex].value != 1) || (state.options[state.selectedIndex].value != 1 && non_us_city.value != '') || (state.options[state.selectedIndex].value != 1 && country.options[country.selectedIndex].value != 1)) {
				response += '\nAddress: Non-US City (Only one address can be used per operation... US or Non-US)';
			}			
			if(postal_code.value == '') {
				response += '\nAddress: Postal Code (Required)';
			}
		    // Modified: Kent Behrends, kent@bci.com, 2007-07-09 Less validation on Customer see wiki page LevelFlightCustomerReqFields
			if(broker_info.value) {
/*
				var pph1 = cpph11.value + cpph12.value + cpph13.value;
				var pph2 = cpph21.value + cpph22.value + cpph23.value;
				var pfax = cpfax1.value + cpfax2.value + cpfax3.value;
				var aph1 = caph11.value + caph12.value + caph13.value;
				var aph2 = caph21.value + caph22.value + caph23.value;
				var afax = cafax1.value + cafax2.value + cafax3.value;			
				if(broker_primary_contact_first_name.value == '') {
					response += "\nPrimary Contact [First Name] (Required)";
				}
				if(broker_primary_contact_last_name.value == '') {
					response += "\nPrimary Contact [Last Name] (Required)";
				}
				if(valEmail(broker_primary_contact_email.value)) {
					response += "\nPrimary Contact [Email] (Required)";
				}
				if(pph1.length == 0 && broker_primary_contact_non_us_phone.value == '') {
					response += '\nPrimary Contact [Primary Phone or Non-US Phone] (Required)';
				}			
				else if(pph1.length > 0 && pph1.length < 10) {
					response += '\nPrimary Contact [Primary Phone] (Incomplete)';
				}
				if(pph2.length > 0 && pph2.length < 10) {
					response += '\nPrimary Contact [Alternate Phone] (Incomplete)';
				}	
				if(pfax.length > 0 && pfax.length < 10) {
					response += '\nPrimary Contact [Fax] (Incomplete)';
				}				
				if(broker_alternate_contact_first_name.value == '') {
					response += "\nAlternate Contact [First Name] (Required)";
				}
				if(broker_alternate_contact_last_name.value == '') {
					response += "\nAlternate Contact [Last Name] (Required)";
				}
				if(valEmail(broker_alternate_contact_email.value)) {
					response += "\nAlternate Contact [Email] (Required)";
				}
				if(aph1.length == 0 && broker_alternate_contact_non_us_phone.value == '') {
					response += '\nAlternate Contact [Primary Phone or Non-US Phone] (Required)';
				}			
				else if(aph1.length > 0 && aph1.length < 10) {
					response += '\nAlternate Contact [Primary Phone] (Incomplete)';
				}
				if(aph2.length > 0 && aph2.length < 10) {
					response += '\nAlternate Contact [Alternate Phone] (Incomplete)';
				}	
				if(afax.length > 0 && afax.length < 10) {
					response += '\nAlternate Contact [Fax] (Incomplete)';
				}
*/
			}
			if(passenger_info.value) {
				if(valDate(birthdate.value)) {
					response += "\nBirthdate (Not a valid date)";
				}			
			}	
			if(travel_document_info.value) {
	/*			
				if(visa_number.value == '') {
					response += "\nVisa Number (Required)";
				}		
				if(valDate(visa_exp_date.value)) {
					response += "\nVisa Expiration Date (Not a valid date)";
				}		
				if(passport_number.value == '') {
					response += "\nPassport Number (Required)";
				}	
				if(valDate(passport_exp_date.value)) {
					response += "\nPassport Expiration Date (Not a valid date)";
				}	
	*/			
			}
			if(pilot_info.value && rating_info.value) {
				if(duty_max_time.value == '') {
					response += "\nDuty Max Time (Required)";
				}	
				if(flight_max_time.value == '') {
					response += "\nFlight Max Time (Required)";
				}
				if(seat_position_id.options[seat_position_id.selectedIndex].value == 1) {
					response += "\nSeat (Required)";				
				}
			}		
			if(emergency_info.value) {
				var eph1 = eph11.value + eph12.value + eph13.value;
				var eph2 = eph21.value + eph22.value + eph23.value;		
				if(eph1.length == 0 && emergency_non_us_phone.value == '') {
					response += '\nEmergency Contact [Primary Phone or Non-US Phone] (Required)';
				}			
				if(eph1.length > 0 && eph1.length < 10) {
					response += '\nEmergency Contact [Primary Phone] (Incomplete)';
				}
				if(eph2.length > 0 && eph2.length < 10) {
					response += '\nEmergency Contact [Alternate Phone] (Incomplete)';
				}		
			}
			if(certificate_info.value) {
				if(qual_certificate_id.options[qual_certificate_id.selectedIndex].value == 1 && cert_needed.value == 1) {
					response += "\nCertificate (Required)";				
				}			
				if(qual_certificate_number.value == '' && cert_needed.value == 1) {
					response += "\nCertificate Number (Required)";
				}
				if(valDate(qual_certificate_date.value) && cert_needed.value == 1) {
					response += "\nCertificate Date (Not a valid date)";
				}			
				/*  commented by pavan sharma on account of erk related changes
                if(qual_medical_class_id.options[qual_medical_class_id.selectedIndex].value == 1) {
					response += "\nMedical Class (Required)";				
				}			
				if(valDate(qual_medical_class_date.value)) {
					response += "\nMedical Class Date (Not a valid date)";
				}
				if(month_id.options[month_id.selectedIndex].value == 1) {
					response += "\nBase Month (Required)";				
				}		*/		
			}
		} // Passenger
	}
	if(response == 'The following fields are required or have been incorrectly submitted:\n') {
		return true;
	}
	else {
		alert(response);
		return false;
	}
}
// ----------------------------------------------------------------------
// Validation for member (rating) update page
// ----------------------------------------------------------------------
function valRating() {
	var response = 'The following fields are required or have been incorrectly submitted:\n';	
	with(document.update_rating) {
		if(aircraft_id.options[aircraft_id.selectedIndex].value == 1) {
			response += "\nRating Type (Required)";
		}
		if(valDate(rating_date.value)) {
			response += "\nRating Date (Not a valid date)";
		}		
		if(response == 'The following fields are required or have been incorrectly submitted:\n') {
			return true;
		}
		else {
			alert(response);
			return false;
		}
	}
}
// ----------------------------------------------------------------------
// Validation for member (attachment) update page
// ----------------------------------------------------------------------
function valAttachment() {
	var response = 'The following fields are required or have been incorrectly submitted:\n';	
	with(document.update_attachment) {
		if(name.value == '') {
			response += "\nName (Required)";
		}
		if((sm.value == '' || active_alert.checked) && valDate(exp_date.value)) {
			response += "\nExpiration Date (Not a valid date)";
		}
		if(aid.value == 1 && eval(file_name.value).value == '') {
			response += "\nDocument (Required)";		
		}
		if(response == 'The following fields are required or have been incorrectly submitted:\n') {
			return true;
		}
		else {
			alert(response);
			return false;
		}
	}
}
// ----------------------------------------------------------------------
// Validation for operation update page
// ----------------------------------------------------------------------
function valOperation(attachmentcheck) {
    if(typeof(attachment)=='object'){
        var status=attachment.finalCheck(); //call back final check for attachment
        if(status==false){
            return false;
        }
        
    }
	var response = 'The following fields are required or have been incorrectly submitted:\n';
	with(document.update_operation) {		
		var ph1 = ph11.value + ph12.value + ph13.value;
		var ph2 = ph21.value + ph22.value + ph23.value;
		var fax = fax1.value + fax2.value + fax3.value;
		if(admin_contact_id.options[admin_contact_id.selectedIndex].value == '1') {
			response += '\nAdministrative Contact (Required)';
		}		
		if(!part_91.checked && !part_125.checked && !part_135.checked) {
			response += '\nAt least one operation type must be selected (91, 125 or 135)';
		}			
		if(name.value == '') {
			response += '\nCompany Name (Required)';
		}
		if(alias.value == '') {
			response += '\nSite Alias (Required)';
		}
		if(cert_num.value == '') {
			response += '\nCertificate Number (Required)';
		}
		if(valDate(cert_date.value)) {
			response += '\nCertificate Date (Not a valid date)';
		}
		if(street1.value == '') {
			response += '\nAddress: Street 1 (Required)';
		}
		if(city.value == '' && non_us_city.value == '' && country.options[country.selectedIndex].value == 1) {
			response += '\nAddress: City (Required)';
		}
		if(state.options[state.selectedIndex].value == 1 && non_us_city.value == '' && country.options[country.selectedIndex].value == 1) {
			response += '\nAddress: State (Required)';
		}
		if(non_us_city.value == '' && city.value == '' && state.options[state.selectedIndex].value == 1 && country.options[country.selectedIndex].value != 1) {
			response += '\nAddress: Non-US City (Required)';			
		}
		if(country.options[country.selectedIndex].value == 1 && non_us_city.value == '' && city.value == '' && state.options[state.selectedIndex].value == 1 && non_us_city.value != '') {
			response += '\nAddress: Non-US Country (Required)';			
		}		
		if((city.value != '' && non_us_city.value != '') || (city.value != '' && country.options[country.selectedIndex].value != 1) || (state.options[state.selectedIndex].value != 1 && non_us_city.value != '') || (state.options[state.selectedIndex].value != 1 && country.options[country.selectedIndex].value != 1)) {
			response += '\nAddress: Non-US City (Only one address can be used per operation... US or Non-US)';
		}		
		if(postal_code.value == '') {
			response += '\nAddress: Postal Code (Required)';
		}		
		if(ph1.length == 0 && non_us_phone.value == '') {
			response += '\nPrimary Phone or Non-US Phone (Required)';
		}		
		if(ph1.length < 10) {
			response += '\nPrimary Phone (Incomplete)';
		}
		if(ph2.length > 0 && ph2.length < 10) {
			response += '\nAlternate phone (Incomplete)';
		}	
		if(fax.length > 0 && fax.length < 10) {
			response += '\nFax (Incomplete)';
		}			
		if(valEmail(email.value)) {
			response += "\nEmail (Not a valid address)";			
		}
		if(response == 'The following fields are required or have been incorrectly submitted:\n') {
			return true;
		}
		else {
			alert(response);
			return false;
		}
	}
}
// ----------------------------------------------------------------------
// Validation for creating a new folder for "L Drive files/folders"
// ----------------------------------------------------------------------
function valLDriveNewDir() {
	var response = 'The following fields are required or have been incorrectly submitted:\n';	
	with(document.formLDriveNewDir) {
		if(formStrNewDir.value == '') {
			response += "\nFolder Name (Required)";
		}		
		if(response == 'The following fields are required or have been incorrectly submitted:\n') {
			return true;
		}
		else {
			alert(response);
			return false;
		}	
	}
}
// ----------------------------------------------------------------------
// Validation for uploading a new file for "L Drive files/folders"
// ----------------------------------------------------------------------
function valLDriveNewFile() {
	var response = 'The following fields are required or have been incorrectly submitted:\n';	
	with(document.formLDriveNewFile) {
		if(formStrNewFile.value == '') {
			response += "\nBrowse for a file (Required)";
		}		
		if(response == 'The following fields are required or have been incorrectly submitted:\n') {
			return true;
		}
		else {
			alert(response);
			return false;
		}	
	}
}
// ----------------------------------------------------------------------
// Validation for renaming a directory for "L Drive files/folders"
// ----------------------------------------------------------------------
function valLDriveRenameDir() {
	var response = 'The following fields are required or have been incorrectly submitted:\n';	
	with(document.formLDriveRenameDir) {
		if(formStrNewDirName.value == '') {
			response += "\nNew Directory Name (Required)";
		}		
		if(response == 'The following fields are required or have been incorrectly submitted:\n') {
			return true;
		}
		else {
			alert(response);
			return false;
		}	
	}
}
// ----------------------------------------------------------------------
// Validation for renaming a file for "L Drive files/folders"
// ----------------------------------------------------------------------
function valLDriveRenameFile() {
	var response = 'The following fields are required or have been incorrectly submitted:\n';	
	with(document.formLDriveRenameFile) {
		if(formStrNewFileName.value == '') {
			response += "\nNew File Name (Required)";
		}		
		if(response == 'The following fields are required or have been incorrectly submitted:\n') {
			return true;
		}
		else {
			alert(response);
			return false;
		}	
	}
}
// ----------------------------------------------------------------------
// Validation for renaming a directory for "L Drive files/folders"
// ----------------------------------------------------------------------
function valLDriveRemoveDir() {
	var response = 'The following fields are required or have been incorrectly submitted:\n';	
	with(document.formLDriveRemoveDir) {
		if(formStrRemoveDirName.value == '') {
			response += "\nRemove Directory Name (Required)";
		}		
		if(response == 'The following fields are required or have been incorrectly submitted:\n') {
			return true;
		}
		else {
			alert(response);
			return false;
		}	
	}
}
// ----------------------------------------------------------------------
// Validation for renaming a file for "L Drive files/folders"
// ----------------------------------------------------------------------
function valLDriveRemoveFile() {
	var response = 'The following fields are required or have been incorrectly submitted:\n';	
	with(document.formLDriveRemoveFile) {
		if(formStrRemoveFileName.value == '') {
			response += "\nRemove File Name (Required)";
		}		
		if(response == 'The following fields are required or have been incorrectly submitted:\n') {
			return true;
		}
		else {
			alert(response);
			return false;
		}	
	}
}
// ----------------------------------------------------------------------
// Validation for inserting special events
// ----------------------------------------------------------------------
function valAddSpecialEvent() {
	var response = 'The following fields are required or have been incorrectly submitted:\n';	
	with(document.add_special_event) {
		for(i=1;i<special_event_entry.options.length;i++) {
			if(i>1) {
				var prev_entry = special_event_entry.options[i-1].value.split(':');
				var sel_entry = special_event_entry.options[i].value.split(':');				
				if(prev_entry[0] == sel_entry[0]) {
					response += "\nEVENT ENTRY (Duplicate Date [ " + sel_entry[0] + " ])";
				}
				event_tallie.value += '-';
			}
			event_tallie.value += special_event_entry.options[i].value;
		}	
		if(special_event_entry.options.length == 1) {
			response += "\nEVENT ENTRY (At least 1 addition is required)";
		}
		if(special_event_name.value == '' || special_event_name.value == 'EVENT NAME') {
			response += "\nEVENT NAME (Required)";
		}		
		if(response == 'The following fields are required or have been incorrectly submitted:\n') {
			special_event.value = 1;
			return true;
		}
		else {
			alert(response);
			return false;
		}	
	}
}
// ----------------------------------------------------------------------
// Validation for generating report type 2 (aircraft activity)
// ----------------------------------------------------------------------
function valReport2() {
	var response = 'The following fields are required or have been incorrectly submitted:\n';	
	with(document.popup_report2) {
		if(aircraft_id.options[aircraft_id.selectedIndex].value == '1') {
			response += "\nAircraft (Required)";
		}
		if(valDate(from_date.value)) {
			response += "\nFrom Date (Not a valid date)";
		}
		if(valDate(to_date.value)) {
			response += "\nTo Date (Not a valid date)";
		}
		if(response == 'The following fields are required or have been incorrectly submitted:\n') {
			return true;
		}
		else {
			alert(response);
			return false;
		}	
	}
}
// ----------------------------------------------------------------------
// Validation for generating report type 3 (aircraft flight log)
// ----------------------------------------------------------------------
function valReport3() {
	var response = 'The following fields are required or have been incorrectly submitted:\n';	
	with(document.popup_report3) {
		if(dispatch_id.options[dispatch_id.selectedIndex].value == '1') {
			response += "\nFlight Number (Required)";
		}
		if(response == 'The following fields are required or have been incorrectly submitted:\n') {
			submit();
		}
		else {
			alert(response);
			return false;
		}	
	}
}
// ----------------------------------------------------------------------
// Validation for generating report type 4 (pilot activity)
// ----------------------------------------------------------------------
function valReport4() {
	var response = 'The following fields are required or have been incorrectly submitted:\n';	
	with(document.popup_report4) {
		if(pilot_id.options[pilot_id.selectedIndex].value == '1') {
			response += "\nPilot (Required)";
		}
		if(valDate(from_date.value)) {
			response += "\nFrom Date (Not a valid date)";
		}
		if(valDate(to_date.value)) {
			response += "\nTo Date (Not a valid date)";
		}
		if(response == 'The following fields are required or have been incorrectly submitted:\n') {
			return true;
		}
		else {
			alert(response);
			return false;
		}	
	}
}
// ----------------------------------------------------------------------
// Validation for generating report type 5 (pilot currency)
// ----------------------------------------------------------------------
function valReport5() {
	var response = 'The following fields are required or have been incorrectly submitted:\n';	
	with(document.popup_report5) {
		if(pilot_id.options[pilot_id.selectedIndex].value == '1') {
			response += "\nPilot (Required)";
		}
		if(response == 'The following fields are required or have been incorrectly submitted:\n') {
			submit()
			return true;
		}
		else {
			alert(response);
			return false;
		}	
	}
}
// ----------------------------------------------------------------------
// Validation for generating report type 6 (pilot flightduty [day])
// ----------------------------------------------------------------------
function valReport6() {
	var response = 'The following fields are required or have been incorrectly submitted:\n';	
	with(document.popup_report6) {
		if(pilot_id.options[pilot_id.selectedIndex].value == '1') {
			response += "\nPilot (Required)";
		}
		if(valDate(date.value)) {
			response += "\nDate (Not a valid date)";
		}
		if(valTime(time.value)) {
			response += "\nTime (Not a valid time)";
		}
		if(response == 'The following fields are required or have been incorrectly submitted:\n') {
			return true;
		}
		else {
			alert(response);
			return false;
		}	
	}
}
// ----------------------------------------------------------------------
// Validation for generating report type 7 (pilot flightduty [yearly])
// ----------------------------------------------------------------------
function valReport7() {
	var response = 'The following fields are required or have been incorrectly submitted:\n';	
	with(document.popup_report7) {
		if(pilot_id.options[pilot_id.selectedIndex].value == '1') {
			response += "\nPilot (Required)";
		}
		if(year_id.options[year_id.selectedIndex].value == '1') {
			response += "\nYear (Required)";
		}
		if(response == 'The following fields are required or have been incorrectly submitted:\n') {
			return true;
		}
		else {
			alert(response);
			return false;
		}	
	}
}
// ----------------------------------------------------------------------
// Validation for generating report type 8 (pilot information sheet)
// ----------------------------------------------------------------------
function valReport8() {
	var response = 'The following fields are required or have been incorrectly submitted:\n';	
	with(document.popup_report8) {
		if(pilot_id.options[pilot_id.selectedIndex].value == '1') {
			response += "\nPilot (Required)";
		}
		if(response == 'The following fields are required or have been incorrectly submitted:\n') {
			submit()
			return true;
		}
		else {
			alert(response);
			return false;
		}	
	}
}
// ----------------------------------------------------------------------
// Validation for generating report type 9 (Aircraft Location Summary)
// ----------------------------------------------------------------------
function valReport9() {
	var response = 'The following fields are required or have been incorrectly submitted:\n';	
	with(document.popup_report9) {
		if(aircraft_id.options[aircraft_id.selectedIndex].value == '1') {
			response += "\nAircraft (Required)";
		}
		if(year_id.options[year_id.selectedIndex].value == '1') {
			response += "\nYear (Required)";
		}
		if(response == 'The following fields are required or have been incorrectly submitted:\n') {
			return true;
		}
		else {
			alert(response);
			return false;
		}	
	}
}
// ----------------------------------------------------------------------
// Validation for generating report type 10 (aircraft status sheet)
// ----------------------------------------------------------------------
function valReport10() {
	var response = 'The following fields are required or have been incorrectly submitted:\n';	
	with(document.popup_report10) {
		if(aircraft_id.options[aircraft_id.selectedIndex].value == '1') {
			response += "\nAircraft (Required)";
		}
		if(response == 'The following fields are required or have been incorrectly submitted:\n') {
			return true;
		}
		else {
			alert(response);
			return false;
		}	
	}
}
// ----------------------------------------------------------------------
// Validation for generating report type 11 (engine status sheet)
// ----------------------------------------------------------------------
function valReport11() {
	var response = 'The following fields are required or have been incorrectly submitted:\n';	
	with(document.popup_report11) {
		if(engine_id.options[engine_id.selectedIndex].value == '1') {
			response += "\nEngine (Required)";
		}
		if(response == 'The following fields are required or have been incorrectly submitted:\n') {
			return true;
		}
		else {
			alert(response);
			return false;
		}	
	}
}
// ----------------------------------------------------------------------
// Validation for generating report type 12 (APU status sheet)
// ----------------------------------------------------------------------
function valReport12() {
	var response = 'The following fields are required or have been incorrectly submitted:\n';	
	with(document.popup_report12) {
		if(apu_id.options[apu_id.selectedIndex].value == '1') {
			response += "\nAircraft (Required)";
		}
		if(response == 'The following fields are required or have been incorrectly submitted:\n') {
			return true;
		}
		else {
			alert(response);
			return false;
		}	
	}
}
// ----------------------------------------------------------------------
// Validation for generating report type 13 (Google KML)
// ----------------------------------------------------------------------
function valReport13() {
	var response = 'The following fields are required or have been incorrectly submitted:\n';	
	with(document.popup_report13) {
		if(dispatch_id.options[dispatch_id.selectedIndex].value == '1') {
			response += "\nFlight Number (Required)";
		}
		if(response == 'The following fields are required or have been incorrectly submitted:\n') {
			submit();
		}
		else {
			alert(response);
			return false;
		}	
	}
}

//dummy function
function selectDefault(){
	//This function was called at Additional fees popup window.
}

function alternateCss(){
	 //object of add_fees_detail selectbox
	 objAddFees=document.getElementById('add_fees_detail');
     for(i=0;i<objAddFees.options.length;i++){
       if(i%2==0){
         objAddFees.options[i].className='even';
	  }else{
		  objAddFees.options[i].className='odd';
	    }
	}
	//object of add_fees_detail selectbox
	 objAddFeesAmount=document.getElementById('add_fees_amount');
     for(i=0;i<objAddFeesAmount.options.length;i++){
       if(i%2==0){
         objAddFeesAmount.options[i].className='even';
	  }else{
		  objAddFeesAmount.options[i].className='odd';
	    }
	}
}
//function to convert to pound from kg
function changeKgP(leg_id){
 document.getElementById('uplift_'+leg_id).value=Math.round((document.getElementById('kg_uplift_'+leg_id).value)*(2.204627));
}
// -->


