<%
	'************************************************************************************
	'*																					*
	'*	LANG_DT stands for Language "D"isplay "T"ext									*
	'*		The reason for the sEnglish is simply to allow for ease of debugging and	*
	'*		finding where text is. It also allows English speaking websites faster 		*
	'*		access to the text -- rather than getting from the database.				*
	'*																					*
	'************************************************************************************
	Function LANG_DT( sStrConst, sValue )
	
		Dim sTemp, rsStoreData
		
		sTemp = iOWIDLanguageSchemes & "_" & sStrConst
		
		If ( sStrConst = "" ) Then
			LANG_DT = sValue
		Else
			LANG_DT = Application(sTemp)
			If ( LANG_DT = "" ) Then
				set rsStoreData = CreateObject("ADODB.Recordset")
				sSQLText = "SELECT * FROM LanguageMap WHERE TextConst = '" & SQLEncode(sStrConst) & "' AND idLanguageSchemes = " & iOWIDLanguageSchemes
				call DB_getFromDatabase (sSQLText, rsStoreData, "")
				If ( NOT rsStoreData.EOF ) Then
					If ( rsStoreData("DataType") = "T" ) Then
						LANG_DT = rsStoreData("TextData")
					Else
						LANG_DT = rsStoreData("VarCharData")
					End If
					Application(sTemp) = LANG_DT
				Else
					' it doesn't exist yet. add it
					If ( Len(sValue) > 250 ) Then
						Call DB_updateDatabase("INSERT INTO LanguageMap (TextConst, DataType, VarCharData, TextData, idLanguageSchemes) VALUES ('" & SQLEncode(sStrConst) & "', 'T', '', '" & SQLEncode(sValue) & "', " & iOWIDLanguageSchemes & ")")
					Else
						Call DB_updateDatabase("INSERT INTO LanguageMap (TextConst, DataType, VarCharData, TextData, idLanguageSchemes) VALUES ('" & SQLEncode(sStrConst) & "', 'V', '" & SQLEncode(sValue) & "', '', " & iOWIDLanguageSchemes & ")")
					End If
					Application(sTemp)	= sValue
					LANG_DT				= sValue
				End If
				Call DB_closeRecordset(rsObject)
				Set rsStoreData = Nothing
			End If
		End If
		
	End Function
	'************************************************************************************
	
	
	'************************************************************************************
	'*																					*
	'*																					*
	'*																					*
	'************************************************************************************
	Sub LANG_SaveSimple(sValue, sIDLanguageMap)
	
		Call LANG_SaveText("", sValue , "", sIDLanguageMap)
	
	End Sub
	'************************************************************************************
	
	
	'************************************************************************************
	'*																					*
	'*	"Adv" = Advanced																*
	'*																					*
	'************************************************************************************
	Sub LANG_SaveAdv(sTextConst, sValue, sIDLanguageSchemes)
	
		Call LANG_SaveText(sTextConst, sValue , sIDLanguageSchemes, "")
		
	End Sub
	'************************************************************************************
	
	
	'************************************************************************************
	'*																					*
	'*																					*
	'*																					*
	'************************************************************************************
	Sub LANG_SaveText(sTextConst, sValue , sIDLanguageSchemes, sIDLanguageMap)
	
		If ( ( IsNumeric(sIDLanguageMap) ) And ( sIDLanguageMap <> "" ) ) Then
			If ( Len(sValue) > 250 ) Then
				Call DB_updateDatabase("UPDATE LanguageMap SET DataType = 'T', VarCharData = '', TextData = '" & SQLEncode(sValue) & "' WHERE idLanguageMap = " & sIDLanguageMap)
			Else
				Call DB_updateDatabase("UPDATE LanguageMap SET DataType = 'V', VarCharData = '" & SQLEncode(sValue) & "', TextData = '' WHERE idLanguageMap = " & sIDLanguageMap)
			End If
			' still have to get the TextConst & sIDLanguageSchemes to be able to write to the Application object below
			sSQLText = "SELECT * FROM LanguageMap WHERE idLanguageMap = " & sIDLanguageMap
			Call DB_getFromDatabase(sSQLText, rsStoreData, "")
			If ( NOT rsStoreData.EOF ) Then
				sTextConst			= rsStoreData("TextConst")
				sIDLanguageSchemes	= rsStoreData("idLanguageSchemes")
			End If
			Call DB_closeRecordset(rsStoreData)
		Else
			sSQLText = "SELECT * FROM LanguageMap WHERE TextConst = '" & SQLEncode(sTextConst) & "' AND idLanguageSchemes = " & sIDLanguageSchemes
			Call DB_getFromDatabase(sSQLText, rsStoreData, "")
			If ( rsStoreData.EOF ) Then
				' it doesn't exist for this language, insert it
				If ( Len(sValue) > 250 ) Then
					Call DB_updateDatabase("INSERT INTO LanguageMap (TextConst, DataType, VarCharData, TextData, idLanguageSchemes) VALUES ('" & SQLEncode(sTextConst) & "', 'T', '', '" & SQLEncode(sValue) & "', " & sIDLanguageSchemes & ")")
				Else
					Call DB_updateDatabase("INSERT INTO LanguageMap (TextConst, DataType, VarCharData, TextData, idLanguageSchemes) VALUES ('" & SQLEncode(sTextConst) & "', 'V', '" & SQLEncode(sValue) & "', '', " & sIDLanguageSchemes & ")")
				End If
			Else
				' it exists for this language, update it
				If ( Len(sValue) > 250 ) Then
					Call DB_updateDatabase("UPDATE LanguageMap SET DataType = 'T', VarCharData = '', TextData = '" & SQLEncode(sValue) & "' WHERE TextConst = '" & SQLEncode(sTextConst) & "' AND idLanguageSchemes = " & sIDLanguageSchemes)
				Else
					Call DB_updateDatabase("UPDATE LanguageMap SET DataType = 'V', VarCharData = '" & SQLEncode(sValue) & "', TextData = '' WHERE TextConst = '" & SQLEncode(sTextConst) & "' AND idLanguageSchemes = " & sIDLanguageSchemes)
				End If
			End If      
			Call DB_closeRecordset(rsStoreData)
		End If
		
		Application.Lock
		Application(sIDLanguageSchemes & "_" & sTextConst) = sValue
		Application.Unlock
	
	End Sub
	'************************************************************************************
%>