﻿<!-- Begin Google Map Interface -->
/*
    These scripts are dependant on the Google Map API
    For these to work 
    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key={YOUR GOOGLE MAP API KEY}" 
        type="text/javascript"></script>
    must be included prior to this file being included.
*/
//alert("maps stuff");
// -----------------------------------------------------------------------
//  IPGLatLong Map objects.
// -----------------------------------------------------------------------
function IPGLatLong(latitude, longitude)
{
    this.latitude = latitude;
    this.longitude = longitude;

    this.toGLatLng = function () {
            var googleLatLng = null;
            
            if(GLatLng)
            {
         //       alert("GLatLng defined");
                googleLatLng = new GLatLng(this.latitude, this.longitude);
            }
            else
            {
                alert("GLatLng not defined");
            }
            
            return googleLatLng;
        }
}

/*
    imageUrl - string - url of the pin's image.
    width - int - width of pin image.
    height - int - height of pin image.
    anchorX & anchorY - int - point that should touch map.
*/
function IPGPin(imageUrl, width, height, anchorX, anchorY)
{
    this.imageUrl = imageUrl;
    this.height = height;
    this.width = width,
    this.anchorX = anchorX;
    this.anchorY = anchorY;

    this.toGIcon = function (){
            var googleIcon = null;
            
            if(GIcon)
            {
        //    alert("GIcon defined: " + this.imageUrl);
                googleIcon = new GIcon();
                googleIcon.image = this.imageUrl;
                googleIcon.iconSize = new GSize(this.width, this.height);
                googleIcon.iconAnchor = new GPoint(this.anchorX, this.anchorY);
            }
            else
            {
                alert("GIcon not defined");
            }
            
            return googleIcon;
        }
}

/*
    locationId - string - unique identifier of this location.
    title - string - title of location.
    coordinates - IPGLatLong - location coordinates
    pin - IPGPin - icon to display at location.
*/
function IPGMapLocation(locationId,
    title, 
    coordinates, 
    pin)
{
    this.locationId = locationId;
    this.title = title;
    this.coordinates = coordinates;
    this.pin = pin;
    
    this.toGMarker = function(){
            var googleMarker = null;
            
            if(GMarker)
            {
     //           alert("GMarker defined");
                var options = { icon: this.pin.toGIcon(), title: this.title, clickable: false};
                
                googleMarker = new GMarker(this.coordinates.toGLatLng(), options);
               
            }
            else
            {
                alert("GMarker not defined");
            }
            
            return googleMarker;
        }
    
    this.toClickableGMarker = function(){
            var googleMarker = null;
            
            if(GMarker)
            {
    //            alert("GMarker defined");
                var options = { icon: this.pin.toGIcon(), title: this.title, clickable: true};
                
                googleMarker = new GMarker(this.coordinates.toGLatLng(), options);
            }
            else
            {
                alert("GMarker not defined");
            }
            
            return googleMarker;
        }
}

// -----------------------------------------------------------------------
//  Map functions
// -----------------------------------------------------------------------
/*
    mapContainerId - string - id of the object the map should be drawn 
                              into.
    location - IPGMapLocation - location to center map on.
*/
function LoadSideMap(mapContainerId, location)
{

    if(document.getElementById && GMap2)
    {
        var map = new GMap2(document.getElementById(mapContainerId));

        map.setCenter(location.coordinates.toGLatLng(), 16);
        map.addOverlay(location.toGMarker());
        map.addControl(new GSmallMapControl());
    }
}

<!--  End Google Map Interface  -->