<%
'protocol = IIf(LCase(Request.ServerVariables("HTTPS")) = "1", "https", "http")
protocol = "https"
Dim timeZones
timeZones = Array( _
  Array("America/New_York", "Eastern (New York)"), _
  Array("America/Chicago", "Central (Chicago)"), _
  Array("America/Denver", "Mountain (Denver)"), _
  Array("America/Los_Angeles", "Pacific (Los Angeles)"), _
  Array("Europe/London", "London (UK)") _
)

Function RequestBinary()
    On Error Resume Next
    Dim stream, rawData

    If Request.TotalBytes = 0 Then
        RequestBinary = ""
        Exit Function
    End If

    Set stream = Server.CreateObject("ADODB.Stream")
    stream.Type = 1 ' adTypeBinary
    stream.Open
    stream.Write Request.BinaryRead(Request.TotalBytes)

    stream.Position = 0
    stream.Type = 2 ' adTypeText
    stream.Charset = "utf-8"
    rawData = stream.ReadText

    stream.Close
    Set stream = Nothing

    If Err.Number <> 0 Then
        rawData = ""
        Err.Clear
    End If

    On Error GoTo 0
    RequestBinary = rawData
End Function

Function ArrayContains(arr, val)
    Dim i
    ArrayContains = False
    If IsArray(arr) Then
        For i = LBound(arr) To UBound(arr)
            If arr(i) = val Then
                ArrayContains = True
                Exit Function
            End If
        Next
    End If
End Function

Function RenderPOBOArrayAsJson(pobo)
    Dim i, j, obj, propList, propName, json, propVal, line,poboArray
    if IsLinkedList(pobo) Then
       poboArray = pobo.TO_Array()
    End If  
    json = "["

    If IsEmpty(poboArray) Then
        RenderPOBOArrayAsJson = "[]"
        Exit Function
    End If

    For i = 0 To UBound(poboArray)
        Set obj = poboArray(i)
        propList = obj.Properties
        line = "{"

        For j = 0 To UBound(propList)
            propName = propList(j)
            ' Dynamically get value using Execute
            Execute "propVal = obj." & propName

            Select Case VarType(propVal)
                Case vbString
                    line = line & """" & propName & """:""" & JsonEscape(propVal) & """"
                Case vbBoolean
                    line = line & """" & propName & """:" & LCase(CStr(propVal))
                Case vbDate
                    line = line & """" & propName & """:""" & Replace(CStr(propVal), """", "") & """"
                Case vbNull
                    line = line & """" & propName & """:null"
                Case Else
                    line = line & """" & propName & """:" & CStr(propVal)
            End Select

            If j < UBound(propList) Then
                line = line & ","
            End If
        Next

        line = line & "}"
        If i < UBound(poboArray) Then line = line & ","
        json = json & line
    Next

    json = json & "]"
    RenderPOBOArrayAsJson = json
End Function

Function JsonEscape(str)
    str = Replace(str, "\", "\\")
    str = Replace(str, """", "\""")
    str = Replace(str, vbCrLf, "\n")
    str = Replace(str, vbLf, "\n")
    str = Replace(str, vbCr, "\n")
    str = Replace(str, Chr(9), "\t")
    JsonEscape = str
End Function
%>