//Defines functions used to manipulate the letter code drop downs

function doSettingsForLetterCodes(depCityValue, arrCityValue) {
	doCommomSettingsForLetterCodes(depCityValue, arrCityValue);
	setDefaultLetterCode(document.main.classLetter);
	setDefaultLetterCode(document.main.classLetterReturn);
	setLetterCodeVisibility();
}
/*Performs the settings for letter codes without setting the default values*/
function doSettingsForLetterCodesWithoutDefault(depCityValue, arrCityValue){
	doCommomSettingsForLetterCodes(depCityValue, arrCityValue);
	setLetterCodeVisibility();
}
function depCityChanged(depCityPanel, arrCityPanel) {
  obDepChanged();
  updateCabinAndLetterCodes(depCityPanel, arrCityPanel, document.main.classType, document.main.classTypeReturn, document.main.classLetter, document.main.classLetterReturn);
}
function arrCityChanged(depCityPanel, arrCityPanel) {
	obArrivalChanged();
  updateCabinAndLetterCodes(depCityPanel, arrCityPanel, document.main.classType, document.main.classTypeReturn, document.main.classLetter, document.main.classLetterReturn);
}

function inbDepCityChanged(inbDepCityPanel, inbArrCityPanel) {
  ibDepChanged();
  updateCabinAndLetterCodes(inbDepCityPanel, inbArrCityPanel, document.main.classType, document.main.classTypeReturn, document.main.classLetter, document.main.classLetterReturn);
}

function inbArrCityChnaged(inbDepCityPanel, inbArrCityPanel) {
  ibArrivalChanged();
  updateCabinAndLetterCodes(inbDepCityPanel, inbArrCityPanel, document.main.classType, document.main.classTypeReturn, document.main.classLetter, document.main.classLetterReturn);
}

function cabinChanged(depCityPanel, arrCityPanel, isOutboundChange) {
	if (isOutboundChange) {
	obCabinChanged();
	}
  updateCabinAndLetterCodes(depCityPanel, arrCityPanel, document.main.classType, document.main.classTypeReturn, document.main.classLetter, document.main.classLetterReturn);
}

function changeBookingType() {
	setLetterCodeVisibility();
	bookingTypeChanged();
}
function setLetterCodeVisibility() {
	var newlySelectedSearch = getSearchType();
	// If the search type is MPM or SpendMiles then the class letter codes
	// fields should disappear from the panel
	if (newlySelectedSearch == "milesPlusMoney"
			|| newlySelectedSearch == "redeemMiles") {
		document.getElementById("classLetterFrom").style.visibility = "hidden";
		document.getElementById("classLetterImageFrom").style.visibility = "hidden";
		document.main.classLetter.style.visibility = "hidden";
		document.getElementById("classLetterTo").style.visibility = "hidden";
		document.getElementById("classLetterImageTo").style.visibility = "hidden";
		document.main.classLetterReturn.style.visibility = "hidden";
	}
	if (newlySelectedSearch == "exact_date"
			|| newlySelectedSearch == "lowest_fare") {
		document.getElementById("classLetterFrom").style.visibility = "visible";
		document.getElementById("classLetterImageFrom").style.visibility = "visible";
		document.main.classLetter.style.visibility = "visible";
		document.getElementById("classLetterTo").style.visibility = "visible";
		document.getElementById("classLetterImageTo").style.visibility = "visible";
		document.main.classLetterReturn.style.visibility = "visible";
	}
}
function setStyle(element){
	element.style.width = "40px";
	element.style.height = "18px";
}


