<%
Function FormatSpecText(Text)


Replace Text, "'", "''"
Replace Text, "%23", "#"
Replace Text, "%38", "&"
Replace Text, "%27", "''"

FormatSpecText = Text

End Function



Function GetYearDD()
Dim CurrentYear, HTML
CurrentYear = Year(Date())

HTML = "<option value=" & CurrentYear & " selected>" & CurrentYear & "</option>" & Chr(13)

For i = 1 to 3
HTML = HTML & "<option value=" & CurrentYear + i & ">" & CurrentYear + i & "</option>" & Chr(13)
Next

GetYearDD = HTML

End Function

Function GetLodgingVars(Entity_ID, Page)
Dim SQL2, i, HTML
i = 0
HTML = ""
Set RS2 = Server.CreateObject("ADODB.Recordset")
	SQL2 = "Select * from Entity E inner join (Group_Entity_Map GEM inner join (Att_Group_Map AGM Inner Join Attribute_Type A "
	SQL2 = SQL2 & "on AGM.ATT_ID = A.ATT_ID) on GEM.Group_ID = AGM.Group_ID)	on E.Entity_ID = GEM.Entity_ID "
	SQL2 = SQL2 & "Where E.Entity_ID = '" & Request.QueryString("Entity_ID") & "' And Att_Page = '" & Page & "' And Not Att_Group_ID = '7' "
		
RS2.Open SQL2, Conn

Do Until RS2.EOF
If Not Trim(RS2("Variable")) = "" Then
If i > 0 Then 
If RS2("Variable") = "True" Then HTML = HTML & ", " & RS2("Att_Desc_Detail") Else HTML = HTML &  ", " & RS2("Att_Desc_Detail") & " : " & RS2("Variable")
Else
If RS2("Variable") = "True" Then HTML = HTML &  RS2("Att_Desc_Detail") Else HTML = HTML &  RS2("Att_Desc_Detail") & ":" & RS2("Variable")
End If
End If
RS2.MoveNext()
i = i + 1
Loop

GetLodgingVars = HTML

RS2.Close()
Set RS2 = Nothing

End Function

Function PCase(strInput)
    Dim iPosition 
    Dim iSpace 
    Dim strOutput 

    iPosition = 1

    Do While InStr(iPosition, strInput, " ", 1) <> 0
            iSpace = InStr(iPosition, strInput, " ", 1)
            strOutput = strOutput & UCase(Mid(strInput, iPosition, 1))
            strOutput = strOutput & LCase(Mid(strInput, iPosition + 1, iSpace - iPosition))
            iPosition = iSpace + 1
    Loop

    strOutput = strOutput & UCase(Mid(strInput, iPosition, 1))
    strOutput = strOutput & LCase(Mid(strInput, iPosition + 1))

    PCase = strOutput
End Function

Function FCurrency(Amount, CurType)

' l33t comments
'
'  Curtype 1 returns   xxxxx.xx format
'  Curtype 2 returns  $xxxxx.xx format
'  Curtype 3 returns  xx,xxx.xx format
'  Curtype 4 returns $xx,xxx.xx format
'

   If CurType = 1 Then
	Amount = Replace(Replace(FormatCurrency(Amount, 2, -1, 0, -1), "$", ""), ",", "")
	FCurrency = Amount

   ElseIf CurType = 2 Then
	Amount = Replace(FormatCurrency(Amount, 2, -1, 0, -1), ",", "")
	FCurrency = Amount

   ElseIf CurType = 3 Then
	Amount = Replace(FormatCurrency(Amount, 2, -1, 0, -1), "$", "")
	FCurrency = Amount

   ElseIf CurType = 4 Then
	Amount = FormatCurrency(Amount, 2, -1, 0, -1)
	FCurrency = Amount

   End If

End Function


Function Get_Att_Desc_By_Group(Group_ID, Att_ID)

	Dim SQLAtt, RSAtt
	SQLAtt = "Get_Attribute_Values @GroupID='" & Group_ID & "', @att_ID='" & Att_ID & "'"
	Set RSAtt = Conn.Execute(SQLAtt)

	If Not RSAtt.EOF Then
		Get_Att_Desc_By_Group = RSAtt("Att_Desc")
	Else
		Get_Att_Desc_By_Group = ""
	End If

End Function


Function Get_Att_Var_By_Group(Group_ID, Att_ID)

	Dim SQLAtt, RSAtt
	SQLAtt = "Get_Attribute_Values @GroupID='" & Group_ID & "', @att_ID='" & Att_ID & "'"
	Set RSAtt = Conn.Execute(SQLAtt)

	If Not RSAtt.EOF Then
		Get_Att_Var_By_Group = RSAtt("Variable")
	Else
		Get_Att_Var_By_Group = ""
	End If

End Function


%>