﻿function mapMoveEnd() {
    if (toZoom > -1) {
        var doZoom = toZoom;
        toZoom = -1;
        setTimeout('map.setZoom(' + doZoom + ')',1000);
    } else {
        var minLat = map.getBounds().getSouthWest().lat();
        var minLng = map.getBounds().getSouthWest().lng();
        var maxLat = map.getBounds().getNorthEast().lat();
        var maxLng = map.getBounds().getNorthEast().lng();
        var zoomLevel = map.getZoom();
        
        var addButton = document.getElementById('addButtonPlaceholder');
        if (addButton != null) {
            if (zoomLevel >= 15)
                addButton.style.display = 'block';
            else
                addButton.style.display = 'none';
        }
        
        //setStatus(minLat, maxLat, minLng, maxLng, zoomLevel);
        getAreaMarkerList(minLat, maxLat, minLng, maxLng, zoomLevel);
    }
}

function moveZoom(lat, lng, zoomLevel) {
    toZoom = zoomLevel;
    map.panTo(new GLatLng(lat, lng));
}

var bubbleTimeout;
var autoHideBubble = false;
function showBubble(objID) {
    var obj = document.getElementById(objID);
    if (obj != null) {
        if (obj.style.display == 'none')
            obj.style.display = 'block';
        bubbleTimeout = new Date();
        bubbleTimeout.setSeconds(bubbleTimeout.getSeconds() + 10);
        
        if (!autoHideBubble) {
            autoHideBubble = true;
            setTimeout('hideBubble(\'' + objID + '\');',1000);
        }
    }
}

function hideBubble(objID) {
    var compDate = new Date();
    if (compDate > bubbleTimeout) {
        var obj = document.getElementById(objID);
        if (obj != null) {
            obj.style.display = 'none';
        }
        autoHideBubble = false;
    } else {
        setTimeout('hideBubble(\'' + objID + '\');',1000);
    }
}

function navigateTo(url) {
    url = url.replace(/&/g,'$');
    url = url.replace(/#/g,'£');
    //alert('url:\n' + url);
    location.href=url;
}
