 //<!--------------------------------------------------------------------------------------
//	
//	Name	:	datefile.js
//
//	Author	:	Derek Mc Connon
//
//	Date		:	Thursday, April 15th 2004
//
//	Desc		:	Java Source File Containing Javascript code
//				for Schedule Section
//
//-------------------------------------------------------------------------------------->

Now = new Date();
NowDay = Now.getDate();
NowMonth = Now.getMonth();
NowYear = Now.getYear();

if (NowYear < 2000) NowYear += 1900; //for Netscape

function SetToSearched() {
	ChangeOptionDays();
}

//function to set options to today
function SetToToday() {
	DaysObject = eval("document.schedule.DAY");
	MonthObject = eval("document.schedule.MONTH");
	
	MonthObject[NowMonth].selected = true;
	ChangeOptionDays();
	DaysObject[NowDay-1].selected = true;
}

//function to change the available days in a months
function ChangeOptionDays() {
	DaysObject = eval("document.schedule.DAY");
	MonthObject = eval("document.schedule.MONTH");

	Month = MonthObject[MonthObject.selectedIndex].text;
	
	Year = NowYear;

	DaysForThisSelection = DaysInMonth(Month, Year);

	CurrentDaysInSelection = DaysObject.length;

	if (CurrentDaysInSelection > DaysForThisSelection) {
		for (i=0; i<(CurrentDaysInSelection-DaysForThisSelection); i++) {
			DaysObject.options[DaysObject.options.length - 1] = null
		}
	}

	if (DaysForThisSelection > CurrentDaysInSelection) {
		for (i=0; i<(DaysForThisSelection-CurrentDaysInSelection); i++) {
			NewOption = new Option(DaysObject.options.length + 1, DaysObject.options.length + 1);
			DaysObject.add(NewOption);
		}
	}	
		
	if (DaysObject.selectedIndex < 0) DaysObject.selectedIndex == 0;
}

//function for returning how many days there are in a month including leap years
function DaysInMonth(WhichMonth, WhichYear) {
	var DaysInMonth = 31;
	if (WhichMonth == "Apr" || WhichMonth == "Jun" || WhichMonth == "Sep" || WhichMonth == "Nov") DaysInMonth = 30;
	if (WhichMonth == "Feb" && (WhichYear/4) != Math.floor(WhichYear/4))	DaysInMonth= 28;
	if (WhichMonth == "Feb" && (WhichYear/4) == Math.floor(WhichYear/4))	DaysInMonth = 29;
	if (WhichMonth == "April" || WhichMonth == "June" || WhichMonth == "September" || WhichMonth == "November") DaysInMonth = 30;
	if (WhichMonth == "February" && (WhichYear/4) != Math.floor(WhichYear/4))	DaysInMonth= 28;
	if (WhichMonth == "February" && (WhichYear/4) == Math.floor(WhichYear/4))	DaysInMonth = 29;
	
	return DaysInMonth;
}

function sendmsg() { 
	document.schedule.action = "/aerlingus_script/cms/flight_schedules.cgi";				
	document.schedule.method = "post";				
	document.schedule.submit(document.schedule);
}                          

if(document.getElementById) { // IE 5 and up, NS 6 and up
	var upLevel = true;
} else if(document.layers) { // Netscape 4
	var ns4 = true;
} else if(document.all) { // IE 4
	var ie4 = true;
}

function showObject(obj) {
	if (ns4) {
		obj.visibility = "show";
	} else if (ie4 || upLevel) {
		obj.style.visibility = "visible";
	}
}

function hideObject(obj) {
	if (ns4) {
		obj.visibility ="hide";
	}
	if (ie4 || upLevel) {
		obj.style.visibility = "hidden";
	}
}	

function clearDetails(field,text) {
	if(field.value==text) {
		field.value="";
	}
}

function reenterDetails(field, text) {
	if(field.value=="") {
		field.value=text;
	}
}

function sendmsg1() { 
	var AWB = document.trackingsearch.awbnum.value;
	var AWBLength = AWB.length;

	if((AWB == "")||(AWB == "enter number")) {
		alert("Air Waybill number must be entered");
		document.trackingsearch.awbnum.focus();
		document.trackingsearch.awbnum.select();
	} else if (isNaN(AWB)) {
		alert("Air Waybill number must be numeric");
		document.trackingsearch.awbnum.focus();
		document.trackingsearch.awbnum.select();	
	} else if (AWBLength != 8) {
		alert("Air Waybill number must be 8 digits");
		document.trackingsearch.awbnum.focus();
		document.trackingsearch.awbnum.select();	
	} else {
		document.trackingsearch.action = "/aerlingus_script/cms/airwaybill_tracking.cgi";				
		document.trackingsearch.method = "post";				
		document.trackingsearch.submit(document.tracking);
	}
}          

function openwindow(loc,url) {
	window.open(url,loc,'left=0,top=0,scrollbars=yes,resizable=1,status=auto,toolbar=1');
}
               

