// Air travel javascript file

//Look-up Table Lists
var lookUp = new Array();

lookUp['Long Haul'] = new Array('0.11');
lookUp['Short (International)'] = new Array('0.13');
lookUp['Short (Domestic)'] = new Array('0.16');


function setLookUp()
  {
  typeTravelSel = document.getElementById('typeTravel');
  lookUpSel = document.getElementById('lookUp');

  lookUpList = lookUp[typeTravelSel.value];
  
  changeSelect(lookUpSel, lookUpList);
  }


function changeSelect(fieldObj, valuesAry, optTextAry, selectedValue) 
  {
  //Clear the select list
  fieldObj.options.length = 0;

  //Set the option text to the values if not passed
  optTextAry = (optTextAry)?optTextAry:valuesAry;

  //Itterate through the list and create the options
  for (i in valuesAry) 
    {
    selectFlag = (selectedValue && selectedValue==valuesAry[i])?true:false;
    fieldObj.options[fieldObj.length] = new Option(optTextAry[i], valuesAry[i], false, selectFlag);
    }
  }


function update(value)
  {
  if (value == "Long Haul")
    {
    document.getElementById('numTravel').value="6";
    document.getElementById('distanceTravel').value="6482";
    var d = 6*6482*2;

    document.getElementById('distanceAnnum').value=d;
    }

  else if (value == "Short (International)")
    {
    document.getElementById('numTravel').value="2";
    document.getElementById('distanceTravel').value="926";
    var d = 2*926*2;

    document.getElementById('distanceAnnum').value=d;
    }

  else if (value == "Short (Domestic)")
    {
    document.getElementById('numTravel').value="4";
    document.getElementById('distanceTravel').value="463";
    var d = 4*463*2;

    document.getElementById('distanceAnnum').value=d;
    }
  }


function updateAnnual(value)
  {
  var annualDistance;
  distanceTravelSel = document.getElementById('distanceTravel');

  annualDistance = value * distanceTravelSel.value * 2;
  document.getElementById('distanceAnnum').value= annualDistance;
  }


