/************************************************************************
 *                                                                      *
 *  emMaps.js   JavaScript to control Google Maps on the Travel script  *
 *                                                                      *
 *  since: 19.04.2010   author: Shawky Elmoazamy <shmz30@gmail.com>    *
 *                                                                      *
 ************************************************************************/

/***
 *  Init Google Map
 ***/
function initialize(){
    //init map
    var map = new google.maps.Map2(document.getElementById("map1"));
    var geocoder = new GClientGeocoder(); //geocoder

    //customize map view
    map.addControl(new GSmallMapControl());
    map.addControl(new GMapTypeControl());

    //open a desired address
    showAddress(addressToShow,markerHTML);

    /***
     *  Creates a Marker on the Map
     ***/
    function createMarker(latlng, message) {
        var marker = new GMarker(latlng);

        if(message){
            GEvent.addListener(marker,"click", function() {
                map.openInfoWindowHtml(latlng, message);
            });
        }

        return marker;
    }

    /***
     *  Add a Pointer at a desired Address on the Map
     ***/
    function showAddress(address, html) {
        if (geocoder) {
            if(!html) {
                html = address;
            }

            geocoder.getLatLng(
                address,
                function(point) {
                    if (!point) {
                        alert(address + " not found");
                    } else {
                        map.setCenter(point, mapZoomLevel);
			map.setMapType(G_HYBRID_MAP);
			map.enableRotation();

                        var marker = new GMarker(point);
                        map.addOverlay(marker);
                        marker.openInfoWindowHtml(html);

                        GEvent.addListener(marker,"click", function() {
                            map.openInfoWindowHtml(point, html);
                        });
                    }
                }
            );

        }

    } //showAddress

}
