<%	
Dim Page 
Page = "1"

Dim Conn
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open Application("conn_string")

If (UCase(Request.ServerVariables("REQUEST_METHOD")) = "POST" And Request.Form("page") = "0") Then
	If Request.Form("Admin_Group_ID") <> "" Then
		Session("Admin_Group_ID") = Request.Form("Admin_Group_ID")
	End If
	
	If Session("Admin_Group_ID") = "" Then
		Session("Admin_Group_ID") = "0"
	End If
End If


Dim SQLRetrieve, RSRetrieve
Dim Att_ID, Att_Desc, Disp_Type, Properties, Default_Value, Input_Class
Dim Label_Left, Label_Right, Label_Left_Class, Label_Right_Class
Dim Input_Line, Value

Dim SQLName, RSName
SQLName = "get_entity_from_group @Group_ID='" & Session("Admin_Group_ID") & "'"
Set RSName=Conn.Execute(SQLName)

Dim SQLAtt, RSAtt
SQLAtt = "select Page_Name, apd.Att_ID As Att_ID, Disp_Type, Properties, Default_Value, Input_Class, Label_Left, Label_Right, Label_Left_Class, Label_Right_Class, Att_Desc "
SQLAtt = SQLAtt & "from att_page ap join att_page_detail apd on ap.page_id = apd.page_id join attribute_type at on at.att_id = apd.att_id where ap.page_id='" & Page & "' order by disp_order,att_id asc"
Set RSAtt = Conn.Execute(SQLAtt)
RSAtt.MoveFirst

If (UCase(Request.ServerVariables("REQUEST_METHOD")) = "POST" And Request.Form("page") = Page) Then

    If Not RSAtt.EOF Then
	Do Until RSAtt.EOF
	    Att_ID = RSAtt("Att_ID")
	    SQL = "Update_Attribute '" & Session("Admin_Group_ID") & "','" & Att_ID & "','" & Request.Form("" & Att_ID & "") & "','" & Page & "'"
'	    Conn.Execute(SQL)
Response.Write (SQL & "<br>")
	    RSAtt.MoveNext
  	Loop
    End If

    If Request.Form("cont") = "1" Then Response.Redirect "default.asp"
'    If Request.Form("cont") = "2" Then Response.Redirect "business-services-admin.asp"

End If

RSAtt.MoveFirst

%>


<html>
<STYLE>
BODY {SCROLLBAR-FACE-COLOR: #5e5ebe; SCROLLBAR-HIGHLIGHT-COLOR: #5e5ebe; SCROLLBAR-SHADOW-COLOR: #5e5ebe; SCROLLBAR-3DLIGHT-COLOR: #5e5ebe; SCROLLBAR-ARROW-COLOR:  #6666CC; SCROLLBAR-TRACK-COLOR: #E3E3E3; SCROLLBAR-DARKSHADOW-COLOR: #666666; }
</STYLE>
<head>
<title><%=RSAtt("Page_Name")%></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="../Style-sheets/standard-input-form.css" type="text/css">
<script language="JavaScript">
<!--

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function Sub_Form(cont) {
  form1.cont.value=cont
  form1.submit();
}

//-->
</script>
<link rel="stylesheet" href="/Style-sheets/headline.css" type="text/css">
<link rel="stylesheet" href="/Style-sheets/galley-text-indent.css" type="text/css">
</head>

<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="MM_preloadImages('images/icon-return-to-main-2.gif','images/icon-submit-changes-2.gif','images/icon-continue-wizard-2.gif')">
<form name="form1" method="post" action="" id=form1>
<INPUT type="hidden" id=page name=page value="<%=Page%>">
<INPUT type="hidden" id=cont name=cont value="">
  <table width="525" border="0" cellspacing="0" cellpadding="2" align="center">
    <tr> 
      <td width="338">&nbsp;</td>
      <td align="right" width="187">&nbsp;</td>
    </tr>
    <tr> 
      <td width="338" bgcolor="#5e5ebe
" class="headline-ffffff" 

align="center"><%=RSAtt("Page_Name")%></td>

      <td bgcolor="#5e5ebe
" align="right" width="187"><a href="default.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image1','','images/icon-return-to-main-2.gif',1)"><img src="images/icon-return-to-main.gif" width="75" height="17" usemap="#returntomain" border="0" name="Image1"></a></td>
    </tr>
    <% If Not RSName.EOF Then %>
    <tr> 
      <td class="galley-text-indent" colspan="2"><%=RSName("Name")%> - <%=RSName("City")%>, 
        <%=RSName("State")%>&nbsp; <%=RSName("ZIP")%></td>
    </tr>
    <% Else %>
    <tr> 
      <td class="galley-text-indent-alert" colspan="2">No Entity Selected! Go 
        back and choose a location to edit from the dropdown menu.</td>
    </tr>
    <% End If %>
    <% RSName.Close %>
  </table>

<!-- Start Attribute Display Code -->

  <table width="500" border="0" cellspacing="0" cellpadding="0" align="center">

<% 'Define html constraints %>

    <tr> 
      <td width="284" height="5">&nbsp;</td>
      <td width="203" height="5">&nbsp;</td>
    </tr>

<% 
If Not RSAtt.EOF Then
   Do Until RSAtt.EOF
	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")
	Input_Class = RSAtt("Input_Class")
	
	Label_Left = RSAtt("Label_Left")
	Label_Right = RSAtt("Label_Right")
	Label_Left_Class = RSAtt("Label_Left_Class")
	Label_Right_Class = RSAtt("Label_Right_Class")
	

	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)

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

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

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

	RSAtt.MoveNext
   Loop
End If
%>
    <tr> 
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>

  </table>

<!-- End Attribute Display Code -->

  <table width="525" border="0" cellspacing="0" cellpadding="0" align="center">
    <tr bgcolor="#5e5ebe
"> 
      <td align="right" width="326"><a href="javascript:Sub_Form('1');" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('submitchanges','','images/icon-submit-changes-2.gif',1)"><img src="images/icon-submit-changes.gif" width="200" height="15" name="submitchanges" border="0"></a></td>
      <td width="336"><a href="javascript:Sub_Form('2');" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image2','','images/icon-continue-wizard-2.gif',1)"><img src="images/icon-continue-wizard.gif" width="150" height="15" usemap="#continue" border="0" name="Image2"></a></td>
    </tr>
    <tr> 
      <td width="326"></td>
      <td width="336">&nbsp;
    </tr>
  </table>
</form>
</body>
</html>
