/*
 * Methods to set maps properly based on addresses
 */
function showAddress(geocoder, map, address) {
    geocoder.getLatLng(address, function(point) {
        if (!point) {
            alert(address + " not found");
        } else {
            map.disableDragging();
            map.setCenter(point, 15);
            var marker = new GMarker(point);
            map.addOverlay(marker);
            GEvent.addListener(map, "click", function() {
                window.open("http://maps.google.com/maps?q=" + address + "&iwloc=A&hl=en");
            });
        }
    });
}

$(document).ready(function() {
    var gc = new GClientGeocoder();
    $('.gmap').each(function() {
        showAddress(gc, new GMap2(this), $(this).attr("addr"));
    });
});
