function map(pMapDivID)
{
    this._init(pMapDivID);
}

map.prototype.id;
map.prototype.title;
map.prototype.parentID;
map.prototype.zoom;
map.prototype.detailMode;
map.prototype.markers;
map.prototype.onMarkerClick;
map.prototype.maptype;
map.prototype.cities
map.prototype.brands;
map.prototype.nearby;

map.prototype._mapDivID;
map.prototype._map;
map.prototype._useCustom;
map.prototype._customMap;

map.prototype._yellowIcon;
map.prototype._blueIcon;
map.prototype._redIcon;

map.prototype._latitude;
map.prototype._longitude;
map.prototype._customTiles;

map.prototype.brandFilter = -1;

map.prototype.loadFromXML = function(pXML, pDetailMode, pDelayMapRefresh)
{
    // XML:
    // <mapdata>
    //     <id></id>
    //     <title></title>
    //     <latitude></latitude>
    //     <longitude></longitude>
    //     <zoom></zoom>
    //     <customtiles></customtiles>
    //     <parentid></parentid>
    //     <maptype></maptype>
    //     <markers>
    //         <marker>
    //             <id></id>
    //             <text></text>
    //             <latitude></latitude>
    //             <longitude></longitude>
    //             <newhotels></newhotels>
    //             <existinghotels></existinghotels>
    //             <allhotels></allhotels>
    //             <hotels>
    //                 <hotel>
    //                     <name></name>
    //                     <address></address>
    //                     <openingDate></openingDate>
    //                     <imageUrl></imageUrl>
    //                     <brandImageUrl></brandImageUrl>
    //                     <meetLink1></meetLink1>
    //                     <resLink1></resLink1>
    //                     <detLink1></detLink1>
    //                 </hotel>
    //             </hotels>
    //         </marker>
    //     </markers>
    //     <cities>
    //         <city>
    //             <title></title>
    //             <latitude></latitude>
    //             <longitude></longitude>
    //         </city>
    //     </cities>        
    // </mapdata>   

    var oXMLDom     = this._getXMLDom(pXML);
    var nodeMapData = this._getFirstChildXMLNode(oXMLDom, "mapdata");
   
    // Get the top level data   
    this.id       = this._getFirstChildXMLNodeValue(nodeMapData, "id");
    this.title    = this._getFirstChildXMLNodeValue(nodeMapData, "title");
    this.parentID = this._getFirstChildXMLNodeValue(nodeMapData, "parentid");
    this.zoom     = parseInt(this._getFirstChildXMLNodeValue(nodeMapData, "zoom"));
    this.maptype  = this._getFirstChildXMLNodeValue(nodeMapData, "maptype");
    this.brands   = this._getFirstChildXMLNodeValue(nodeMapData, "brands").split('|');
    
    this._latitude    = parseFloat(this._getFirstChildXMLNodeValue(nodeMapData, "latitude"));
    this._longitude   = parseFloat(this._getFirstChildXMLNodeValue(nodeMapData, "longitude"));
    this._customTiles = (this._getFirstChildXMLNodeValue(nodeMapData, "customtiles") == "True");

    GLOBAL_MAPID = this.id;

    // Get the markers
    this.markers = new Array();
    
    var nodeMarkers = this._getFirstChildXMLNode(nodeMapData, "markers");
    
    if (nodeMarkers != null)
    {
        var arrMarkerNodes = this._getChildXMLNodes(nodeMarkers, "marker");
        
        if (arrMarkerNodes != null)
        {
            for (var ii = 0; ii < arrMarkerNodes.length; ii++)
            {
                var oMapMarker = new mapMarker();

                oMapMarker.id             = this._getFirstChildXMLNodeValue(arrMarkerNodes[ii], "id");
                oMapMarker.text           = this._getFirstChildXMLNodeValue(arrMarkerNodes[ii], "text");
                oMapMarker.latitude       = parseFloat(this._getFirstChildXMLNodeValue(arrMarkerNodes[ii], "latitude"));
                oMapMarker.longitude      = parseFloat(this._getFirstChildXMLNodeValue(arrMarkerNodes[ii], "longitude"));
                oMapMarker.newHotels      = this._getFirstChildXMLNodeValue(arrMarkerNodes[ii], "newhotels").split('|');
                oMapMarker.existingHotels = this._getFirstChildXMLNodeValue(arrMarkerNodes[ii], "existinghotels").split('|');
                oMapMarker.allHotels      = this._getFirstChildXMLNodeValue(arrMarkerNodes[ii], "allhotels").split('|');
                
                // Add in the hotels associated with this marker
                var nodeHotels = this._getFirstChildXMLNode(arrMarkerNodes[ii], "hotels");
                
                if (nodeHotels != null)
                {
                    var arrHotelNodes = this._getChildXMLNodes(nodeHotels, "hotel");

                    for (var jj = 0; jj < arrHotelNodes.length; jj++)
                    {
                        var oMapHotel = new mapHotel();

                        oMapHotel.name          = this._getFirstChildXMLNodeValue(arrHotelNodes[jj], "name");
                        oMapHotel.address       = this._getFirstChildXMLNodeValue(arrHotelNodes[jj], "address");
                        oMapHotel.openingDate   = this._getFirstChildXMLNodeValue(arrHotelNodes[jj], "openingdate");
                        oMapHotel.showDate      = this._getFirstChildXMLNodeValue(arrHotelNodes[jj], "showdate");
                        oMapHotel.imageUrl      = this._getFirstChildXMLNodeValue(arrHotelNodes[jj], "imageurl");
                        oMapHotel.brandImageUrl = this._getFirstChildXMLNodeValue(arrHotelNodes[jj], "brandimageurl");
                        oMapHotel.meetLink1     = this._getFirstChildXMLNodeValue(arrHotelNodes[jj], "meetlink1");
                        oMapHotel.resLink1      = this._getFirstChildXMLNodeValue(arrHotelNodes[jj], "reslink1");
                        oMapHotel.detLink1      = this._getFirstChildXMLNodeValue(arrHotelNodes[jj], "detlink1");

                        oMapMarker.hotels.push(oMapHotel);                
                    }    
                }
                
                this.markers.push(oMapMarker);                
            }    
        }    
    }
    
    // Get Cities
    this.cities = new Array();
    
    var nodeCities = this._getFirstChildXMLNode(nodeMapData, "cities");
    
    if (nodeCities != null)
    {
        var arrCityNodes = this._getChildXMLNodes(nodeCities, "city");
        
        if (arrCityNodes != null)
        {
            for (var ii = 0; ii < arrCityNodes.length; ii++)
            {
                var oCity = new mapCity();
                
                oCity.title = this._getFirstChildXMLNodeValue(arrCityNodes[ii], "title");
                oCity.latitude = this._getFirstChildXMLNodeValue(arrCityNodes[ii], "latitude");
                oCity.longitude = this._getFirstChildXMLNodeValue(arrCityNodes[ii], "longitude");
                
                this.cities.push(oCity);
            }
            
        }
    }
    
    // Get Nearby Points
    this.nearby = new Array();
    
    var nodeNearby = this._getFirstChildXMLNode(nodeMapData, "nearby");
    
    if (nodeNearby != null)
    {
        var arrNearbyNodes = this._getChildXMLNodes(nodeNearby, "point");
        
        if (arrNearbyNodes != null)
        {
            for (var ii = 0; ii < arrNearbyNodes.length; ii++)
            {
                var oPoint = new mapNearbyPoint();
                
                oPoint.title = this._getFirstChildXMLNodeValue(arrNearbyNodes[ii], "title");
                oPoint.mapid = this._getFirstChildXMLNodeValue(arrNearbyNodes[ii], "mapid");
                oPoint.latitude = this._getFirstChildXMLNodeValue(arrNearbyNodes[ii], "latitude");
                oPoint.longitude = this._getFirstChildXMLNodeValue(arrNearbyNodes[ii], "longitude");
                
                this.nearby.push(oPoint);
            }
        }
    }
    

    if (pDetailMode != null)
    {
        this.detailMode = pDetailMode;
    }



    if (!pDelayMapRefresh)
    {
        this.refreshMap();
    }    
}

