function onewayTrip(){
    var fsp = document.flightsearchpod;
    fsp.returnDay.disabled = true;
    fsp.returnMonth.disabled = true;
    fsp.returnTime.disabled = true;
    tripType = "O";
    document.getElementById('returncalendarlink').style.display='none';
}

function returnTrip(){
    var fsp = document.flightsearchpod;
    fsp.returnDay.disabled = false;
    fsp.returnMonth.disabled = false;
    fsp.returnTime.disabled = false;
    tripType = "R";
    document.getElementById('returncalendarlink').style.display='';

}
var Maximum = 10;
function setOptions(chosen) {
    frm = document.flightsearchpod;
    var selbox = frm.numChildren;
    selbox.options.length = 0;
    var selbox2 = frm.numInfants;
    selbox2.options.length = 0;
    var box1 = frm.numAdults.options[frm.numAdults.selectedIndex].value;
    for(q=0;q<=box1;q++){
         selbox2.options[selbox2.options.length] = new Option(q,q);
    }
    for(i=0 ; i < Maximum ; i++){
        if (chosen == i) {
            selbox.options[selbox.options.length] = new Option(0,0);
            for(z=1;z <(Maximum-i) ; z++){
              selbox.options[selbox.options.length] = new Option(z,z);
            }
        }
    }
}

var today = new Date();
var dayz = today.getDate();
function zero(){
    var fsp = document.flightsearchpod;
    fsp.reset();
    fsp.departureDate.selectedIndex = dayz; 
    fsp.returnDay.selectedIndex = dayz; 
    calcDay('flightsearchpod','departureDate','departureMonth','PDayOfWeek');
    calcDay('flightsearchpod','returnDay','returnMonth','DDayOfWeek');
    fsp.departureAirport.focus();
}
var second_field_name="";
var field_name="";
var form_name="";
var myDoc=document;
popUpWindowWithReturn = new Function("field_value", "form_value", "page", "title", "height", "width", '\
                        field_name = field_value;\
                        form_name = form_value;\
                        options = "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=" + width + ",height=" + height;\
                        popup = open(page, title, options );\
                        if(navigator.appName == "Netscape"){\
                        popup.focus();\
                        }\
                        ');
popUpWindowWithReturnFor2Fields = new Function("field_value", "second_field_value", "form_value", "page", "title", "height", "width", '\
                        second_field_name = second_field_value;\
                        field_name = field_value;\
                        form_name = form_value;\
                        options = "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=" + width + ",height=" + height;\
                        popup = open(page, title, options );\
                        if(navigator.appName == "Netscape"){\
                        popup.focus();\
                        }\
                        ');
function airlineToTextInput(defaultAirlineCode) {
    var fsp = document.flightsearchpod;
    var airline_selected_code = fsp.popupAirlineCode.value;
    var airline_selected_name = fsp.popupAirlineName.value;
    if (defaultAirlineCode == null) {
        defaultAirlineCode = airline_selected_code;
    }
    var newHtml =       "<input type=\"hidden\" name=\"airlineCode\"          value=\"" + defaultAirlineCode + "\">";
    newHtml = newHtml + "<input type=\"hidden\" name=\"popupAirlineCode\"     value=\"" + airline_selected_code + "\">";
    newHtml = newHtml + "<input type=\"hidden\" name=\"popupAirlineName\"     value=\"" + airline_selected_name + "\">";
    newHtml = newHtml + "<input type=\"hidden\" name=\"airlineFromSelectBox\" value=\"false\">";
    newHtml = newHtml + "<input type=\"text\"   name=\"popupDisplayAirline\"  value=\"" + airline_selected_name + "\" class=\"formText0\">";
    var airSelectDiv = myDoc.getElementById("AirlineFilterDisplay");
    airSelectDiv.innerHTML=newHtml;
    fsp.popupDisplayAirline.disabled=true;
}
function synchronizeForm(){
    var fsp = document.flightsearchpod;
    fsp.departureAirport.focus();
    if (fsp.numAdults.options[fsp.numAdults.selectedIndex].value == '1' &&
        fsp.numChildren.options[fsp.numChildren.selectedIndex].value =='0' &&
        fsp.numInfants.options[fsp.numInfants.selectedIndex].value == 0) {
        setOptions(fsp.numAdults.options[fsp.numAdults.selectedIndex].value);
    }
    if (fsp.tripType[1].checked){
        fsp.tripType[1].checked=true;
    } else {
        fsp.tripType[0].checked = true;
    }
    calcDay("flightsearchpod","departureDay","departureMonth","PDayOfWeek");
    calcDay("flightsearchpod","returnDay","returnMonth","DDayOfWeek");
    var airlineCode=fsp.airlineCode.options[fsp.airlineCode.selectedIndex].value;
    if (airlineCode.length > 0){
        fsp.airlineName.value=fsp.airlineCode.options[fsp.airlineCode.selectedIndex].text;
    }
}
function checkEmail(){
  if(document.newsletter.sEmail.value=="") {
      document.newsletter.sEmail.focus();
      return false;
  } else {
      document.newsletter.submit(); 
  }
}
function swapDate(item,doIt){
    if(doIt==true){
        for (x=0;x<7;x++){
            if(days2[x].indexOf(item.innerHTML) !=-1){
                item.innerHTML=days2[x];
            }
        }
    }else{
        item.innerHTML=item.innerHTML.substr(0,3);
    }
}
function copyDestinationName() {
    var destinationList = document.getElementById('destination');
    var destElement = document.getElementById('destinationInput');
    var toCopy = destinationList.options[destinationList.selectedIndex];
    destElement.value = toCopy.innerHTML;
}
