//---------------------------------------------------------------------------
//
// JavaScript to manipulate index map rollovers.
//
// Rollover images are loaded on first reference and are stored in an
// associative array.
//
// Note that you must include "ClientScript.js" to use this facility.
// Before using these functions, you must call SetPageAttributes().
//
//---------------------------------------------------------------------------

//
// For rollovers, we use a dynamically allocated array indexed by strings.
// The index for each array element is the base name of the image file
// that's loaded into that element. In this case, that's the name of a town.
//
var g_index_map_rollovers;


//
// Create image arrays for rollovers. Most images are loaded dynamically
// on first reference.
//
if (document.images)
{
    g_index_map_rollovers = new Array();
}


//
// Set the image of the index map (i.e., activate a rollover).
//
function SetIndexMapImage(town_name)
{
    if (document.images)
    {
        // Load image on first reference.
        if (g_index_map_rollovers[town_name] == null)
        {
            // Note assumed name and location of graphic file.
            var path;
            if (town_name == ThisTownName())
              path = "Images/" + ThisObjectType() + "/" + ThisObjectName() + "/IndexMap.png";
            else
              path = "Images/Towns/" + town_name + "/IndexMap.png";

            LoadIndexMapRollover(town_name, path);
        }

        //
        // NB: The IMG element for the index map is assumed to have the
        //     attribute "name='IndexMap'".
        //
        document["IndexMap"].src = g_index_map_rollovers[town_name].src;
    }
}


//
// Reset the index map to its original state. Note that we use the town name
// captured by dynamically generated javascript.
//
function ResetIndexMapImage()
{
    SetIndexMapImage(ThisTownName());
}


//
// Load a town's index map rollover.
//
function LoadIndexMapRollover(town_name, path)
{
    g_index_map_rollovers[town_name] = LoadImage(path);
}