map.prototype.setDetailMode = function(pDetailMode)
{
    this.detailMode = pDetailMode;

    this.refreshMap();
}

map.prototype.setBrandFilter = function(pBrandFilter)
{
    this.brandFilter = pBrandFilter;
    this.refreshMap();
}

map.prototype.refreshMap = function () {
    // If we are switching between google and custom tiles (there must be a better way of doing this!)
    this._map = new GMap2(document.getElementById(this._mapDivID));

    // AP: moved map ref out of if and forced tile refresh if custom tiles are specified (different levels will 
    // need different tiles)

    if (this._customTiles) {
        this._map.disableDoubleClickZoom();
        this._map.disableDragging();

        // Create a Custom Map for the custom tiles
        var oCopyright = new GCopyright(1, new GLatLngBounds(new GLatLng(-90, -180), new GLatLng(90, 180)), 0, "");
        var oCopyrightCollection = new GCopyrightCollection("");

        oCopyrightCollection.addCopyright(oCopyright);

        var oTileLayers = [new GTileLayer(oCopyrightCollection, 1, 17)];
        oTileLayers[0].getTileUrl = this._getTileUrl;

        this._customMap = new GMapType(oTileLayers, new GMercatorProjection(18), "", { errorMessage: "No data available" });

        this._map.addMapType(this._customMap);
        this._map.setMapType(this._customMap);

        this.useCustom = this._customTiles;
    }
    else {
        // Clear the markers
        this._clearMarkers();
        this.useCustom = false;
    }





    if (this._customTiles) {
        this._map.setCenter(new GLatLng(this._latitude, this._longitude), this.zoom, this._customMap);
    }
    else {
        // City average calcs
        var iPointCount = 0;
        var fLat = 0;
        var fLng = 0;
        var oPointBounds = new GLatLngBounds();

        for (var ii = 0; ii < this.markers.length; ii++) {
            var arrTotal;
            var oMarker = this.markers[ii];
            switch (this.detailMode) {
                case 0:
                    {
                        arrTotal = oMarker.allHotels;
                        break;
                    }
                case 1:
                    {
                        arrTotal = oMarker.newHotels;
                        break;
                    }
                case 2:
                    {
                        arrTotal = oMarker.existingHotels;
                        break;
                    }
            }

            if (this._showPoint(arrTotal)) {
                iPointCount++;
                fLat += oMarker.latitude;
                fLng += oMarker.longitude;
                oPointBounds.extend(new GLatLng(oMarker.latitude, oMarker.longitude));
            }
        }

        if (iPointCount == 0) {
            this._map.setCenter(new GLatLng(this._latitude, this._longitude), this.zoom);
        }
        else {
            this._map.setCenter(oPointBounds.getCenter(), Math.min(15, this._map.getBoundsZoomLevel(oPointBounds)));
        }
    }


    if (this.maptype == 'WORLD') {
        var oMask = new Mask();
        this._map.addOverlay(oMask);
    }

    //var oHelp = new HelpLink();
    //this._map.addOverlay(oHelp)

    if (this.id.toString() == "-1") {
        var oAfrica = new GPolygon([new GLatLng(35.39, -5.58), new GLatLng(30.98, 31.95), new GLatLng(7.67, 49.44), new GLatLng(-33.65, 21.97), new GLatLng(3.67, 9.23), new GLatLng(5.35, -13), new GLatLng(35.39, -5.58)]);
        var oRussia = new GPolygon([new GLatLng(49.80, 43.51), new GLatLng(55.45, 69.45), new GLatLng(50.51, 99.67), new GLatLng(53.59, 122.94), new GLatLng(45.95, 134.38), new GLatLng(65.58, 180), new GLatLng(76.59, 108.11), new GLatLng(69.38, 29.62), new GLatLng(55.25, 30.89), new GLatLng(49.80, 43.51)]);

        var oCanada = new GPolygon([new GLatLng(60.367, -141.053),
        new GLatLng(69.999, -141.105),
        new GLatLng(82.994, -78.398),
        new GLatLng(83.339, -14.766),
        new GLatLng(69.457, -25.093),
        new GLatLng(53.853, -58.184),
        new GLatLng(60.367, -141.053)]);


        var oAlaska = new GPolygon([
            new GLatLng(70, -141),
            new GLatLng(71.3, -156.6),
            new GLatLng(68.6, -167.7),
            new GLatLng(52.4, -172.6),
            new GLatLng(54.2, -129.4),
            new GLatLng(60.8, -141.3),
            new GLatLng(70, -141)
        ]);

        var oHawaii = new GPolygon([
            new GLatLng(23.5, -161.5),
            new GLatLng(23.5, -153.1),
            new GLatLng(18.4, -153.1),
            new GLatLng(18.4, -161.5),
            new GLatLng(23.5, -161.5)
        ]);

        var oMaldives = new GPolygon([
            new GLatLng(8.7, 72.2),
            new GLatLng(8.8, 74.2),
            new GLatLng(-0.9, 74.6),
            new GLatLng(-1.0, 72.4),
            new GLatLng(8.7, 72.2)
        ]);

        var oPolynesia = new GPolygon([
            new GLatLng(-15.0, -152.6),
            new GLatLng(-16.7, -146.8),
            new GLatLng(-19.1, -150.3),
            new GLatLng(-16.5, -152.3),
            new GLatLng(-15.0, -152.6)
        ]);


        oAfrica.setFillStyle({opacity: 0});
        oAfrica.setStrokeStyle({opacity: 0});
        oRussia.setFillStyle({opacity: 0});
        oRussia.setStrokeStyle({opacity: 0});
        oCanada.setFillStyle({opacity: 0});
        oCanada.setStrokeStyle({opacity: 0});
        oAlaska.setFillStyle({opacity: 0});
        oAlaska.setStrokeStyle({opacity: 0});
        oHawaii.setFillStyle({opacity: 0});
        oHawaii.setStrokeStyle({opacity: 0});
        oPolynesia.setFillStyle({opacity: 0});
        oPolynesia.setStrokeStyle({opacity: 0});
        oMaldives.setFillStyle({opacity: 0});
        oMaldives.setStrokeStyle({opacity: 0});
        

        GEvent.addListener(oAfrica, "click", function () { oThis._onMarkerClick("AFRICA|341"); });
        GEvent.addListener(oRussia, "click", function () { oThis._onMarkerClick("RUSSIA|342"); });
        GEvent.addListener(oCanada, "click", function () { oThis._onMarkerClick("CANADA|313"); });
        this._map.addOverlay(oAfrica);
        this._map.addOverlay(oRussia);
        this._map.addOverlay(oCanada);

        GEvent.addListener(oAlaska, "click", function () { oThis._onMarkerClick("AK|260"); });
        GEvent.addListener(oHawaii, "click", function () { oThis._onMarkerClick("HI|271"); });
        GEvent.addListener(oPolynesia, "click", function () { oThis._onMarkerClick("POLYNESIA|182"); });
        //GEvent.addListener(oMaldives, "click", function () { alert('Maldives'); });
        this._map.addOverlay(oAlaska);
        this._map.addOverlay(oHawaii);
        this._map.addOverlay(oMaldives);
        this._map.addOverlay(oPolynesia);

        this._map.getPane(G_MAP_OVERLAY_LAYER_PANE).style.zIndex = 1000;
    }

    // Add the new markers
    var oThis = this;
    for (var ii = 0; ii < this.markers.length; ii++) {
        var oMarker = this.markers[ii];

        var oIcon = null;

        switch (this.detailMode) {
            case 0:
                {
                    if (this._showPoint(oMarker.allHotels)) {
                        if (this.zoom == 1) {
                            oIcon = this._yellowIconSmall;
                        }
                        else if (this.maptype == "CITY") {
                            oIcon = this._yellowIconLarge;
                        }
                        else {
                            oIcon = this._yellowIcon;
                        }
                    }
                    break;
                }
            case 1:
                {
                    if (this._showPoint(oMarker.newHotels)) {
                        if (this.zoom == 1) {
                            oIcon = this._blueIconSmall;
                        }
                        else if (this.maptype == "CITY") {
                            oIcon = this._blueIconLarge;
                        }
                        else {
                            oIcon = this._blueIcon;
                        }
                    }
                    break;
                }
            case 2:
                {
                    if (this._showPoint(oMarker.existingHotels)) {
                        if (this.zoom == 1) {
                            oIcon = this._redIconSmall;
                        }
                        else if (this.maptype == "CITY") {
                            oIcon = this._redIconLarge;
                        }
                        else {
                            oIcon = this._redIcon;
                        }
                    }
                    break;
                }
        }





        if (oIcon != null) {
            var oPointer = new GLatLng(oMarker.latitude, oMarker.longitude);
            var sTheId = "MARKER|" + oMarker.id

            var oGMarker = new GMarker(oPointer, { id: sTheId, icon: oIcon, title: oMarker.text });

            GEvent.addListener(oGMarker, "click", function () { oThis._onMarkerClick(this.id); });
            GEvent.addListener(oGMarker, "mouseover", function () { oThis._onMarkerOver(this); });
            GEvent.addListener(oGMarker, "mouseout", function () { oThis._onMarkerOut(this); });

            this._map.addOverlay(oGMarker);
        }


    }


    var oLabelOffset = new GSize(2, 14);

    for (var ii = 0; ii < this.cities.length; ii++) {
        var oCity = this.cities[ii];
        var label = new ELabel(new GLatLng(oCity.latitude, oCity.longitude), oCity.title, "map-label", oLabelOffset);
        this._map.addOverlay(label);
    }

    for (var ii = 0; ii < this.nearby.length; ii++) {
        var oPoint = this.nearby[ii];
        var label = new ELabel(new GLatLng(oPoint.latitude, oPoint.longitude), oPoint.title, "map-label-state", new GSize(-50, 5));

        this._map.addOverlay(label);
    }

    GEvent.addListener(this._map, "click", function (overlay, latlng) {
        if (latlng != null && (oThis.maptype == "REGION" || oThis.maptype == "MAPPINGREGION" || oThis.maptype == "WORLD" || oThis.maptype == "STATE" || oThis.maptype == "COUNTRY")) {

            oThis.onMarkerClick("NEAR|" + oThis.maptype + "|" + latlng.lat() + "|" + latlng.lng());
        }
    });


}
var posx;
var posy;

