﻿//Increases/decreases the height of a Google Map container
function setMapDivHeight(divMapContainerID, mapID, newHeight)
{
    var divMapContainer = $("#" + divMapContainerID);
    var hidMapHeight = $("> input:hidden[id$='hidMapHeight']", divMapContainer);
    var map = $("#" + mapID);
    var centre = eval(mapID + ".getCenter()");

    if (newHeight == 0) {
        divMapContainer.css("height", hidMapHeight.val() + "px");
    } 
    else {
        newHeight = parseInt(hidMapHeight.val(), 10) + parseInt(newHeight, 10);

        if (newHeight < 200) newHeight = 200;
        if (newHeight > 1000) newHeight = 1000;

        divMapContainer.css("height", newHeight + "px");
        hidMapHeight.val(newHeight);
    }

    eval("google.maps.event.trigger(" + mapID + ", 'resize')");
    eval(mapID + ".setCenter(centre)");
}

document.onmousemove = storeMousePos;

var mousePos = { left: 0, top: 0 };

function storeMousePos(e)
{
    mousePos.left = document.all ? event.clientX + document.documentElement.scrollLeft : e.pageX;
    mousePos.top = document.all ? event.clientY + document.documentElement.scrollTop : e.pageY;
}

function showMapOverlay(divMapContainerID, content)
{
    var divMapContainer = $("#" + divMapContainerID);
    var divOverlayContainer = $("> div.overlayContainer", divMapContainer);

    l = mousePos.left + 15;
    t = mousePos.top + 5;

    divOverlayContainer.stop().hide().html(content).css("left", l).css("top", t).fadeIn(250);
}

function hideMapOverlay(divMapContainerID)
{
    var divMapContainer = $("#" + divMapContainerID);
    var divOverlayContainer = $("> div.overlayContainer", divMapContainer);

    divOverlayContainer.stop().fadeOut(250);
}
