/*
#################################################################################
#                                                                               #
#   Module:     smb_stdutils.js                                                 #
#                                                                               #
#   Purpose:    This module contains "standard" JavaScript utility functions    #
#               that are used throughout the SMB site.                          #
#                                                                               #
#   Functions:  getCurrentDateAsString()                                        #
#               trim( strSource )                                               #
#                                                                               #
#   Change Log:                                                                 #
#                                                                               #
#   Date      Programmer            Change                                      #
#   ========  ===================== =========================================== #
#   12/21/04  Fred Rockenbach       Creation                                    #
#                                                                               #
#################################################################################
*/




/*
#################################################################################
#                                                                               #
#   Function:       getCurrentDateAsString()                                    #
#                                                                               #
#   Purpose:        This function returns the date as a text string in the      #
#                   format:  "Month day, Year"                                  #
#                                                                               #
#                   Not as compact, perhaps, as an array index lookup scheme,   #
#                   but fully KISS compliant and hence robust.                  #
#                                                                               #
#   Returns:        Current date as a text string.                              #
#                                                                               #
#################################################################################
*/
function getCurrentDateAsString()
    {
    var today       = new Date();
    var day         = today.getDate();
    var month       = today.getMonth();
    var year        = today.getYear();
    var strMonth;
            
    if ( year < 1900 )
        {
        year += 1900;
        }

    switch ( month )
        {
        case 0:
            strMonth = "January"; 
            break;
            
        case 1:
            strMonth = "February";
            break;
            
        case 2:
            strMonth = "March";
            break;
            
        case 3:
            strMonth = "April";
            break;
            
        case 4:
            strMonth = "May";
            break;
            
        case 5:
            strMonth = "June";
            break;
            
        case 6:
            strMonth = "July";
            break;
            
        case 7:
            strMonth = "August";
            break;
            
        case 8:
            strMonth = "September";
            break;
            
        case 9:
            strMonth = "October";
            break;
            
        case 10:
            strMonth = "November";
            break;
            
        case 11:
            strMonth = "December";
            break;
                
        default:
            strMonth = "Unknown";
            break;
        }
            
                
    return( strMonth + " " + day + ", " + year );
    }
            
    



/*
#################################################################################
#                                                                               #
#   Function:   trim()                                                          #
#                                                                               #
#   Purpose:    Strips off leading white space and trailing white space from    #
#               a string, including newline and tab characters.                 #
#                                                                               #
#   Returns:    A string based on strSource, minus any leading or trailing      #
#               white space characters.                                         #
#                                                                               #
#################################################################################
*/
function trim( strSource )
    {
    /*
    =============================================================================
    =   Find the left-most position of a character that is NOT a blank,         =
    =   newline, or tab, and then exit the loop, leaving the value of leftIndex =
    =   set to that character position in "strSource".                          =
    =============================================================================
    */ 
    var leftIndex = 0;

    while ( leftIndex < strSource.length ) 
        {
        ch = strSource.charAt( leftIndex );
        
        if (ch != " " && ch != "\n" && ch != "\t") break;
        
        leftIndex++;
        }
    
    /*
    =============================================================================
    =   Check for an empty string.                                              =
    =============================================================================
    */
    if ( leftIndex == strSource.length )
        {
        return( "" );
        }
        
    /*
    =============================================================================
    =   Find the right-most position of a character that is NOT a blank,        =
    =   newline, or tab, and then exit the loop, leaving the value of           =
    =   rightIndex set to that character position.                              =
    =============================================================================
    */
    var rightIndex = strSource.length - 1;

    while ( rightIndex >= leftIndex ) 
        {
        ch = strSource.charAt( rightIndex )
        
        if (ch != " " && ch != "\n" && ch != "\t") break;
        
        rightIndex--;
        }

    /*
    =============================================================================
    =   The value of leftIndex now points at the left-most non-whitespace char, =
    =   and the value of rightIndex now points at the right-most non-whitespace =
    =   char.  Return the substring from leftIndex to rightIndex, inclusive.    =
    =============================================================================
    */
    return( strSource.substring( leftIndex, rightIndex + 1 ) );
    }




/*
#################################################################################
#                                                                               #
#   From dstore\dcart\html\showhidemenus.inc:                                   #
#                                                                               #
#################################################################################
*/
    var browser = navigator.appName;
    var version = parseInt(navigator.appVersion);
    var block1;
    var block2;
    var block3;
        
    var ns5 = (browser == "Netscape" && version > 4);
    var ie4 = (browser == "Microsoft Internet Explorer" && version >= 4);
    var ns3 = (browser == "Netscape" && version == 3);
    var ie3 = (browser == "Microsoft Internet Explorer" && version < 4);
    var ns2 = (browser == "Netscape" && version < 3);
    var ready = false;
    
    function init_nav()
    // don't forget to put function call in body tag
    {
        if (ie4) block1 = document.getElementById("one").style
        if (ns5) block1 = document.getElementById("one").style
    
        if (ie4) block2 = document.getElementById("two").style
        if (ns5) block2 = document.getElementById("two").style
        
        if (ie4) block3 = document.getElementById("three").style
        if (ns5) block3 = document.getElementById("three").style
        
        ready = true
    }
        
        
    // hide and show for layers
    function showObject(obj) 
    {
        if (ready)
        {
            if (ns5) obj.visibility = "visible"        
            else if (ie4) obj.visibility = "visible"
        }
    }
    
    function hideObject(obj) 
    {
        if (ready)
        {
            if (ns5) obj.visibility = "hidden"        
            else if (ie4) obj.visibility = "hidden"
        }
    }
    
    function drop(dropnum)
    {
        if (ready)
        {
        //hideall()
            if (dropnum == 1) 
                {
                showObject(block1); 
                }
                
            if (dropnum == 2) 
                {
                showObject(block2); 
                }
                
            if (dropnum == 3) 
                {
                showObject(block3); 
                }
        }
    }
    
    function hideall()
    {
        hideObject(block1);
        hideObject(block2);
        hideObject(block3);
    }
    
    function hideone()
    {
        hideObject(block1);
    }
    
    function hidetwo()
    {
        hideObject(block2);
    }
    
    function hidethree()
    {
        hideObject(block3);
    }
    
    
    function donothing() 
    {}

    
// background change    
    function td_on(tdnumber){
    tdNum = tdnumber
    tdChangeOn = document.getElementById("td" + tdNum +"");
    tdChangeOn.className='on';
    return;
    }       
    
    function td_off(tdnumber){
    tdNum = tdnumber
    tdChangeOff = document.getElementById("td" + tdNum +"");
    tdChangeOff.className='off';
    return;
    }  
     
 
/*
#################################################################################
#                                                                               #
#                       E N D    O F    M O D U L E                             #
#                                                                               #
#################################################################################
*/
