﻿//--------------------------------------------------------//
// This is the javascript file used on the home page      //
// Author: L Wittman                                      //
// Date: 2/06/08                                          //
//--------------------------------------------------------//

// Global variables
var banner_src;
var timer;  
var idef = 0;
var revertID;

//On Load
// Try to this function, if the page is slow to load
// try again a couple more times to be sure it is done.
setTimeout("OnLoad(1)",100);
var retrySec = 1000; // milliseconds to wait until retry on error (1000 = 1 second)
var page = "Welcome"; // Page name and part of left menu name

function OnLoad(index)
{
    // Highlight the correct navigation menu on the left
    try
    {
        window.status=index; // Retry status
        var nav = document.getElementById('Nav_' + page);
        nav.className = 'mouseover_leftnav';
        navselected = nav.id;
        window.status = "Done";
    }
    catch(e)
    {
        if(index == 1){setTimeout("OnLoad(2)",retrySec);}
        else if(index == 2){setTimeout("OnLoad(3)",retrySec + 1000);}
        else{window.status=page;}
    }
}

// This function will fade in the banner
function rotate_banner(objid,newimg,imgid,alt)
{
    //window.status=banner_src;
    var imgobj = document.getElementById(objid);
    // Set the transition and duration (Fade, 1 second)
    var filterstring = "progid:DXImageTransform.Microsoft.Fade(Duration=1.0)";
    // Set the image source code
    if(document.getElementById && idef == 0)
    {
        banner_src = imgobj.innerHTML;
        var imgsrc =  '<img id="' + imgid + '" src="images/' + newimg + '" alt="' + alt + '" height="160px" width="160px" />';
        if (imgobj.filters && window.createPopup)
        {
            imgobj.style.filter=filterstring;
            imgobj.filters[0].Apply();
        }
        if (imgobj.filters && window.createPopup)
        {
            imgobj.filters[0].Play();
            imgobj.innerHTML = imgsrc;
        }
        idef++;
    }
    if(document.getElementById && idef == 2)
    {
        var imgsrc =  banner_src;
        if (imgobj.filters && window.createPopup)
        {
            imgobj.style.filter=filterstring;
            imgobj.filters[0].Apply();
        }
        if (imgobj.filters && window.createPopup)
        {
            imgobj.filters[0].Play();
            imgobj.innerHTML = imgsrc;
        }
        idef=0;
    }
}
//------------------------------------------------------------------------------------------
// This function will revert the banner back to the image that it was (fade)
function revert_banner(objid)
{
    revertID = objid;
    clearTimeout(timer);
    timer = setTimeout("idef=2;rotate_banner(revertID,1,1,1)",2000);
}
//------------------------------------------------------------------------------------------
// Show the hidden banner in place of the original banner
function showHiddenBanner(num)
{
    var obj = document.getElementById('default_banner_' + num + '_img');
    var hiddenobj = document.getElementById('default_banner_' + num + '_img_hidden');
    //window.status = obj.id + ' ' + hiddenobj.id;
    obj.style.display = 'none';
    hiddenobj.style.display = '';
}
//------------------------------------------------------------------------------------------
// Show the hidden banner in place of the original banner
function showBanner(num)
{
    var obj = document.getElementById('default_banner_' + num + '_img');
    var hiddenobj = document.getElementById('default_banner_' + num + '_img_hidden');
    obj.style.display = '';
    hiddenobj.style.display = 'none';
}