$(document).mousemove(function(e){
posx=e.pageX;
posy=e.pageY;
});

map.prototype._showPoint = function(arrCounts){
    if (this.brandFilter != -1)
    {
        return arrCounts[this.brandFilter-1] != "0";
    }
    else
    {
        for (var ii = 0; ii < arrCounts.length; ii++)
        {
            if (arrCounts[ii] != "0") return true;
        }
        return false;
    }
}

map.prototype._onMarkerOver = function(obj) {
    if (this.zoom > 1) {
        $('#finderCallout').show();
        
        var bLeft = $(window).width() / 2 > posx;
        if (bLeft)
        {        
            $('#finderCallout').css('left', (posx + 45) + 'px');
            $('#calloutarrow').addClass('finder-callout-arrow-left');
            $('#calloutarrow').removeClass('finder-callout-arrow');
        }
        else
        {
            $('#finderCallout').css('left', (posx - 210) + 'px');
            $('#calloutarrow').removeClass('finder-callout-arrow-left');
            $('#calloutarrow').addClass('finder-callout-arrow');
        }
        
        $('#finderCallout').css('top', (posy - 20) + 'px');

        for (var ii = 0; ii < this.markers.length; ii++) {
            var oMarker = this.markers[ii];

            if (obj.getLatLng().lat() == oMarker.latitude && obj.getLatLng().lng() == oMarker.longitude) {
            
                var sDetail = "";
                sDetail += this._getTotal(oMarker.newHotels) + " New hotels<br /><div style=\"padding-left:10px\">";
                
                
                var arrTotal;
                arrTotal = oMarker.newHotels;    
            
                for (var jj=0; jj<this.brands.length;jj++)
                {
                    if (arrTotal[jj] != "0") sDetail += arrTotal[jj] + " " + this.brands[jj] + "<br />";
                }
                
                sDetail += "</div><div>----------------------</div><div>"; 
                sDetail += this._getTotal(oMarker.existingHotels) + " Existing hotels</div><div style=\"padding-left:10px\">";  
                          
                arrTotal = oMarker.existingHotels;
                for (var jj=0; jj<this.brands.length;jj++)
                {
                    if (arrTotal[jj] != "0") sDetail += arrTotal[jj] + " " + this.brands[jj] + "<br />";
                }
                
                 sDetail += "</div>";
            
                $('#callouttitle').html(oMarker.text);
                $('#calloutdetail').html(sDetail);
            }
        }
    }
}

