$(document).ready(function() {
	//initialize the Google map
	initialize();

	//Get focus on frm_from_address
	$("#frm_from_address").focus(function() {
		$(this).data("hasfocus", true);
	});
	$("#frm_from_address").blur(function() {
		$(this).data("hasfocus", false);
	});
	
	//Get focus on frm_to_address
	$("#frm_to_address").focus(function() {
		$(this).data("hasfocus", true);
	});
	$("#frm_to_address").blur(function() {
		$(this).data("hasfocus", false);
	});

	//Get focus on frm_via_address
	$("#frm_via_address").focus(function() {
		$(this).data("hasfocus", true);
	});
	$("#frm_via_address").blur(function() {
		$(this).data("hasfocus", false);
	});

	//If one of the above fields has focus we catch the enter (keycode 13)
	$(document.body).keyup(function(ev) {
	    if (ev.which === 13 && $("#frm_from_address").data("hasfocus")) { fn_search_address('from'); }
	    if (ev.which === 13 && $("#frm_to_address").data("hasfocus")) { fn_search_address('to'); }
	    if (ev.which === 13 && $("#frm_via_address").data("hasfocus")) { fn_search_address('via'); }
	});
});
