<%
' *****************************************************************************
'
'	This file contains methods and variables to help with the use of the 
'	NCASPExtenstion ASPUtils object. It also contains some general utility 
'	functions for use in ASP.
'
' *****************************************************************************

' This is the global variable which is returned by the getASPUtils method. 
' It is not to be used directly, but through the accessor method that will 
' allow any needed initialization to be done in one place.
Dim pASPUtilsForGlobalDissemination
Set pASPUtilsForGlobalDissemination = Nothing

' -----------------------------------------------------------------------------
'
'	Accessor function for the ASPUtils object.  At this time, it does no extra
'	initialization, but if more becomes required, it should be added to this 
'	function
'
'	@return - The ASPUtils object
'
' -----------------------------------------------------------------------------
Function GetInitializedASPUtils()
    ' Do lazy initialization -- I don't think this actually does lazy 
    ' initialization, because I think that ASP takes care of all of the
    ' create object calls before it runs the script ... but if not....
    If pASPUtilsForGlobalDissemination Is Nothing Then
        Set pASPUtilsForGlobalDissemination = Server.CreateObject("NCASPExtensions.ASPUtils")
    End If

    ' Return our local global to the client to use
    Set GetInitializedASPUtils = pASPUtilsForGlobalDissemination
End Function

' -----------------------------------------------------------------------------
'
'	Does a server side redirect.  Calls ASPUtils redirect method (not
'	response.redirect).  If we change the way we do this, or MS cleans up its
'	redirect method, this function can be changed to take out the reliance on
'	the ASPUtils object
'
'	@strRedirectURL - the URL to redirect to
'
' -----------------------------------------------------------------------------
Sub ServerSideRedirect( strRedirectURL )
    'Get a copy of our ASPUtils object
    Dim pASPUtils
    Set pASPUtils = GetInitializedASPUtils()
    
    'Call the ASPUtils method with the passed in URL as the redirect address
    pASPUtils.Redirect( strRedirectURL )
End Sub


' -----------------------------------------------------------------------------
'
'  This helper function retrieves the major version number in long value of
'  the full version number if it is using decimal symbot "." as a separator
'  to define the version number. Otherwise, it returns the originl value.
'  The information from ASP ServerVariables are always using decimal symbot as a 
'  separator even though the server is using non-English OS and other separator 
'  symbot such as comma ",".
'         
'	@param	strFullVersion [in] - a string contains a full version number 
'           with decimal symbot "." as a separator (e.g 5.1.0.12)
'
' -----------------------------------------------------------------------------
Function GetMajorVersion(strFullVersion)

	' get the first decimal separator location 	
	Dim nDecimalStart	
	nDecimalStart = InStr(strFullVersion, ".")
	
	If (nDecimalStart > 1) Then
		
		' returns the major version number
		GetMajorVersion = Left(strFullVersion, nDecimalStart - 1)
	Else
		
		' returns the original version if decimal doesn't exit
		GetMajorVersion = strFullVersion
	End If
End Function

%>