var SAMPLE_POST = HOST_URL + '/geocoding/v1/address?key=YOUR_KEY_HERE&location=Lancaster,PA&callback=renderGeocode';

function showBasicURL() {
    var safe = SAMPLE_POST;
    document.getElementById('basicSampleUrl').innerHTML = safe.replace(/</g, '&lt;').replace(/>/g, '&gt;');
};

function doClick() {
    var script = document.createElement('script');
    script.type = 'text/javascript';
    showBasicURL();
    var newURL = SAMPLE_POST.replace('YOUR_KEY_HERE', APP_KEY);
    script.src = newURL;
    document.body.appendChild(script);
};

function renderGeocode(response) {
    var html = '';
    var i = 0;
    var j = 0;
	
	html = "<p>Location: ";
	var location = response.results[0].locations[0];
	html += location.adminArea5 + ", " + location.adminArea4 + ", " + location.adminArea3 + ", " + location.adminArea1 + "(" + location.latLng.lat + ", " + location.latLng.lng + ")";
  	html += "</p>";
    
    document.getElementById('narrative').innerHTML = html;
}
