<!--
function urlencode(value) {
   return value.replace(/ /g,"+");
}
function swap() {
   var tmp = document.calculator.from.value;
   document.calculator.from.value = document.calculator.to.value;
   document.calculator.to.value = tmp;
}
function home() {
   var form = document.calculator;
   var thepath = form.path.options[form.path.options.selectedIndex].value;
   if (thepath == '') {
      alert("Please select which type of calculation you want to get.");
      form.path.focus();
   } else if (thepath == 'closest-airport' ||
      thepath == 'nearest-airport' ||
      thepath == 'hotels-near' || thepath == 'cities-near' ||
      thepath == 'airlines' || thepath == 'lat-long') {
      if (form.to.value.length == 0) {
	 alert("Please enter a location.");
	 form.to.focus();
      } else {
	 window.location = "http://www.travelmath.com/" +
	    thepath + "/" + urlencode(form.to.value);
      }
   } else if (form.from.value.length == 0) {
      if (thepath == 'currency') {
	 alert("Please enter a starting currency.");
      } else {
	 alert("Please enter a starting location.");
      }
      form.from.focus();
   } else if (form.to.value.length == 0) {
      if (thepath == 'currency') {
	 alert("Please enter a second currency.");
      } else {
	 alert("Please enter a destination.");
      }
      form.to.focus();
   } else {
      window.location = "http://www.travelmath.com/" + thepath + "/from/" +
	 urlencode(form.from.value) + "/to/" + urlencode(form.to.value);
   }
   return false;
}
function changepath() {
   var thepath = document.calculator.path.options[document.calculator.path.options.selectedIndex].value;
   if (thepath == 'closest-airport' || thepath == 'hotels-near' ||
      thepath == 'nearest-airport' || thepath == 'cities-near') {
      document.getElementById('CalcFromRow').style.display = 'none';
      document.getElementById('CalcSwap').style.display = 'none';
      document.getElementById('CalcTo').innerHTML =
	 '<strong>near/in:</strong>';
   } else if (thepath == 'airlines') {
      document.getElementById('CalcFromRow').style.display = 'none';
      document.getElementById('CalcSwap').style.display = 'none';
      document.getElementById('CalcTo').innerHTML = '<strong>to:</strong>';
   } else if (thepath == 'lat-long') {
      document.getElementById('CalcFromRow').style.display = 'none';
      document.getElementById('CalcSwap').style.display = 'none';
      document.getElementById('CalcTo').innerHTML = '<strong>of:</strong>';
   } else {
      document.getElementById('CalcFromRow').style.display = '';
      document.getElementById('CalcSwap').style.display = '';
      document.getElementById('CalcTo').innerHTML = '<strong>To:</strong>';
   }
}
function redirect(form) {
   if (form.path.value == "flight-distance" ||
      form.path.value == "flying-distance" ||
      form.path.value == "flight-time" ||
      form.path.value == "flying-time" ||
      form.path.value == "drive-distance" ||
      form.path.value == "driving-distance" ||
      form.path.value == "drive-time" ||
      form.path.value == "driving-time" ||
      form.path.value == "nonstop-flights" ||
      form.path.value == "time-difference" ||
      form.path.value == "time-change" ||
      form.path.value == "cost-of-driving" ||
      form.path.value == "fuel-cost" ||
      form.path.value == "halfway-point" ||
      form.path.value == "currency" ||
      form.path.value == "flight-emissions") {
      if (form.from.value.length == 0) {
	 if (form.path.value == 'currency') {
	    alert("Please enter a starting currency.");
	 } else {
	    alert("Please enter a starting location.");
	 }
	 form.from.focus();
      } else if (form.to.value.length == 0) {
	 if (form.path.value == 'currency') {
	    alert("Please enter a second currency.");
	 } else {
	    alert("Please enter a destination.");
	 }
	 form.to.focus();
      } else {
	 window.location = "http://www.travelmath.com/" +
	    form.path.value + "/from/" + urlencode(form.from.value) +
	    "/to/" + urlencode(form.to.value);
      }
   } else if (form.path.value.length > 0) {
      if (form.to.value.length == 0) {
	 alert("Please enter a location.");
	 form.to.focus();
      } else {
	 window.location = "http://www.travelmath.com/" +
	    form.path.value + "/" + urlencode(form.to.value);
      }
   }
   return false;
}
// -->