map.prototype._getTotal = function(arr)
{
    var iTotal = 0;
    for (var jj = 0; jj < arr.length; jj++)
    {
        iTotal += parseInt(arr[jj]);
    }
    return iTotal;
}

map.prototype._onMarkerOut = function(id)
{
    $('#finderCallout').hide();
    
}

map.prototype.getHotelCount = function()
{
    var iTotal = 0;
    
    for (var ii = 0; ii < this.markers.length; ii++)
    {
        var oMarker = this.markers[ii];
        
        switch (this.detailMode)
        {
            case 0:
                {
                    for (var jj = 0; jj < oMarker.allHotels.length; jj++)
                    {
                        iTotal += parseInt(oMarker.allHotels[jj]);
                    }
                    break;
                }
            case 1:
                {
                    for (var jj = 0; jj < oMarker.newHotels.length; jj++)
                    {
                        iTotal += parseInt(oMarker.newHotels[jj]);
                    }
                    break;
                }
            case 2:
                {
                    for (var jj = 0; jj < oMarker.existingHotels.length; jj++)
                    {
                        iTotal += parseInt(oMarker.existingHotels[jj]);
                    }
                    break;
                }
        }        
    }
    return(iTotal);
}

map.prototype._getTileUrl = function(a, b)
{
    return "/tiles/" + GLOBAL_MAPID + "_" + a.x + "_" + a.y + "_" + b + ".jpg";        
}

