jQuery(function () {
                            gd_initialize_ac();
                        });
                        
                        function gd_initialize_ac() {
                            if (window.gdMaps == 'google') {
                                // Create the autocomplete object, restricting the search
                                // to geographical location types.
                                autocomplete = new google.maps.places.Autocomplete(
                                    /** @type {HTMLInputElement} */(document.getElementById('detail_page_map_canvas_fromAddress')),
                                    {types: ['geocode']});
                                // When the user selects an address from the dropdown,
                                // populate the address fields in the form.
                                google.maps.event.addListener(autocomplete, 'place_changed', function () {
                                    gd_fillInAddress_ac();
                                });
                            } else {
                                jQuery('#detail_page_map_canvas_fromAddress').hide();
                                jQuery('.gd-get-directions').hide();
                                jQuery('.detail_page_map_canvas_getdirection').hide();
                                
                                if (window.gdMaps == 'osm') {
                                    window.setTimeout(function() {
                                        calcRoute('detail_page_map_canvas');
                                    }, 1000);
                                }
                            }
                        }

                        function gd_fillInAddress_ac() {
                            //submit the form
                            jQuery('#directions').trigger('click');
                        }