<% 
' Dynamic Display Code

'Define Maximum Number of Dropdowns allowed on a page.
Dim Arr_Dropdown(10)

' Some Defining Stuff
Cnt_Dropdown = 1

RSAtt.MoveFirst
If Not RSAtt.EOF Then
   Do Until RSAtt.EOF
	On Error Resume Next
	ObjectName = RSAtt("Object_Name")
	Att_ID = RSAtt("Att_ID")
	Att_Desc = RSAtt("Att_Desc")
	Disp_Type = LCase(Trim(RSAtt("Disp_Type")))
	Properties = Trim(RSAtt("Properties"))
	Default_Value = RSAtt("Default_Value")

	TR_Class = RSAtt("TR_Class")

	Input_Class = RSAtt("Input_Class")
	Input_TD_Class = RSAtt("Input_TD_ClasS")

	Att_Desc_Class = RSAtt("Att_Desc_Class")
	Hide_Att_Desc = RSAtt("Hide_Att_Desc")

	Label_Left = RSAtt("Label_Left")
	Label_Right = RSAtt("Label_Right")
	Label_Left_Class = RSAtt("Label_Left_Class")
	Label_Right_Class = RSAtt("Label_Right_Class")
	On Error Goto 0

	SQLRetrieve = "Select * from Att_Group_Map Where [Group_ID] = '" & Session("Admin_Group_ID") & "' And [Att_ID]='" & Att_ID & "' And [Att_Page] = '" & Page & "'"
	Set RSRetrieve = Conn.Execute(SQLRetrieve)

	Value = ""

	If Not RSRetrieve.EOF Then
		Value = RSRetrieve("Variable")
	End If