map.prototype._init = function(pMapDivID)
{
    this._mapDivID  = pMapDivID;
    this._useCustom = null;
    
    // Create base icons for the markers that specify the
    // shadow, icon dimensions, etc.
    this._yellowIcon = new GIcon(G_DEFAULT_ICON, "images/marker_yellow.gif");

    this._yellowIcon.shadow           = "";
    this._yellowIcon.iconSize         = new GSize(7, 7);
    this._yellowIcon.shadowSize       = new GSize(0, 0);
    this._yellowIcon.iconAnchor       = new GPoint(3, 3);
    this._yellowIcon.infoWindowAnchor = new GPoint(9, 2);
    this._yellowIcon.imageMap         = [0,0, 7,0, 7,7, 0,7];

    this._blueIcon = new GIcon(G_DEFAULT_ICON, "images/marker_blue.gif");
    
    this._blueIcon.shadow           = "";
    this._blueIcon.iconSize         = new GSize(7, 7);
    this._blueIcon.shadowSize       = new GSize(0, 0);
    this._blueIcon.iconAnchor       = new GPoint(3, 3);
    this._blueIcon.infoWindowAnchor = new GPoint(9, 2);
    this._blueIcon.imageMap         = [0,0, 7,0, 7,7, 0,7];

    this._redIcon = new GIcon(G_DEFAULT_ICON, "images/marker_red.gif");
    
    this._redIcon.shadow           = "";
    this._redIcon.iconSize         = new GSize(7, 7);
    this._redIcon.shadowSize       = new GSize(0, 0);
    this._redIcon.iconAnchor       = new GPoint(3, 3);
    this._redIcon.infoWindowAnchor = new GPoint(9, 2);
    this._redIcon.imageMap         = [0,0, 7,0, 7,7, 0,7];
    
    this._yellowIconSmall = new GIcon(G_DEFAULT_ICON, "images/marker_yellow_sm.gif");

    this._yellowIconSmall.shadow           = "";
    this._yellowIconSmall.iconSize         = new GSize(3, 3);
    this._yellowIconSmall.shadowSize       = new GSize(0, 0);
    this._yellowIconSmall.iconAnchor       = new GPoint(1, 1);
    this._yellowIconSmall.infoWindowAnchor = new GPoint(9, 2);
    this._yellowIconSmall.imageMap         = [0,0, 3,0, 3,3, 0,3];

    this._blueIconSmall = new GIcon(G_DEFAULT_ICON, "images/marker_blue_sm.gif");
    
    this._blueIconSmall.shadow           = "";
    this._blueIconSmall.iconSize         = new GSize(3, 3);
    this._blueIconSmall.shadowSize       = new GSize(0, 0);
    this._blueIconSmall.iconAnchor       = new GPoint(1, 1);
    this._blueIconSmall.infoWindowAnchor = new GPoint(9, 2);
    this._blueIconSmall.imageMap         = [0,0, 3,0, 3,3, 0,3];

    this._redIconSmall = new GIcon(G_DEFAULT_ICON, "images/marker_red_sm.gif");
    
    this._redIconSmall.shadow           = "";
    this._redIconSmall.iconSize         = new GSize(3, 3);
    this._redIconSmall.shadowSize       = new GSize(0, 0);
    this._redIconSmall.iconAnchor       = new GPoint(1, 1);
    this._redIconSmall.infoWindowAnchor = new GPoint(9, 2);
    this._redIconSmall.imageMap         = [0,0, 3,0, 3,3, 0,3];
    
    this._yellowIconLarge = new GIcon(G_DEFAULT_ICON, "images/marker_yellow_lg.gif");

    this._yellowIconLarge.shadow           = "";
    this._yellowIconLarge.iconSize         = new GSize(21, 21);
    this._yellowIconLarge.shadowSize       = new GSize(0, 0);
    this._yellowIconLarge.iconAnchor       = new GPoint(10, 10);
    this._yellowIconLarge.infoWindowAnchor = new GPoint(9, 2);
    this._yellowIconLarge.imageMap         = [0,0, 21,0, 21,21, 0,21];

    this._blueIconLarge = new GIcon(G_DEFAULT_ICON, "images/marker_blue_lg.gif");
    
    this._blueIconLarge.shadow           = "";
    this._blueIconLarge.iconSize         = new GSize(21, 21);
    this._blueIconLarge.shadowSize       = new GSize(0, 0);
    this._blueIconLarge.iconAnchor       = new GPoint(10, 10);
    this._blueIconLarge.infoWindowAnchor = new GPoint(9, 2);
    this._blueIconLarge.imageMap         = [0,0, 21,0, 21,21, 0,21];

    this._redIconLarge = new GIcon(G_DEFAULT_ICON, "images/marker_red_lg.gif");
    
    this._redIconLarge.shadow           = "";
    this._redIconLarge.iconSize         = new GSize(21, 21);
    this._redIconLarge.shadowSize       = new GSize(0, 0);
    this._redIconLarge.iconAnchor       = new GPoint(10, 10);
    this._redIconLarge.infoWindowAnchor = new GPoint(9, 2);
    this._redIconLarge.imageMap         = [0,0, 21,0, 21,21, 0,21];


    this.markers = new Array();
    
    this.detailMode = 1; // 0 = Show All; 1 = Show New; 2 = Show Existing
}

