﻿function initialize(lat, lng, zoom) {

    if (GBrowserIsCompatible()) {

        var map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(lat, lng), zoom);

        map.addControl(new GMapTypeControl());
        map.addControl(new GSmallMapControl());

        var tiny = new GIcon();
        tiny.iconSize = new GSize(32, 33);
        tiny.iconAnchor = new GPoint(6, 20);

        for (var i = 0; i < locations.length; i++) {

            var array2 = locations[i].split(",");

            var point = new GLatLng(array2[0], array2[1]);

            var title = array2[2];
            var desc = array2[3];
            var link = array2[4];

            tiny.image = "http://www.sceneonscreen.co.uk/media/images/location" + (i + 1) + ".gif";

            var marker = new GMarker(point, {icon: tiny});

            function createMarker(point, i, title, desc, link) {

                // Create a lettered icon for this point using our icon class
                // var letter = String.fromCharCode("A".charCodeAt(0) + index);
                var customIcon = new GIcon();

                customIcon.iconSize = new GSize(32, 33);
                customIcon.iconAnchor = new GPoint(9, 34);
                customIcon.infoWindowAnchor = new GPoint(9, 2);

                //letteredIcon.image = "http://www.google.com/mapfiles/marker" + letter + ".png";
                customIcon.image = "/media/images/mapicons/" + (i + 1) + ".gif";

                // Set up our GMarkerOptions object
                markerOptions = { icon: customIcon };
                var marker = new GMarker(point, markerOptions);

                GEvent.addListener(marker, "click", function() {
                marker.openInfoWindowHtml("<b>" + title + "</b><br />" + desc + "<br /><br /><a class='gmaplink' title='" + title + "' href='" + link + "'>more ></a>");
                });
                return marker;

            }

            map.addOverlay(createMarker(point, i, title, desc, link));

        }
    }
}







