<?php session_start();  ?>

<?php
if (isset($_POST['confirm']))
{
  include("route5.php");
  return;
}
else if (isset($_POST['calculate']))
{
  include("route5.php");
  return;
}


?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<title>jQuery Autocomplete</title>
	<script type="text/javascript" src="jquery.js"></script>
	<script type='text/javascript' src='jquery.autocomplete.js'></script>

	<link rel="stylesheet" type="text/css" href="jquery.autocomplete.css" />
</head>

<body>

<p>
<br>

  <a href="http://www.whistler.com/">
<img src="http://www.whistler.com/images/common/whistler.gif" border="0" /></a>


<br>
</p>

<form id="route" name="route" method="post" action="index.php">
  <p>
  <label>
  <input name="Routing" type="radio" value="return" <?php echo ( ($_POST['Routing']!="oneway")? 'checked="checked"' : "" ) ?> />
    Return</label>
  <br />
  <label>
  <input  name="Routing" type="radio" value="oneway"  <?php echo ( ($_POST['Routing']=="oneway")? 'checked="checked"' : "" ) ?> />
    One-way</label>
  <br />
 <br />
  <label> Number of Passengers: <br />
  <input name="passengers" type="text" value=<?php  echo isset($_POST['passengers'])? '"' . $_POST['passengers'] . '"' : '"1"' ?> size="5" />
  </label><br />
  </p>
  <label> Origin city or IATA airport code <br />
  <input name="destination0" class="ajax" type="text" value= <?php echo '"' . $_POST['destination0'] . '"' ?> size="20" />
  </label>

  <?php
  include("form.php");
  /*<label><br /> Destination city or IATA airport code<br />
  <input name="Destination" type="text" value="" size="20" />
  </label>*/

  ?>
  <p>

	<input name="AddMultiple" type="submit" value="add more destinations" />
	<input name="Remove" type="submit" value="remove destination" />
	<br/>
	<br/>
	 <input name="confirm" type="submit" value="calculate emissions" />
  </p>
</form>

<br>
  <a href="http://www.offsetters.ca">
<img src="http://www.trekescapes.com/offsetting/images/ofsetters-logo.gif" width="250" height="98" border="0" /></a>





<script type="text/javascript">
function findValue(li) {
	if( li == null ) return alert("No match!");

	// if coming from an AJAX call, let's use the CityId as the value
	if( !!li.extra ) var sValue = li.extra[0];

	// otherwise, let's just display the value in the text box
	else var sValue = li.selectValue;

	//alert("The value you selected was: " + sValue);
}

function selectItem(li) {
	findValue(li);
}

function formatItem(row) {
	//return row[0] + " (id: " + row[1] + ")";
	return row[0];
}

function lookupAjax(){
	var oSuggest = $("input.ajax")[0].autocompleter;

	oSuggest.findValue();

	return false;
}

$(document).ready(function() {
	$("input.ajax").autocomplete(
		"autocomplete_ajax.php",
		{
			delay:10,
			minChars:2,
			matchSubset:1,
			matchContains:1,
			cacheLength:10,
			onItemSelect:selectItem,
			onFindValue:findValue,
			formatItem:formatItem,
			autoFill:true
		}
	);
});
</script>




</body>
</html>