map.prototype._clearMarkers = function()
{
    this._map.clearOverlays();
}

map.prototype._onMarkerClick = function(pMarkerIDString)
{
    $('#finderCallout').hide();
    if (this.onMarkerClick != null)
    {
        var arrMarkerIDString = pMarkerIDString.split("|");
        
        var sID = "";
        for (var ii = 1; ii < arrMarkerIDString.length; ii++)
        {
            if (ii > 1)
            {
                sID += "|";
            }
            
            sID += arrMarkerIDString[ii];
        }
        
        this.onMarkerClick(sID);
    }    
}

map.prototype._getXMLDom = function(pXML)
{
    var oXMLDom;
    
    try //Internet Explorer
    {
        oXMLDom = new ActiveXObject("Microsoft.XMLDOM");
        oXMLDom.async="false";
        oXMLDom.loadXML(pXML);
    }
    catch(e)
    {
        try //Firefox, Mozilla, Opera, etc.
        {
            var oParser = new DOMParser();
            oXMLDom = oParser.parseFromString(pXML,"text/xml");
        }
        catch(e) 
        {
            alert(e.message);
        }
    }

    return(oXMLDom);
}

map.prototype._getFirstChildXMLNode = function(pParent, pNodeName)
{
    var oChildNode = null;
    
    if (pParent.getElementsByTagName(pNodeName).length > 0)
    {
        oChildNode = pParent.getElementsByTagName(pNodeName)[0];
    }
    
    return(oChildNode);
}

