﻿/*
    This file handles the link management for the Churches, Students, Missionaries, and Travelers links.
    This file requires the general.js for some of its functions.
 */

var InfoBox = new function()
{
    this.INFOBOX_COUNT = 4;
    this.INFOBOX_DEFAULT_SELECTED_ID = -1;
    this.INFOBOX_HIDE_TIMEOUT_ID = 0;

    this.ShowInfo = function(obj, index)
    {
        this.HideAllInfo();
        
        var d = document.getElementById('info_' + index);
        d.style.left = (General.IsExplorer()) ? General.GetLeftPosition(obj) + 1 + obj.offsetWidth + 'px' : General.GetLeftPosition(obj) + obj.offsetWidth + 'px';
        d.style.top = (General.IsExplorer()) ? General.GetTopPosition(obj) - (obj.offsetHeight * index) + 'px' : General.GetTopPosition(obj) - 1 - (obj.offsetHeight * index) + 'px';
        d.style.display = '';
        this.SelectInfoLink(index);
    }; // ShowInfo(obj, index)
    this.KeepOpen = function(id)
    {
        clearTimeout(this.INFOBOX_HIDE_TIMEOUT_ID);
        this.SelectInfoLink(id);
    }; // KeepOpen(id)
    this.HideAllInfo = function()
    {
        clearTimeout(this.INFOBOX_HIDE_TIMEOUT_ID);
        for(var i = 0; i < this.INFOBOX_COUNT; i++)
        {
            document.getElementById('info_' + i).style.display = 'none';
            document.getElementById('infolink_' + i).className = '';
        }
    }; // HideAllInfo()
    this.HideInfo = function() { this.INFOBOX_HIDE_TIMEOUT_ID = setTimeout("InfoBox.ResetInfo()", 1000); }; // HideInfo()
    this.ResetInfo = function()
    {
        this.HideAllInfo();
        this.SelectDefaultInfoLink();
    }; // ResetInfo()
    this.SelectInfoLink = function(id) { if(id > -1) { document.getElementById('infolink_' + id).className = 'selected'; } }; // SelectInfoLink(id)
    this.SetDefaultInfoLink = function(index)
    {
        this.INFOBOX_DEFAULT_SELECTED_ID = index;
        this.SelectInfoLink(index);
    }; // SetDefaultInfoLink(index)
    this.SelectDefaultInfoLink = function() { this.SelectInfoLink(this.INFOBOX_DEFAULT_SELECTED_ID); }; // SelectDefaultInfoLink()
};