//-----------------------------------------------------------------------------
// Highlight the links in the right nav
//-----------------------------------------------------------------------------
function hiLite( objElmt, bMouseIn )
{
    switch ( bMouseIn )
    {
        case true  : {
                objElmt.style.backgroundColor = '#C9C9C9';
                break;
        }
        case false : {
                objElmt.style.backgroundColor = '#B6B6B6';
                break;
        }
    }
}

//-----------------------------------------------------------------------------
// CLASS - AdRotator
//         Requires Prototype JavaScript Framework.
//         A simple class to rotate banners ads
//         Banner Ads can have a max width of 690px.
//         
//         NOTE: Current this is set up for a MAX of 10 banner ads.
//               Although it's easily modifiable.
//-----------------------------------------------------------------------------
var AdRotator = Class.create(
{
    // Class constructor.  Called automatically when a new AdRotator object is instantiated.
    initialize: function() 
    {        
        // Arrays to store Ad images, associated links & ALT text.
        this.adImgArray = new Array();
        this.adLnkArray = new Array();
        this.adTxtArray = new Array();

        // Populate the Ad img array
        this.adImgArray[0] = "freeHawgGraphics.gif";
        this.adImgArray[1] = "pgr.jpg";
        this.adImgArray[2] = "superSundayBanner.gif";
        this.adImgArray[3] = "logoChip.gif";

        // Populate the Links array w/ corresponding links.
        this.adLnkArray[0] = "http://www.hawggraphics.com/";
        this.adLnkArray[1] = "http://www.patriotguard.org/";
        this.adLnkArray[2] = "http://www.supersundayonline.com/";
        this.adLnkArray[3] = "http://www.buffalochip.com";

        // And now for the matching ALT text.
        this.adTxtArray[0] = "Free Hawg Graphics for Bikers";
        this.adTxtArray[1] = "Patriot Guard";
        this.adTxtArray[2] = "Super Sunday Online";
        this.adTxtArray[3] = "Buffalo Chip";

        // Index of the last ad to be displayed.
        this.nextAdIndex = this.getRandomStartIndex();
    }

    // Get a random start index for the Ad Rotator to begin with
    ,getRandomStartIndex: function()
    {
        // Get a random number between 0 & 1
        var randNum = Math.random();

        // Multiply by 10 and round it off, to turn it into a whole number
        if ( randNum != 0 && randNum != 1 ) {
            randNum = Math.round( randNum * 10 );

            // make sure our random number makes sense in the context of our array sizes.
            while ( randNum > (this.adImgArray.length - 1) ) {
                randNum = Math.random();
                randNum = Math.round( randNum * 10 );
            }
        }

        // Return the starting index
        return randNum;
    }

    // Return a banner ad to display
    ,getNextAd: function( htmlElmt )
    {
        var bannerAd = new String();

        if ( (this.nextAdIndex < 0) || (this.nextAdIndex > (this.adImgArray.length - 1)) ) {
                this.nextAdIndex = 0;
        }

        try
        {
            bannerAd =
                "<a href='" + this.adLnkArray[this.nextAdIndex] + "' target='_blank'>" +
                "<img border='0' src='bannerAds/" + this.adImgArray[this.nextAdIndex] + "' "     +
                "alt='" + this.adTxtArray[this.nextAdIndex] + "'>" + "</a>";

            htmlElmt.innerHTML = bannerAd;
            this.nextAdIndex++;
        }
        catch( e )
        {
            // The Array index is off for some reason.  Just display a blank line & reset the index.
            htmlElmt.innerHTML = "<br>";
            this.nextAdIndex = 0;
        }
    }
});