map.prototype._getFirstChildXMLNodeValue = function(pParent, pNodeName)
{
    var sChildNodeValue = "";
    var oChildNode      = this._getFirstChildXMLNode(pParent, pNodeName);
    
    if (oChildNode != null)
    {
        if (oChildNode.childNodes.length == 1)
        {
            var sText = oChildNode.childNodes[0].nodeValue;
            if (sText == "NULL")
            {
                sChildNodeValue = null;
            }
            else
            {
                sChildNodeValue = sText;
            }
        }
    }
    
    return (sChildNodeValue);
}

map.prototype._getChildXMLNodes = function(pParent, pNodeName)
{
    return(pParent.getElementsByTagName(pNodeName));
}


///////////////////////


function mapMarker()
{
    this.id             = 0;
    this.text           = "";
    this.latitude       = 0;
    this.longitude      = 0;
    this.newHotels      = 0;
    this.existingHotels = 0;
    this.allHotels      = 0;
    
    this.hotels         = new Array();
}

mapMarker.prototype.id;
mapMarker.prototype.text;
mapMarker.prototype.latitude;
mapMarker.prototype.longitude;
mapMarker.prototype.newHotels;
mapMarker.prototype.existingHotels;
mapMarker.prototype.allHotels;

mapMarker.prototype.hotels;


