    var icon = new GIcon();
    icon.iconSize = new GSize(14, 14);
    icon.iconAnchor = new GPoint(7, 7);
    icon.infoWindowAnchor = new GPoint(5, 1);
    icon.image = '/ui/media/geo-small-flag.png';

    var imap, vmap;
    var ilat, ilng, izoom;
    var vlat, vlng, vzoom;

    function initPlaceMap(mapNodeId, geo, points, messages) {
        var map;
        var mapNode = document.getElementById(mapNodeId);
        if (mapNode) {
            map = createMap(mapNode);
            initPopups(map, 150);

            if (geo) {
                var pos = geo.value.split(",");
                lat = pos[0];
                lng = pos[1];
                zoom = parseInt(pos[2]);
            }

            if (lat && lng) {
                centerPoint = new GLatLng(lat, lng);
                map.setCenter(centerPoint, zoom);

                if (points) {
                    for (var i = 0; i < points.length; i++) {
                        map.addOverlay(createMarker(points[i], messages[i], map));
                    }
                }
            }
        }
        return map;
    }

    function initMapInterested() {
        imap = initPlaceMap("mapInterested", document.form.geoInterested, window.ipoints, window.imessages);
    }

    function initMapVisited() {
        vmap = initPlaceMap("mapVisited", document.form.geoVisited, window.vpoints, window.vmessages);
    }

    addOnload(initMapInterested);
    addOnload(initMapVisited);

    function deinit() {
        GUnload();
    }

    window.unload = deinit;


    function zoomIn(oEvent, scr) {
        if (scr >= 120)
            zoomAdjustment = map.getZoomLevel() + 1;
        else
            zoomAdjustment = map.getZoomLevel() - 1;
        if (zoomAdjustment > 0 && zoomAdjustment < 17)
            map.zoomTo(zoomAdjustment);

        if (oEvent.preventDefault)
            oEvent.preventDefault();
    }

    function createMarker(point, message, map) {
        var marker = new GMarker(point, icon);
        makePopup(marker, message, map);
/*
        GEvent.addListener(marker, "click", function() {
            message = "<div class='mapPlaceInfo'>" + message + "</div>";
            marker.openInfoWindowHtml(message);
        });
*/

        return marker;
    }

function showGroups() {
    // make request
    var url = "/XmlService?event=getUserGroups";
    sendRequest(url);
}

function getUserGroupsHandler(result, error) {
    if (error) {
        valert(error);
        if (error.match(/login/)) {
            window.location = "/Users?event=displayLogin&returnToUrl=" + encode(window.location);
        }
        return;
    }

    var groups = result.getElementsByTagName("group");

    var html = "Add this member to your friends group:<br><br>";
    html += "<form name='dialogForm'><select name='group' id='group'>";
    for (var j=0; j < groups.length; j++) {
        var group = groups[j];
        html += "<option value='" + group.getAttribute("id") + "'>" + group.firstChild.nodeValue + "</option>";
    }
    html += "</select>";
    html += "<br><br>You can create new groups by visiting My Profile and clicking <i>Edit</i> under the Friends section.<br><br>";
    html += "<div style='text-align:center'><button type='button' onclick='selectGroup()' class='icon'><img src='/ui/media/select-O-LG.png'></button>";
    html += "<button type='button' onclick='hideDialog()' class='icon'><img src='/ui/media/cancel-LG.png'></button></div></form>";
    showDialog("Select Group", html);
}

function composeMail() {
    var username = document.form.username.value;
    window.location = "/Messages?event=composeMessage&username="+username;
}

/*
function addToGroup() {
    var item = document.form.item.value;
    openWindow("/UserGroups?event=displayList&popup=true&mode=selector&user="+item);
}
*/

function selectGroup() {
    var item = document.form.item.value;
    var groupId = document.dialogForm.group.value;
    sendRequest('/XmlService?event=addToGroup&group=' + groupId + '&item=' + item);
    hideDialog();
}

function addToGroupHandler(result) {
    if (result.firstChild.data == "OK") {
        var username = document.getElementById("usernameText").innerHTML;
        valert("An invitation has been sent to " + username + ".");
    } else if (result.firstChild.data == "EXISTS") {
        var username = document.getElementById("usernameText").innerHTML;
        valert("You already added " + username + " to your friends list.");
    }
}

function deleteCustomList(href) {
    if (confirm("Are you sure you want to delete this list?"))
        window.location = href + "&returnToUrl=" + encode(window.location);
}

