<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Step5.ascx.cs" Inherits="bitrix_install_Step5" %>
<%@ Import Namespace="Bitrix.Installer" %>
<script type="text/javascript">
function UpdateAdminAccount()
{
	var cb1 = document.getElementById("<%= UserExists.ClientID %>");
	var cb2 = document.getElementById("<%= DbExists.ClientID %>");
	var hidden = cb1.checked && cb2.checked;
	ToggleAdminAccount(!hidden);
}

function ToggleAdminAccount(visible)
{
	var lines = ["line1", "line2", "line3"];
	for(var i = 0; i < lines.length; i++)
		document.getElementById(lines[i]).style.display = visible ? "" : "none";
}
</script>
<font class="title"><%= BXInstaller.GetMessage(this, "Head") %></font>
<p>
    <table width="100%" cellspacing="0" cellpadding="0" border="0">
        <tbody>
            <tr>
                <td width="100%" bgcolor="#d5e7f3">
                    <img width="1" height="1" border="0" src="images/1.gif" /></td>
            </tr>
        </tbody>
    </table>
</p>
<p>
<%@ Register Src="Summary.ascx" TagName="Summary" TagPrefix="bx" %>
<bx:Summary runat="Server" ID="Errors" />
</p>
<table width="100%" cellspacing="1" cellpadding="2" border="0">
    <tbody>
        <tr>
            <td valign="center" nowrap="" align="center" class="tablehead4" colspan="2">
                <font class="tableheadtext"><b><%= BXInstaller.GetMessage(this, "TableHead") %></b></font>
            </td>
        </tr>
        <tr>
            <td width="40%" valign="top" nowrap="" align="right" class="tablebody1">
                <font class="tablefieldtext"><span class="required">*</span><%= BXInstaller.GetMessage(this, "Server") %>:</font>
            </td>
            <td width="60%" valign="top" class="tablebody3">
                <font class="tablebodytext">
                    <% valServer.ErrorMessage = BXInstaller.GetMessage(this, "Error.ServerRequired"); %>
                    <asp:TextBox ID="txtServer" runat="server" Columns="30">localhost\BITRIX</asp:TextBox><asp:RequiredFieldValidator ID="valServer" runat="server" ControlToValidate="txtServer"
                        Display="Dynamic">*</asp:RequiredFieldValidator><br />
                    <small><%= BXInstaller.GetMessage(this, "Server.Hint") %><br />
                    </small></font>
            </td>
        </tr>
        <tr>
            <td valign="top" align="right" class="tablebody1">
                <font class="tablefieldtext"><%= BXInstaller.GetMessage(this, "DBUser") %>:</font>
            </td>
            <td valign="top" class="tablebody3">
                <font class="tablebodytext">
					<% UserExists.Text = BXInstaller.GetMessage(this, "RadioButtonText.Exists"); %>
					<% RadioButton2.Text = BXInstaller.GetMessage(this, "RadioButtonText.NewUser"); %>
                    <asp:RadioButton ID="UserExists" runat="server" Checked="True" GroupName="DbUser" onclick="UpdateAdminAccount();" />
                    <br />
                    <asp:RadioButton ID="RadioButton2" runat="server" GroupName="DbUser" onclick="UpdateAdminAccount();" /></font></td>
        </tr>
        <tr>
            <td valign="top" nowrap="" align="right" class="tablebody1">
                <font class="tablefieldtext"><span class="required">*</span><%= BXInstaller.GetMessage(this, "Login") %>:</font>
            </td>
            <td valign="top" class="tablebody3">
                <font class="tablebodytext">
					<% valUserLogin.ErrorMessage = BXInstaller.GetMessage(this, "Error.LoginRequired"); %>
                    <asp:TextBox ID="txtUserLogin" runat="server" Columns="30"></asp:TextBox><asp:RequiredFieldValidator ID="valUserLogin" runat="server" ControlToValidate="txtUserLogin"
                        Display="Dynamic">*</asp:RequiredFieldValidator><br />
                    <small><%= BXInstaller.GetMessage(this, "Login.Hint") %><br />
                    </small></font>
            </td>
        </tr>
        <tr>
            <td valign="top" nowrap="" align="right" class="tablebody1">
                <font class="tablefieldtext"><span class="required">*</span><%= BXInstaller.GetMessage(this, "Password") %>:</font>
            </td>
            <td valign="top" class="tablebody3">
                <font class="tablebodytext">
					<% RequiredFieldValidator1.ErrorMessage = BXInstaller.GetMessage(this, "Error.PasswordRequired"); %>
                    <asp:TextBox ID="txtUserPass" runat="server" Columns="30" TextMode="Password"></asp:TextBox><asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtUserPass"
                        Display="Dynamic">*</asp:RequiredFieldValidator><br />
                    <small><%= BXInstaller.GetMessage(this, "Password.Hint") %><br />
                    </small></font>
            </td>
        </tr>
        <tr>
            <td valign="top" nowrap="" align="right" class="tablebody1">
                <font class="tablefieldtext"><%= BXInstaller.GetMessage(this, "Database") %>:</font>
            </td>
            <td valign="top" class="tablebody3">
                <font class="tablebodytext">
					<% DbExists.Text = BXInstaller.GetMessage(this, "RadioButtonText.Exists"); %>
					<% RadioButton3.Text = BXInstaller.GetMessage(this, "RadioButtonText.NewDB"); %>
                    <asp:RadioButton ID="DbExists" runat="server" Checked="True" GroupName="Db" onclick="UpdateAdminAccount();" /><br />
                    <asp:RadioButton ID="RadioButton3" runat="server" GroupName="Db" onclick="UpdateAdminAccount();" /></font></td>
        </tr>
        <tr>
            <td valign="top" nowrap="" align="right" class="tablebody1">
                <div id="db_exists">
                    <font class="tablefieldtext"><span class="required">*</span><%= BXInstaller.GetMessage(this, "DBName") %>:</font></div>
            </td>
            <td valign="top" class="tablebody3">
                <font class="tablebodytext">
				 <% valDbName.ErrorMessage = BXInstaller.GetMessage(this, "Error.DBNameRequired"); %>
                    <asp:TextBox ID="txtDbName" runat="server" Columns="30"></asp:TextBox><asp:RequiredFieldValidator ID="valDbName" runat="server" ControlToValidate="txtDbName"
                            Display="Dynamic">*</asp:RequiredFieldValidator><br />
                    <small><%= BXInstaller.GetMessage(this, "DBName.Hint") %><br />
                    </small></font>
            </td>
        </tr>
        <% bool hidden = UserExists.Checked && DbExists.Checked; %>
        <tr id="line1"<% if (hidden) { %> style="display: none"<% } %>>
            <td valign="center" nowrap="" align="center" class="tablehead5" colspan="2">
                <font class="tableheadtext"><b><%= BXInstaller.GetMessage(this, "TableHead.DBAdmin") %></b></font>
            </td>
        </tr>
        <tr id="line2"<% if (hidden) { %> style="display: none"<% } %>>
            <td valign="top" nowrap="" align="right" class="tablebody1">
                <font class="tablefieldtext"> <%= BXInstaller.GetMessage(this, "Login") %>:</font>
            </td>
            <td valign="top" class="tablebody3">
                <font class="tablebodytext">
                    <asp:TextBox ID="txtAdminLogin" runat="server" Columns="30"></asp:TextBox><br />
                    <small><%= BXInstaller.GetMessage(this, "DBAdminLogin.Hint") %><br />
                    </small></font>
            </td>
        </tr>
        <tr id="line3"<% if (hidden) { %> style="display: none"<% } %>>
            <td valign="top" nowrap="" align="right" class="tablebody1">
                <font class="tablefieldtext"><%= BXInstaller.GetMessage(this, "Password") %>:</font>
            </td>
            <td valign="top" class="tablebody3">
                <font class="tablebodytext">
                    <asp:TextBox ID="txtAdminPass" runat="server" Columns="30" TextMode="Password"></asp:TextBox><br />
                    <small><%= BXInstaller.GetMessage(this, "DBAdminPassword.Hint") %><br />
                    </small></font>
            </td>
        </tr>
    </tbody>
</table>
<br />
<div align="right">
<% btnNext.Text = BXInstaller.GetMessage(this, "ButtonText.Next"); %>
    <asp:Button runat="server" ID="btnNext" CssClass="button"
        OnClick="OnNext" />
</div>
