<%
	'************************************************************************************
	'*																					*
	'*																					*
	'*																					*
	'************************************************************************************
	Function CONVERSION_SQLEncode2(sString, iLen)
	
		CONVERSION_SQLEncode2 = SQLEncode(Left(CONVERSION_Trim(sString),iLen))
		
	End Function
	'************************************************************************************
	
	
	'************************************************************************************
	'*																					*
	'*	This formats the date for SQL statements. This is required because not all  	*
	'*	places in the world use the USA date format and MSSQL requires that dates		*
	'*	be in this format: mm/dd/yyyy or mm/dd/yyyy hh:mm:ss							*
	'*	Also in some languages May is Mai, etc. and MSSQL doesn't understand Mai.		*
	'*	The sLength parameter is "S" for shortdatetime and "L" for datetime (long date)	*
	'*																					*
	'************************************************************************************
	Function CONVERSION_FormatDate(sDate, cLength)
	
		Dim sYear, sMonth, sDay, sHour, sMinute, sSecond

		If ( IsDate(sDate) ) Then
			If ( cLength = "L" ) Then
				' make the date long
				sYear		= DatePart("yyyy", sDate)
				sMonth		= DatePart("m", sDate)
				sDay		= DatePart("d", sDate)
				sHour		= DatePart("h", sDate)
				sMinute		= DatePart("n", sDate)
				sSecond		= DatePart("s", sDate)
				If ( sOWDateFormat = "1" ) Then
					CONVERSION_FormatDate = sMonth & "/" & sDay & "/" & sYear & " " & sHour & ":" & sMinute & ":" & sSecond
				Else
					CONVERSION_FormatDate = sDay & "/" & sMonth & "/" & sYear & " " & sHour & ":" & sMinute & ":" & sSecond
				End If
			Else
				' make the date short - default to this since it's more compatable
				sYear		= DatePart("yyyy", sDate)
				sMonth		= DatePart("m", sDate)
				sDay		= DatePart("d", sDate)
				If ( sOWDateFormat = "1" ) Then
					CONVERSION_FormatDate = sMonth & "/" & sDay & "/" & sYear
				Else
					CONVERSION_FormatDate = sDay & "/" & sMonth & "/" & sYear
				End If
			End If
		Else
			CONVERSION_FormatDate = sDate
		End If

	End Function
	'************************************************************************************

	
	
	'************************************************************************************
	'*																					*
	'*																					*
	'*																					*
	'************************************************************************************
	Function CONVERSION_Currency(iAmount)
	
		if isNull(iAmount) Or ( iAmount = "" ) then 
			CONVERSION_Currency = FormatCurrency(0.00, 4, -2, 0, -2)
		else
			If ( bOWDoNotRoundMoney ) Then
				CONVERSION_Currency = FormatCurrency(iAmount, 4, -2, 0, -2)
			Else
				CONVERSION_Currency = FormatCurrency(iAmount, 2, -2, 0, -2)
			End If 
		End If
		
	End Function
	'************************************************************************************

	
	
	'************************************************************************************
	'*																					*
	'*																					*
	'*																					*
	'************************************************************************************
	Function CONVERSION_Trim(sValue)
	
		If ( IsNull(sValue) ) Then
			CONVERSION_Trim = ""
		Else
			CONVERSION_Trim = Trim(sValue)
		End If
	
	End Function
	'************************************************************************************
	
	
	'************************************************************************************
	'*																					*
	'*	Encodes a string for use in a SQL Statement.						 			*
	'*																					*
	'************************************************************************************
	Function SQLEncode( sStr )

		If ( NOT IsNull(sStr) ) Then
			If ( NOT IsNumeric(sStr) ) Then
				If ( sStr <> "" ) Then
					SQLEncode = Replace( sStr, "'", "''" )
				End If
			Else
				SQLEncode = CStr(sStr)
			End If
		Else
			SQLEncode = ""
		End If

	End Function
	'************************************************************************************
	
	
	'************************************************************************************
	'*																					*
	'*																					*
	'*																					*
	'************************************************************************************
	Function CONVERSION_Numeric(sString, iType)
	
		sString = Trim(sString)
	
		If ( sString = "" ) Then
			CONVERSION_Numeric = 0
		Else
			If ( IsNull(sString) ) Then
				CONVERSION_Numeric = 0
			Else
				If ( IsNumeric(sString) ) Then
					If ( iType = C_DOUBLE ) Then
						CONVERSION_Numeric = CDbl(sString)
					Else
						CONVERSION_Numeric = CInt(sString)
					End If
				Else
					CONVERSION_Numeric = 0
				End If
			End If
		End If
		
	End Function
	'************************************************************************************
	
	
	'************************************************************************************
	'*																					*
	'*	String concatenation class (using an array)										*
	'*																					*
	'*		Written by Marcus Tucker, July 2004											*
	'*		http://marcustucker.com														*
	'*																					*
	'************************************************************************************
'Set tmp = New StrConCatArray
'tmp.Add SubString
'TestString = tmp.value
'Set tmp = Nothing
	Class StrConCatArray
		Private StringCounter
		Private StringArray()
		Private StringLength
		
		'called at creation of instance
		Private Sub Class_Initialize()
			StringCounter = 0
			InitStringLength = 128
			ReDim StringArray(InitStringLength - 1)
			StringLength = InitStringLength
		End Sub
		
		Private Sub Class_Terminate()
			Erase StringArray
		End Sub
	
		'add new string to array
		Public Sub Add(byref NewString)
			StringArray(StringCounter) = NewString
			StringCounter = StringCounter + 1
			
			'ReDim array if necessary
			If StringCounter MOD StringLength = 0 Then
				'redimension
				ReDim Preserve StringArray(StringCounter + StringLength - 1)
				
				'double the size of the array next time
				StringLength = StringLength * 2
			End If
		End Sub
		
		'return the concatenated string
		Public Property Get Value
			Value = Join(StringArray, "")
		End Property 
		
		'resets array
		Public Function Clear()
			StringCounter = 0
			
			Redim StringArray(InitStringLength - 1)
			StringLength = InitStringLength
		End Function		
	End Class 
	'************************************************************************************
	
	
	'************************************************************************************
	'*																					*
	'*	String concatenation class (using a stream)										*
	'*																					*
	'*		Written by Marcus Tucker, July 2004											*
	'*		http://marcustucker.com														*
	'*																					*
	'************************************************************************************
	Class StrConCatStream
		Private Stream
		Private StringArray()
		Private StringLength
		
		'called at creation of instance
		Private Sub Class_Initialize()
			Set Stream = Server.CreateObject("ADODB.Stream")
			Stream.Type = 2 'Text
			Stream.Open
		End Sub
		
		Private Sub Class_Terminate()
			Stream.Close
			Set Stream = Nothing
		End Sub
	
		'add new string to array
		Public Sub Add(byref NewString)
			Stream.WriteText NewSring
		End Sub
		
		'return the concatenated string
		Public Property Get Value
			Stream.Position = 0
			Value = Stream.ReadText()
		End Property
	
		'resets class
		Public Function Clear()
			StringCounter = 0
			Stream.Position = 0
			Call Stream.SetEOS()
		End Function		
	End Class
	'************************************************************************************
%>