
// Wait for user finishing typing
// callback: The callback function
// wait: The number of milliseconds to wait after the the last key press before firing the callback
// highlight: Highlights the element when it receives focus
// allowSubmit: Allows a non-multiline element to be submitted (enter key) regardless of captureLength
// captureLength: Minimum # of characters necessary to fire the callback

$(document).ready(function() {
            
	alert("mainjs loaded");
	$('#street').typeWatch({
		captureLength: 2,
		wait: 1750,
    		highlight: true,
		callback: function(value) {
			//alert("typing finished");
			street_to_geo(value);
		}
	});
});


function street_to_geo(street){
      //encodes the street string into url friendly format
      var street_encoded = encodeURIComponent(street);
      var uri = "http://nominatim.openstreetmap.org/search/" + street_encoded + "?format=json";
      //alert(uri);
      //makes the the jquery call and gets json back 
      $.getJSON(uri, function(data) {
        //make js obj containing lat and long
        var obj = {latitude: data[0].lat, longitude: data[0].lon};
        alert(obj.latitude + " " + obj.longitude);
        //return obj; 
      });
      
    }



@@ -1208,19 +1208,501 @@
 %7D);%0A
-      %0A    
+%7D%0A%0Afunction calc_distance(lat1, lon1, lat2, lon2) %7B%0A%09var unit = %22K%22;%0A%09var radlat1 = Math.PI * lat1/180;%0A%09var radlat2 = Math.PI * lat2/180;%0A%09var theta = lon1-lon2;%0A%09var radtheta = Math.PI * theta/180;%0A%09var dist = Math.sin(radlat1) * Math.sin(radlat2) + Math.cos(radlat1) * Math.cos(radlat2) * Math.cos(radtheta);%0A%09dist = Math.acos(dist);%0A%09dist = dist * 180/Math.PI;%0A%09dist = dist * 60 * 1.1515;%0A%09if (unit==%22K%22) %7B dist = dist * 1.609344; %7D%0A%09if (unit==%22N%22) %7B dist = dist * 0.8684; %7D%0A%09return dist;%0A
 %7D%0A%0A%0A

Update main.js