<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fi" >
  <head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <meta http-equiv="Content-Style-Type" content="text/css" />
    <meta http-equiv="Content-Script-Type" content="text/javascript" />
    <link rel="icon" type="image/png" href="/favicon.png" />
    <%= stylesheet_link_tag    "application" %>
    <%= javascript_include_tag "application" %>
    <title>ENSL - User Finder</title>
  </head>
  <body>
    <div class="box big">
      <h3 class="center">
        Search for a user
      </h3>

      <%= form_tag do %>
        <%= hidden_field_tag "source", params[:source] %>

        <div style="float: left;">
          <p>
            <%= label_tag "username" %><br />
            <%= text_field_tag "username", params[:username], :size => 20 %>
          </p>
          <p>
            <%= label_tag "steamid" %><br />
            <%= text_field_tag "steamid", params[:steamid], :size => 20 %>
          </p>
        </div>
        <div style="float: left;">
          <p>
            <%= label_tag "firstname" %><br />
            <%= text_field_tag "firstname", params[:firstname], :size => 20 %>
          </p>
          <p>
            <%= label_tag "lastname" %><br />
            <%= text_field_tag "lastname", params[:lastname], :size => 20 %>
          </p>
          <p>
            <%= label_tag "irc" %><br />
            <%= text_field_tag "profile[irc]", params[:irc], :size => 20 %>
          </p>
        </div>
        <p style="clear: both; ">
          <%= submit_tag "Search" %>
        </p>
      <% end %>

      <p>Use % for asterisk.</p>

      <% if @results %>
        <h3 class="center">
          Results
        </h3>

        <table class="data">
          <tr>
            <th>Username</th>
            <th>SteamID</th>
            <th>Options</th>
          </tr>

          <% for user in @results %>
            <tr class="<%= cycle('even', 'odd') %>">
              <td><%= h user %></td>
              <td><%= h user.steamid %></td>
              <td>
                <%= link_to_function 'Select', "opener.document.getElementById($('source').value).value='#{(h user.username)}';" %>
              </td>
            </tr>
          <% end %>
        </table>
      <% end %>
    </div>
  </body>
</html>
