var uniqueId;
var uniqueName;
var dcLoggedIn;
var FromPoint;
var ToPoint;
var MaximumPassengers;
var InfantsAdults;
var EconomyNotAvailable;
var BusinessNotAvailable;
var neweconomy;
var calendarWindow;

function calendarSelectDay(dayElName, monthElName, dayVal, monthVal)
{
	var dayEl = document.getElementById(dayElName);
	var monthEl = document.getElementById(monthElName);
	
	dayEl.selectedIndex = dayVal;
	monthEl.selectedIndex = monthVal;
	
	reloadCabins();
}

function checkIBE()
{
	var from = document.getElementById("drpFrom").value;
	var to = document.getElementById("drpTo").value;
	//var cabin = document.getElementById("fb_class").value;

	return checkCodeSharePax();
}

function selectPackageItem(packageSelected)
{
	//var cabin = document.getElementById("fb_class");
	var oneway = document.getElementById("chkOneWay");
	
	if (packageSelected)
	{
		//cabin.selectedIndex = 0;
		oneway.checked = false;
	}

	//cabin.disabled = packageSelected;
	oneway.disabled = packageSelected;
}

function isGrqAbzGrq(from, to, cabin)
{
	return ((from == 'GRQ' && to == 'ABZ') || (from == 'ABZ' && to == 'GRQ')) && (cabin == 'BF' || cabin == 'BR');
}

function displayMessage(code)
{
	var message = messages[code];
	if (message != null) alert(message);
}

function checkCodeSharePax()
{
	var from = document.getElementById("drpFrom").value;
	var to = document.getElementById("drpTo").value;

	if (isCodeShare(from, to))
	{
		var paxADT = document.getElementById("fb_numpaxADT");
		var paxCHD = document.getElementById("fb_numpaxCHD");
		
		if ((parseInt(paxADT.value) + parseInt(paxCHD.value)) > 4)
		{
			alert("The selected route is not operated by bmi, therefore a maximum of 4 passengers (including children) may be booked.");
			return false;
		}
	}

	return true;
}

function isCodeShare(from, to)
{
	var toPoints = eval(from)
	var i;
	
	for (i = 3; i < toPoints.length; i++) {
		if (toPoints[i][3] == to) return toPoints[i][0] == 1;
	}
}

function isTransatlantic(from, to)
{
	var toPoints = eval(from);
	var i;
	
	for (i = 3; i < toPoints.length; i++) {
		if (toPoints[i][3] == to)
			return (toPoints[i][0] == 0 && toPoints[i][1] == 1);
	}
}

function isPta(from, day, month)
{
	if (from == 'CGN' || from == 'DUS' || from == 'FRA' || from == 'HAM' || from == 'MUC' || from == 'STR') {
		var today = new Date();
		var intNow = today.getDate();
		var intYear = today.getFullYear();
		var intNowMonth = today.getMonth() + 1;
		var monarr = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
		if (((intYear % 4 == 0) && (intYear % 100 != 0)) || (intYear % 400 == 0)) monarr[1] = "29";
		if ((month == intNowMonth && day - intNow < 6) || (month == intNowMonth + 1 && (monarr[intNowMonth] - intNow) + day < 6))
			return true;
		else
			return false;
	}
	else
		return false;
}

function showNewEconomy(show, select)
{
	if (select == null) return;
	
	var selectValue = select.options[2] != null ? select.options[2].value : "";
	
	if (show && selectValue != 'N')
	{
		addOption(select, 2, "premium economy", 'N');
	}
	if (!show && selectValue == 'N')
	{
		if (select.selectedIndex == 2)
		{
			select.selectedIndex = 0;
		}
		select.options[2] = null;
	}
}

function checkNewEconomy()
{
	var from = drpFrom.value;
	var to = drpTo.value;
	
	if (from != '' && to != '')
	{
		showNewEconomy(isTransatlantic(from, to), document.getElementById('fb_class'));
	}
}

