﻿/*
mapalert.js handles the logic for the display of map alerts
*/

var _mapAlertDivName = "wrapper-mapalert"; //Name of the div acting as the map alert.
var _timeoutObject = null; //The instance of a particular timeout. Used to cancel a timeout.

/// <summary>
/// Displays a message in a div that overlays the map
/// <param name="message">The string to be displayed</param>
/// </summary>
/// <returns>null</returns>
function MapAlert(message)
{   
    //First, make sure we clear any existing timeout commands.
    if(_timeoutObject)
    {
        clearTimeout(_timeoutObject);
        _timeoutObject = null;
    }

    //Display Message in alert div
    var ma = $(_mapAlertDivName);
    ma.innerHTML = message;
    //If div is hidden, show it.
    if(ma.style.display == 'none')
    {
        Effect.Appear(_mapAlertDivName, '{duration: .0.3}');
    }
    //Wait 4 seconds, then hide.
    _timeoutObject = setTimeout("Effect.Fade(_mapAlertDivName, '{duration:.8}');",4000);
     
}

//Kills the open map alert window immediately
function CancelMapAlert()
{
    if(_timeoutObject)
    {
        clearTimeout(_timeoutObject);
        _timeoutObject = null;
    }
    $(_mapAlertDivName).style.display = 'none';
}


/// <summary>
/// Displays an animated gif in the Map Alert div
/// </summary>
/// <returns>null</returns>
function ShowLoadingDisplay(geometryType)
{
    //Display waiting icon in alert div
    var msg = (geometryType == 'marker') ? (_searchingMessage + _searchingPoint) : (_searchingMessage + _searchingArea);
    _searchResultsGrid.DisplaySearchResultsHeader("<table><tr><td><img src=" + _waitingIcon + " alt='' /></td><td>" + msg + "</td></tr></table>");
}

/// <summary>
/// Cancels an animated gif in the Map Alert div
/// </summary>
/// <returns>null</returns>
function HideLoadingImage()
{
    //First, make sure we clear any existing timeout commands.
    if(_timeoutObject)
    {
        clearTimeout(_timeoutObject);
        _timeoutObject = null;
    }
    Effect.Fade(_mapAlertDivName, '{duration:.8}');
}   