


function turnOn(navName){
    document.images[navName].src = eval(navName + "_on.src");
}


function turnOff(navName){
    document.images[navName].src = eval(navName + "_off.src");
}


/***************************************************************************************
 * writeWelcome()                                                                      *
 ***************************************************************************************
 *                                                                                     *
 * Description:                                                                        *
 *   Displays a dynamic welcome message on the screen that says                        *
 *   'Welcome, xxx. Not xxx? ID=xxx'. It displays the user's first name and RacePoints *
 *   ID number. It gets these values from a cookie that gets set on the RacePoints     *
 *   site. Of course, if the cookie can't be found or loaded, we gracefully do not     *
 *   display a welcome message, we just say 'Not Logged in' instead.                   *
 *                                                                                     *
 *                                                                                     *
 * Parameters:                                                                         *
 *   None                                                                              *
 *                                                                                     *
 *                                                                                     *
 * Return:                                                                             *
 *   Nothing                                                                           *
 *                                                                                     *
 ***************************************************************************************/
function writeWelcome()
{
    var firstName = getCookie('fname');
    var RPID      = getCookie('uid');

    // Browser-specific Div Finding.
    if (document.getElementById)
    {
        welcomBarDiv = document.getElementById('welcomeBar')
        RPIDDiv      = document.getElementById('RPID');
    }
    else if (document.all)
    {         
        welcomBarDiv = document.all['welcomeBar'];
	  RPIDDiv      = document.all['RPID'];
    }

    // Set the text of the <div> tags based on current user status.
    if ((firstName != null) && (RPID != null))
    {
        welcomBarDiv.innerHTML = "Hello, " + firstName + ".<a href=\"javascript:logOut();\">&nbsp;Not " + firstName + "?</a>";
	  RPIDDiv.innerHTML      = "Your NASCAR RacePoints<span style = 'font-size: 9px;'><sup>SM</sup></span> ID# " + RPID;
    }
    else
    {
        welcomBarDiv.innerHTML = "Not Logged in";
        RPIDDiv.innerHTML      = ""; 
    }
}






/***************************************************************************************
 * getCookie()                                                                         *
 ***************************************************************************************
 *                                                                                     *
 * Description:                                                                        *
 *   Searches through the cookies for the current domain for a specific cookie.        *
 *   When it finds the cookie, it reads and returns the data contained inside.         *
 *                                                                                     *
 *                                                                                     *
 * Parameters:                                                                         *
 *   name: The name of the cookie we're searching for (in the name/value pairs)        *
 *                                                                                     *
 *                                                                                     *
 * Return:                                                                             *
 *   The data inside the cookie, or null if the cookie wasn't found                    *
 *                                                                                     *
 ***************************************************************************************/
function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0)
        {
            return null;
        }
    }
    else
    {
        begin += 2;
    }

    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }

    return unescape(dc.substring(begin + prefix.length, end));
}


/***************************************************************************************
 * setCookie()                                                                         *
 ***************************************************************************************
 *                                                                                     *
 * Description:                                                                        *
 *   Creates a new cookie (for this domain).                                           *
 *                                                                                     *
 *                                                                                     *
 * Parameters:                                                                         *
 *   name :    The name of the cookie we're adding                                     *
 *   value :   The value of the new cookie                                             *
 *   expires : (optional)Expiration date of the cookie. Defaults to end of the session *
 *   path :    (optional)Path where the cookie is valid                                *
 *   domain :  (optional)Domain where the cookie is valid                              *
 *   secure :  (optional)requires a secure transmission? Defaults to no                *                                   
 *                                                                                     *
 *                                                                                     *
 * Return:                                                                             *
 *   Nothing                                                                           *
 *                                                                                     *
 ***************************************************************************************/
function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}


/***************************************************************************************
 * removeCookie()                                                                      *
 ***************************************************************************************
 *                                                                                     *
 * Description:                                                                        *
 *   Removes a cookie from the user's computer                                         *
 *                                                                                     *
 *                                                                                     *
 * Parameters:                                                                         *
 *   name :    The name of the cookie we're removing                                   *                                   
 *                                                                                     *
 *                                                                                     *
 * Return:                                                                             *
 *   Nothing                                                                           *
 *                                                                                     *
 ***************************************************************************************/
function removeCookie(name, domain)
{
    var cookieDate = new Date ();
    cookieDate.setTime(cookieDate.getTime() - 1);
    
    document.cookie = name += "=; expires=" + cookieDate.toGMTString() +
        ((domain) ? "; domain=" + domain : "");
}