
		var city, dist;
		var mapsloaded = false;

		$.ui.dialog.defaults.bgiframe = true;
		$.ui.dialog.defaults.autoOpen = false;
		$.ui.dialog.defaults.minWidth = 500;
		$(function() {
			$("#calcdist").dialog({ width: 500, height: 220 });
		});
		
		function loadMaps()
		{
			resetTravel();
			if(mapsloaded == true)
			{
				$(function() {
					$("#calcdist").dialog('open');
				});
			}
			else
			{
				mapsloaded = true;
				google.load("maps", "2", {"callback" : mapsLoad});
				$(function() {
					$("#calcdist").dialog('open');
				});
			}
		}
		function mapsLoad()
		{
			dirs = new GDirections();
			GEvent.addListener(dirs, "load", dirsLoad);
			$("#calcdist_loader").fadeOut(500);
			$("#calcdist_content").fadeIn(500);
		}
		function calcDist()
		{
			city = document.getElementById("city").value;
			dirs.load("from: 55431 to: " + city);
			resetTravel();
		}
		function dirsLoad()
		{
			//weddingprice = 3000;
			dist = dirs.getDuration().seconds;
			var hours = Math.round((dist / 3600 - 0.01) * 2) / 2;
//			alert(city + " is " + (Math.round((dist / 3600 - 0.2) * 2) / 2) + " hours away");
			
			if(hours < 1)
			{
				var basecost = 0;
				var carprice = 0;
				var subtotal = 0;
				var total = weddingprice

				setTravel('basecost', basecost);
				setTravel('cartime', carprice);
				setTravel('subtotal', subtotal);
				setTravel('total', total);
			}
			else if(hours < 2)
			{
				var basecost = 25;
				var carprice = 30 * hours;
				var subtotal = basecost + carprice;
				var total = subtotal + weddingprice

				setTravel('basecost', basecost);
				setTravel('cartime', carprice);
				setTravel('subtotal', subtotal);
				setTravel('total', total);
			}
			else if(hours <= 6)
			{
				var basecost = 100;
				var carprice = 30 * hours;
				var subtotal = basecost + carprice;
				var total = subtotal + weddingprice

				setTravel('basecost', basecost);
				setTravel('cartime', carprice);
				setTravel('subtotal', subtotal);
				setTravel('total', total);
			}
			else
			{
				var basecost = 200;
				var airfare = 500;
				var subtotal = basecost + airfare;
				var total = subtotal + weddingprice

				setTravel('basecost', basecost);
				setTravel('airfare', airfare);
				setTravel('subtotal', subtotal);
				setTravel('total', total);
			}
		}

		function resetTravel()
		{
//			document.getElementById("city").value = "";
			$('#basecost').html('--&nbsp;&nbsp;&nbsp;');
			$('#cartime').html('--&nbsp;&nbsp;&nbsp;');
			$('#airfare').html('--&nbsp;&nbsp;&nbsp;');
			$('#subtotal').html('--&nbsp;&nbsp;&nbsp;');
			$('#total').html('--&nbsp;&nbsp;&nbsp;');
		}
		function setTravel(item, itemvalue)
		{
			$('#' + item).html('$' + itemvalue + '&nbsp;&nbsp;&nbsp;');
		}
