function udfValidName(strName)
{
    // checks the length of strName with "."'s removed

    //var lregSearch = /\W/g     // remove all except A-Z, a-z, 0-9, and "_"
    var lregSearch = /\./g       // remove all "."'s
    //var lregSearch = /-/g      // remove all "-"'s  

    var lstrResult = strName
    lstrResult = lstrResult.replace(lregSearch, '')
    lstrResult = udfTrim(lstrResult)

    if (lstrResult.length < 2)
    {
        return(false)
    }

    return(true)
}


function udfGetIndexValue(objObject, strValue)
{
    // returns the index for a given object value

    for (var i = 0; i < objObject.length; i++)
    {
        //if (objObject.options[i].selected == true)

        if (objObject.options[i].value == strValue)
        {
            return objObject.options[i].index
        }
    }

    return(-1)
}


function udfTrim(strString)
{
    var lstrResult = strString
    lstrResult = udfLTrim(lstrResult)
    lstrResult = udfRTrim(lstrResult)
    
    return(lstrResult)    
}


function udfLTrim(strString)
{
    var lregSearch = /^\s*/      // remove all white space

    var lstrResult = strString
    lstrResult = lstrResult.replace(lregSearch, '')

    return(lstrResult)    
}


function udfRTrim(strString)
{
    var lregSearch = /\s*$/      // remove all white space

    var lstrResult = strString
    lstrResult = lstrResult.replace(lregSearch, '')
    
    return(lstrResult)    
}


function udfGetSearch(strName)
{
    // returns the Value for a given Name stored in window.location.search (substring of the href property that follows the ? symbol)
    // e.g. window.location.search = '?pg=aq&stype=%22stext%22&Translate=on'

    var lstrSearch = '&' + window.location.search.substring(1)    // remove the "?"
    var lstrName = '&' + strName + '='
    var lstrValue = ''
    var lintStart = 0
    var lintEnd = 0

    if (lstrSearch.length > 1)
    {
        lintStart = lstrSearch.indexOf(lstrName)

        if (lintStart != -1)
        {
            lintStart = lintStart + lstrName.length
            lintEnd = lstrSearch.indexOf('&', lintStart)

            if (lintEnd == -1)
            {
                lintEnd = lstrSearch.length
            }

            lstrValue = unescape(lstrSearch.substring(lintStart, lintEnd))
        }
    }

    return(lstrValue)
}


function udfGetCookie(strName)
{
    // returns the Value for a given cookie Name
    // note: when a cookie value is set to a zero length string IE includes the name without "=" where Netscape includes the "=" - this function will not work in IE for a zero length string

    var lstrCookie = ' ' + document.cookie
    var lstrName = ' ' + strName + '='
    var lstrValue = ''
    var lintStart = 0
    var lintEnd = 0

    if (lstrCookie.length > 1)
    {
        lintStart = lstrCookie.indexOf(lstrName)

        if (lintStart != -1)
        {
            lintStart = lintStart + lstrName.length
            lintEnd = lstrCookie.indexOf(';', lintStart)

            if (lintEnd == -1)
            {
                lintEnd = lstrCookie.length
            }

            lstrValue = unescape(lstrCookie.substring(lintStart, lintEnd))
        }
    }

    return(lstrValue)
}


function udpBack(strAlternateURL)
{
    // goes back one page, or to strAlternateURL if there is no page to go back to

    if (!strAlternateURL)
    {
        alert('dev error - missing parameter in udpBack')
        return
    }

    var lintBase = 0
    if (udfMSIEVersion() == 0) lintBase = 1

    if (window.history.length <= lintBase)
    {
        // very first page opened in the browser
        window.location.href = strAlternateURL
    }
    else
    {
        window.history.back()
        //window.history.go(-1)        // same as .back()
    }
}


function udfMSIEVersion()
{
    // returns Microsoft Internet Explorer major version number - or 0 for other browsers

    var ua = window.navigator.userAgent
    var msie = ua.indexOf ( "MSIE " )
    if ( msie > 0 ) 
        return parseInt ( ua.substring ( msie+5, ua.indexOf ( ".", msie ) ) ) 
    else
        return 0 

    // notes:
    // - the following taken from Microsoft's home page
    //     (navigator.userAgent.indexOf("MSIE") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.appVersion.substring(0,1) > 3)		
    // - IE 5.01 SP1 returned navigator.appVersion = "4.0 (..."
}