If Disp_Type = "checkbox" Then
	   If Value = Default_Value Then
		Input_Line = "<!--" & Value & " - " & Default_Value & "--><input class=""" & Input_Class & """ type=""checkbox"" name=""" & Att_ID & """ value=""" & Default_Value & """ " & Properties & " checked>"
	   Else
		Input_Line = "<!--" & Value & " - " & Default_Value & "--><input class=""" & Input_Class & """ type=""checkbox"" name=""" & Att_ID & """ value=""" & Default_Value & """ " & Properties & ">"
	   End If

	   If Hide_Att_Desc = True Then
		Att_Desc = ""
	   End If

		' Begin Rendering the HTML
		    Response.Write "<tr class=""" & TR_Class & """>" & Chr(13)
		    Response.Write "<td class=""" & Att_Desc_Class & """>" & Att_Desc & "&nbsp;</td>" & Chr(13)
		    Response.Write "<td class=""" & Label_Left_Class & """>" & Label_Left & "&nbsp;</td>" & Chr(13)
		    Response.Write "<td class=""" & Input_TD_Class & """>" & Input_Line & "&nbsp;</td>" & Chr(13)
		    Response.Write "<td class=""" & Label_Right_Class & """>" & Label_Right & "&nbsp;</td>" & Chr(13)
		    Response.Write "</tr>" & Chr(13)
		' End Rendering the HTML

ElseIf Disp_Type = "radio" Then

	   If Value = Default_Value Then
		Input_Line = "<!--" & Value & " - " & Default_Value & "--><input class=""" & Input_Class & """ type=""radio"" name=""" & ObjectName & """ value=""" & Att_ID & """ " & Properties & " checked>"
	   Else
		Input_Line = "<!--" & Value & " - " & Default_Value & "--><input class=""" & Input_Class & """ type=""radio"" name=""" & ObjectName & """ value=""" & Att_ID & """ " & Properties & ">"
	   End If

	   If Hide_Att_Desc = True Then
		Att_Desc = ""
	   End If

		' Begin Rendering the HTML
		    Response.Write "<tr class=""" & TR_Class & """>" & Chr(13)
		    Response.Write "<td class=""" & Att_Desc_Class & """>" & Att_Desc & "&nbsp;</td>" & Chr(13)
		    Response.Write "<td class=""" & Label_Left_Class & """>" & Label_Left & "&nbsp;</td>" & Chr(13)
		    Response.Write "<td class=""" & Input_TD_Class & """>" & Input_Line & "&nbsp;</td>" & Chr(13)
		    Response.Write "<td class=""" & Label_Right_Class & """>" & Label_Right & "&nbsp;</td>" & Chr(13)
		    Response.Write "</tr>" & Chr(13)
		' End Rendering the HTML
ElseIf Disp_Type = "dropdown" Then
	
	  DD_Continue = True

	  For I = 1 to UBound(Arr_Dropdown)
		If Arr_Dropdown(i) = Att_ID Then
		   DD_Continue = False
                End If
          Next

          If DD_Continue = True Then
 	    Dropdown_SQL = "Select * from Att_Page_Detail Where [Att_ID]='" & Att_ID & "' And [Page_ID] = '" & Page & "' And [Disp_Type]='dropdown' Order By Disp_Order, Att_ID"
	    Set Dropdown = Conn.Execute(Dropdown_SQL)
	    Dropdown.MoveFirst

	    If Not Dropdown.EOF Then
	      First_Run = 1
  	      Do Until Dropdown.EOF

		Disp_Type = LCase(Trim(Dropdown("Disp_Type")))
		Properties = Trim(Dropdown("Properties"))
		Default_Value = Dropdown("Default_Value")
	
		TR_Class = Dropdown("TR_Class")
	
		Input_Class = Dropdown("Input_Class")
		Input_TD_Class = Dropdown("Input_TD_ClasS")
	
		Att_Desc_Class = Dropdown("Att_Desc_Class")
		Hide_Att_Desc = Dropdown("Hide_Att_Desc")
	
		Label_Left = Dropdown("Label_Left")
		Label_Right = Dropdown("Label_Right")
		Label_Left_Class = Dropdown("Label_Left_Class")
		Label_Right_Class = Dropdown("Label_Right_Class")

		If First_Run = 1 Then
		   Input_Line = "<select class=""" & Input_Class & """ name=""" & Att_ID & """ " & Properties & ">"
		   First_TR_Class = TR_Class
		   First_Input_TD_Class = Input_TD_Class
		   First_Att_Desc_Class = Att_Desc_Class
		   First_Label_Left_Class = Label_Left_Class
		   First_Label_Left = Label_Left
		   First_Label_Right_Class = Label_Right_Class
		   First_Label_Right = Label_Right
		   First_Run = 0
		End If
		
		If Value = Default_Value Then
		   Input_Line = Input_Line & "<option value=""" & Default_Value & """ " & Properties & " selected>" & Default_Value & "</option>"
		Else
		   Input_Line = Input_Line & "<option value=""" & Default_Value & """ " & Properties & ">" & Default_Value & "</option>"
		End If

		If Hide_Att_Desc = True Then
		   Att_Desc = ""
		End If

	        Dropdown.MoveNext

	     Loop
	    Cnt_Dropdown = Cnt_Dropdown + 1
           Arr_Dropdown(Cnt_Dropdown) = Att_ID
	  End If
	 Set Dropdown = Nothing
  	Input_Line = Input_Line & "</select>"

	' Begin Rendering the HTML
	    Response.Write "<tr class=""" & First_TR_Class & """>" & Chr(13)
	    Response.Write "<td class=""" & First_Att_Desc_Class & """>" & Att_Desc & "&nbsp;</td>" & Chr(13)
	    Response.Write "<td class=""" & First_Label_Left_Class & """>" & First_Label_Left & "&nbsp;</td>" & Chr(13)
	    Response.Write "<td class=""" & First_Input_TD_Class & """>" & Input_Line & "&nbsp;</td>" & Chr(13)
	    Response.Write "<td class=""" & First_Label_Right_Class & """>" & First_Label_Right & "&nbsp;</td>" & Chr(13)
	    Response.Write "</tr>" & Chr(13)
	' End Rendering the HTML

         End If

ElseIf Disp_Type = "text" Then

		If Value = "" Then
			Input_Line = "<input class=""" & Input_Class & """ type=""text"" name=""" & Att_ID & """ value=""" & Default_Value & """ " & Properties & ">"
		Else
			Input_Line = "<input class=""" & Input_Class & """ type=""text"" name=""" & Att_ID & """ value=""" & Value & """ " & Properties & ">"
		End If

	   	If Hide_Att_Desc = True Then
		   Att_Desc = ""
		End If

		' Begin Rendering the HTML
		    Response.Write "<tr class=""" & TR_Class & """>" & Chr(13)
		    Response.Write "<td class=""" & Att_Desc_Class & """>" & Att_Desc & "&nbsp;</td>" & Chr(13)
		    Response.Write "<td class=""" & Label_Left_Class & """>" & Label_Left & "&nbsp;</td>" & Chr(13)
		    Response.Write "<td class=""" & Input_TD_Class & """>" & Input_Line & "&nbsp;</td>" & Chr(13)
		    Response.Write "<td class=""" & Label_Right_Class & """>" & Label_Right & "&nbsp;</td>" & Chr(13)
		    Response.Write "</tr>" & Chr(13)
		' End Rendering the HTML

ElseIf Disp_Type = "break" Then
		Response.Write "    <tr>" & Chr(13)
		Response.Write "      <td>&nbsp;</td>" & Chr(13)
		Response.Write "      <td>&nbsp;</td>" & Chr(13)
		Response.Write "      <td>&nbsp;</td>" & Chr(13)
		Response.Write "      <td>&nbsp;</td>" & Chr(13)
		Response.Write "    </tr>" & Chr(13)

ElseIf Disp_Type = "label" Then

		' Begin Rendering the HTML
		    Response.Write "<tr class=""" & TR_Class & """>" & Chr(13)
		    Response.Write "<td colspan=""4""><table border=""0"" cellspacing=""0"" cellpadding=""0"" width=""100%"">"
		    Response.Write "<td class=""" & Label_Left_Class & """> &nbsp; " & Label_Left & "&nbsp;</td>" & Chr(13)
		    Response.Write "<td class=""" & Label_Right_Class & """>" & Label_Right & "&nbsp;</td>" & Chr(13)
		    Response.Write "</tr></table>" & Chr(13)
		    Response.Write "</tr>" & Chr(13)
		' End Rendering the HTML

ElseIf Disp_Type = "textarea" Then

		Response.Write "<!--" & Value & " - " & Default_Value & "-->"

		If CStr(Value) <> "" Then
			Input_Line = "<textarea class=""" & Input_Class & """ name=""" & Att_ID & """ " & Properties & ">" & Value & "</textarea>"
		Else
			Input_Line = "<textarea class=""" & Input_Class & """ name=""" & Att_ID & """ " & Properties & ">" & Default_Value & "</textarea>"
		End If

	   	If Hide_Att_Desc = True Then
		   Att_Desc = ""
		End If

		' Begin Rendering the HTML
		    Response.Write "<tr class=""" & TR_Class & """>" & Chr(13)
		    Response.Write "<td colspan=""4"" class=""" & Att_Desc_Class & """> &nbsp; " & Att_Desc & "&nbsp;</td></tr>" & Chr(13)
		    Response.Write "<tr>" & Chr(13)
		    Response.Write "<td colspan=""4""><table border=""0"" cellspacing=""0"" cellpadding=""0"" width=""100%""><tr>"
		    Response.Write "<td class=""" & Label_Left_Class & """>" & Label_Left & "&nbsp;</td>" & Chr(13)
		    Response.Write "<td class=""" & Input_TD_Class & """>" & Input_Line & "&nbsp;</td>" & Chr(13)
		    Response.Write "<td class=""" & Label_Right_Class & """>" & Label_Right & "&nbsp;</td>" & Chr(13)
		    Response.Write "</tr></table>" & Chr(13)
		    Response.Write "</tr>" & Chr(13)
		' End Rendering the HTML

End If

	RSAtt.MoveNext
   Loop
End If
%>