function getDate(direction)
{
	var day;
	var month;
	var dayName;
	var monthName;
	
	if (direction == 'out') {
		dayName = 'day0';
		monthName ='month0';
	}
	else {
		dayName = 'day1';
		monthName = 'month1';
	}
	
	day = document.getElementById(dayName).value;
	month = document.getElementById(monthName).value;
	
	document.domain = "flybmi.com";
	calendarWindow = window.open('http://www.flybmi.com/bmi/src/aspx/calendar.aspx?day=' + day + '&month=' + month + '&dayname=' + dayName + '&monthName=' + monthName, 'calendar', 'width=250,height=230,top=200,left=200,toolbars=no,scrollbars=no,status=no,resizable=no');
}

function depDateChanged()
{
	var depDay = document.getElementById("day0");
	var depMonth = document.getElementById("month0");
	var retDay = document.getElementById("day1");
	var retMonth = document.getElementById("month1");
	
	if (depMonth.selectedIndex > retMonth.selectedIndex)
	{
		retMonth.selectedIndex = depMonth.selectedIndex;
	}
	
	if (depDay.selectedIndex >= retDay.selectedIndex && depMonth.selectedIndex == retMonth.selectedIndex)
	{
		if (depDay.selectedIndex == depDay.options.length - 1)
		{
			retDay.selectedIndex = 0;
			
			if (retMonth.selectedIndex == retMonth.options.length - 1)
			{
				retMonth.selectedIndex = 0;
			}
			else
			{
				retMonth.selectedIndex++;
			}
		}
		else
		{
			retDay.selectedIndex = depDay.selectedIndex + 1;
		}
	}
}

function reloadCabins()
{
return;
	var to = drpTo.options[drpTo.selectedIndex].value;
	var from = drpFrom.options[drpFrom.selectedIndex].value;
	var toPoints = eval(from);
	var drpOutDay = document.getElementById("day0");
	var drpOutMon = document.getElementById("month0");
	var now = new Date(); now.setHours(0); now.setMinutes(0); now.setSeconds(0); now.setMilliseconds(0);
	var cutover = new Date(2005, 7, 1);
	var dtOut = new Date(now.getFullYear(), drpOutMon.options[drpOutMon.selectedIndex].value - 1, drpOutDay.options[drpOutDay.selectedIndex].value);

	if (dtOut < now)
	{
		dtOut.setFullYear(dtOut.getFullYear() + 1);
	}

	if (from == "" || to == "")
	{
		//alert("Using default scheduleCabins");
		loadFareCabins(scheduleCabins);
	}
	else
	{
		for (var i = 3; i < toPoints.length; i++)
		{
			if (toPoints[i][3] == to)
			{
				var index = toPoints[i][5];
				var fareset = eval(fareSets[index]);

				if (index == 0 && toPoints[i][0] == 0 && toPoints[i][1] == 0)
				{
					//alert("Using scheduleCabins_bmi");
					fareset = scheduleCabins_bmi;
				}
				else if (index == 0 && toPoints[i][1] == 1)
				{
					//alert("Using scheduleCabins_longhaul");
					fareset = scheduleCabins_longhaul;
				}
				else if (index > 0 && (dtOut < cutover))
				{
					//alert("Outbound before 1/8, using default fare set");
					fareset = fare_Default;
				}
				else
				{
					//alert("Using fareset " + index);
				}

				loadFareCabins(fareset);
			}
		}
	}
}

function loadFareCabins(fares)
{
return;
	var drpClass = document.getElementById("fb_class");
	var prev = drpClass.options[drpClass.selectedIndex].text;
	drpClass.options.length = 0;
	for (var j = 0; j < fares.length; j++)
	{
		drpClass.options[drpClass.options.length] = new Option(fares[j][1], fares[j][0]);
		if (prev == fares[j][1]) drpClass.selectedIndex = j;
	}
}

/*
  Local variables:
  mode: outline-minor
  End:
 */