//******************
// Global Variables
//******************

    // These arrays control the visibility of the collapsable menus.
    // Here, CFA_MenuDisplay is initialized to NOT show the menus.
var CFA_MenuName    = [ 'menuGen', 'menuMin', 'menuNews', 'menuAudio' ];
var CFA_MenuDisplay = [  false,     false,     false,      false      ];


    // These variables indicate the type of DOM, if any, this browser uses.
var CFA_isDHTML  = 0;
var CFA_isLayers = 0;
var CFA_isAll    = 0;
var CFA_isID     = 0;
var CFA_browserVersion = parseInt(navigator.appVersion);

// Adjust global variable values based on browser type
if (document.getElementById)
{
    CFA_isID    = 1;
    CFA_isDHTML = 1;
}
else if (document.all)
{
    CFA_isAll   = 1;
    CFA_isDHTML = 1;
}
else if ((navigator.appName.indexOf('Netscape') != -1) && (CFA_browserVersion == 4))
{
    CFA_isLayers = 1;
    CFA_isDHTML  = 1;
}

// This function takes an object's ID and creates a DOM
// for the browser being used.
function CFA_findDOM(objectId,withStyle)
{
    if (withStyle == 1)
    {
        if (CFA_isID)
        {
            return(document.getElementById(objectId).style);
        }
        else if (CFA_isAll)
        {
            return(document.all[objectId].style);
        }
        else if (CFA_isLayers)
        {
            return(document.layers[objectId]);
        }
    }
    else if (CFA_isID)
    {
        return(document.getElementById(objectId));
    }
    else if (CFA_isAll)
    {
        return(document.all[objectId]);
    }
    else if (CFA_isLayers)
    {
        return(document.layers[objectId]);
    }
    
} // CFA_findDOM()

// Return specified object's width
function CFA_findWidth(objectID)
{
    var dom = CFA_findDOM(objectID,0);

    if (dom.offsetWidth)
        return(dom.offsetWidth);

    if (dom.clip.width)
        return(dom.clip.width);

    return(null);

} // CFA_findWidth()


//*********************************************************
// This function toggles the specified object's display
// property between 'block' and 'none'.
//*********************************************************
function toggleCollapsingMenu(objectID)
{
    if (CFA_isAll || CFA_isID)
    {
        domStyle = CFA_findDOM(objectID,1);
        
        if (domStyle.display == 'block')
        {
            domStyle.display = 'none';
        }
        else
        {
            domStyle.display = 'block';
        }
    }
    else
    {
        // Don't have a good DOM to work with.
        // Do nothing for now.
    }
    return;
    
} //toggleCollapsingMenu()


//*******************************************************
// This function is called from the Bible Gateway form
// to (1) request a Bible search and (2) put the results
// in a new window.
//*******************************************************
function CFA_BibleGateway()
{
    var serverURL = "http://bible.gospelcom.net/bible?";
    var sParams;
    var sFeatures;
    var newWindow;

    // The Bible Gateway server requires that the search parameters
    // be escaped.  So, escape them and build the URL string.
    sParams  = "passage="     + escape(document.BibleGW.passage.value);
    sParams += "&version="    + document.BibleGW.version.value;
    sParams += "&language="   + document.BibleGW.language.value;
    sParams += "&search="     + escape(document.BibleGW.search.value);
    sParams += "&SearchType=" + document.BibleGW.SearchType.value;

    serverURL += sParams;

    // Build window feature string
    sFeatures  = "height=400,width=500,innerHeight=400,innerWidth=500";
    sFeatures += ",screenX=50,screenY=50,left=50,top=50";
    sFeatures += ",resizable,scrollbars,status,dependent";

    // Open the Window and give it the focus.
    newWindow = window.open( serverURL, 'BGWSearchResults', sFeatures );
    newWindow.focus();

} // CFA_BibleGateway()


//*******************************************************
// This function can be called from any page on the
// site to allow the user to send an e-mail message
// to a specified person at CFA.
//*******************************************************
function CFA_WriteMessage(Code)
{
    var serverURL = "http://www.cfa.us/misc/mail_compose.asp";
    var sParams;
    var sFeatures;
    var newWindow;

    // Escape the parameter and build the URL string.
    sParams      = "?UserCode=" + escape(Code);
    serverURL += sParams;

    // Build window feature string
    sFeatures  = "height=450,width=510,innerHeight=450,innerWidth=510";
    sFeatures += ",screenX=100,screenY=50,left=100,top=50";
    sFeatures += ",resizable,scrollbars,status,dependent";

    // Open the Window and give it the focus.
    newWindow = window.open( serverURL, 'CFAMailCompose', sFeatures );
    newWindow.focus();

} // CFA_WriteMessage()