///////////////////////


function mapHotel()
{
    name          = "";
    address       = 0;
    openingDate   = 0;
    imageUrl      = "";
    brandImageUrl = "";
    meetLink1     = "";
    resLink1      = "";
    detLink1      = "";
}

mapMarker.prototype.name;
mapMarker.prototype.address;
mapMarker.prototype.openingDate;
mapMarker.prototype.imageUrl;
mapMarker.prototype.brandImageUrl;
mapMarker.prototype.meetLink1;
mapMarker.prototype.resLink1;
mapMarker.prototype.detLink1;

function mapCity()
{
    title = "";
    latitude = 0;
    longitude = 0;
}

mapCity.prototype.title;
mapCity.prototype.latitude;
mapCity.prototype.longitude;


function mapNearbyPoint()
{
    title = "";
    mapid = 0;
    latitude = 0;
    longitude = 0;    
}

mapNearbyPoint.prototype.title;
mapNearbyPoint.prototype.mapid;
mapNearbyPoint.prototype.latitude;
mapNearbyPoint.prototype.longitude;



/////////////////////////////////////////////////////////////////////////////////////////////////////
// Custom Overlay "Mask"

    function Mask() { }
    Mask.prototype = new GOverlay();


    Mask.prototype.initialize = function(map) {
      // Create the DIV representing our rectangle
      var div = document.createElement("div");
      div.style.position = "absolute";
      div.style.background = "url('images/map_mask.gif')"

      map.getPane(G_MAP_MAP_PANE).appendChild(div);

      this.map_ = map;
      this.div_ = div;
    }

    Mask.prototype.remove = function() {
      this.div_.parentNode.removeChild(this.div_);
    }

    Mask.prototype.copy = function() {
      return new Mask();
    }

    Mask.prototype.redraw = function(force) {
      // We only need to redraw if the coordinate system has changed
      if (!force) return;

      // Now position our DIV based on the DIV coordinates of our bounds
      this.div_.style.width = "730px";
      this.div_.style.height = "378px";
      this.div_.style.left = "0px";
      this.div_.style.top = "0px";
    }
    
/////////////////////////////////////////////////////////////////////////////////////////////////////
// Custom Overlay "HelpLink"

    function HelpLink() { }
    HelpLink.prototype = new GOverlay();


    HelpLink.prototype.initialize = function(map) {
      // Create the DIV representing our rectangle
      var div = document.createElement("div");
      div.style.position = "absolute";
      div.style.color = '#7777CC';
      div.style.fontSize = '11px';
      div.innerHTML = '<a href="javascript:void(0)" style=\"color:#7777CC\" onclick="event.cancelBubble = true;$(\'#mapHelp\').show();">Help</a>';

      map.getPane(G_MAP_MAP_PANE).appendChild(div);

      this.map_ = map;
      this.div_ = div;
    }

    HelpLink.prototype.remove = function() {
      this.div_.parentNode.removeChild(this.div_);
    }

    HelpLink.prototype.copy = function() {
      return new Mask();
    }

    HelpLink.prototype.redraw = function(force) {
      // We only need to redraw if the coordinate system has changed
      if (!force) return;

      // Now position our DIV based on the DIV coordinates of our bounds
      //this.div_.style.width = "730px";
      //this.div_.style.height = "378px";
      var oBounds = this.map_.getSize();

      this.div_.style.left = (oBounds.width - 25) + 'px';
      this.div_.style.top = (oBounds.height - 30) + 'px';
    }