// Shortened function name for CFA_WriteMessage()
function mail(Code)
{
   CFA_WriteMessage(Code);
}

//*******************************************************
// This function can be called from any page on the
// site to allow the user to send a registration form
// for the UVa residents seminar.
//*******************************************************
function mail_residents(Code)
{
    var serverURL = "/misc/mail_compose_residents.asp";
    var sParams;
    var sFeatures;
    var newWindow;

    // Escape the parameter and build the URL string.
    sParams      = "?UserCode=" + escape(Code);
    serverURL += sParams;

    // Build window feature string
    sFeatures  = "height=490,width=530,innerHeight=490,innerWidth=530";
    sFeatures += ",screenX=100,screenY=50,left=100,top=50";
    sFeatures += ",resizable,scrollbars,status,dependent";

    // Open the Window and give it the focus.
    newWindow = window.open( serverURL, 'RegistrationCompose', sFeatures );
    newWindow.focus();

} // mail_residents()



//****************************************************
//* Date Display Function for page heading
//*
//* Outputs a string of HTML of the form:
//*     day-of-week<br>
//*     full-month-name day, 4-digit-year
//*
//****************************************************
function CFA_displayToday()
{
  var Months = new Array("January","February","March","April","May","June",
                         "July","August","September","October","November","December");
  var Days   = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");

  var MyDate = new Date();
  var Year   = MyDate.getYear();

  if (Year < 1900)
  {
    Year += 1900;
  }
  document.write(Days[MyDate.getDay()]+"<br>\n"+Months[MyDate.getMonth()]+"&nbsp;"+MyDate.getDate()+",&nbsp;"+Year);
}

//************************************************************************
//* FUNCTION swapImage - for doing Image Rollovers
//*
//* PARAMETERS
//*   ImageName = Name of image as specified in IMG tag's name attribute.
//*   Source    = Integer indicating folder where NewImage is located:
//*                  1 = /images/navigation/
//*                  If any other value is specified, the path is assumed
//*                  to be in NewImage.
//*   NewImage  = Filename of the image to be swapped in.
//************************************************************************

function CFA_swapImages(ImageName, Source, NewImage)
{
  var ImageDir;

  if (document.images)
  {
    if (Source == 1)
    {
      ImageDir = "/images/navigation/";
    }
    else
    {
      ImageDir = "";
    }
    document[ImageName].src = ImageDir+NewImage;
  }
}

//************************************************************************
//* Setup Initialization Values for Menu System
//************************************************************************
if(window.event + "" == "undefined") event = null;
function HM_f_PopUp(){return false};
function HM_f_PopDown(){return false};
popUp = HM_f_PopUp;
popDown = HM_f_PopDown;

HM_PG_MenuWidth = 150;
HM_PG_FontFamily = "Verdana,Arial,sans-serif";
HM_PG_FontSize = 10;
HM_PG_FontBold = 0;
HM_PG_FontItalic = 0;
HM_PG_FontColor = "blue";
HM_PG_FontColorOver = "white";
HM_PG_BGColor = "#FFFABA";
HM_PG_BGColorOver = "#8080FF";
HM_PG_ItemPadding = 3;

HM_PG_BorderWidth = 1;
HM_PG_BorderColor = "black";
HM_PG_BorderStyle = "solid";
HM_PG_SeparatorSize = 1;
HM_PG_SeparatorColor = "gray";

HM_PG_ImageSrc = "/menu/HM_More_black_right.gif";
HM_PG_ImageSrcLeft = "/menu/HM_More_black_left.gif";
HM_PG_ImageSrcOver = "/menu/HM_More_white_right.gif";
HM_PG_ImageSrcLeftOver = "/menu/HM_More_white_left.gif";

HM_PG_ImageSize = 5;
HM_PG_ImageHorizSpace = 0;
HM_PG_ImageVertSpace = 2;

HM_PG_KeepHilite = true; 
HM_PG_ClickStart = 0;
HM_PG_ClickKill = false;
HM_PG_ChildOverlap = 20;
HM_PG_ChildOffset = 10;
HM_PG_ChildPerCentOver = null;
HM_PG_TopSecondsVisible = 1.25;
HM_PG_StatusDisplayBuild =0;
HM_PG_StatusDisplayLink = 0;
HM_PG_UponDisplay = null;
HM_PG_UponHide = null;
HM_PG_RightToLeft = 0;

HM_PG_CreateTopOnly = 0;
HM_PG_ShowLinkCursor = 1;
HM_PG_NSFontOver = true;

//************************************************************************
//* END Setup for Menu System
//************************************************************************

