<% @page_title = "Account: Login" %>
<% @show_tabs = false %>

<% if session[:user_id] %>

<%= form_tag :action=> "logout" %>
<% table :caption => "Logged In", :id => "login" do %>
  <tr><th colspan="2">&nbsp;</th></tr>
  <tr>
    <td>You are logged-in as <%= logged_in_user.name %></td>
  </tr>
  <tr>
    <td><input type="submit" name="logout" value="Logout"/></td>
  </tr>
<% end -%>
</form>

<% else %>

<h2>Welcome</h2>

<%= form_tag :action => "authenticate" %>
  <div class="login centered">
    <%= labelled_text_field_tag "email", "Email", @email %><br/>
    <%= label_tag "user_password", "Password" %>
    <%= password_field_tag "user_password", @user_password %>
    <div class="page_buttons last">
      <div style="float: left;"><%= link_to "Forgot your password?", { :action => "forgot" }, { :class => "obvious forgot" } %></div>
      <div class="last right" style=""><input type="submit" name="login" value="Login" class="right" id="login_button" /></div>
    </div>
  </div>
</form>
  
<% end %>

<% focus('email') %>
<% @page_title = "Account: Login" %>
<% @show_tabs = false %>

<% if is_logged_in? %>

<%= form_tag :action=> "logout" %>
<% table :caption => "Logged In", :id => "login" do %>
  <tr><th colspan="2">&nbsp;</th></tr>
  <tr>
    <td>You are logged-in as <%= logged_in_user.name %></td>
  </tr>
  <tr>
    <td><input type="submit" name="logout" value="Logout"/></td>
  </tr>
<% end -%>
</form>

<% else %>

<h2>Welcome</h2>

<%= form_tag :action => "authenticate" %>
  <div class="login centered">
    <%= labelled_text_field_tag "email", "Email", @email %><br/>
    <%= label_tag "user_password", "Password" %>
    <%= password_field_tag "user_password", @user_password %>
    <div class="page_buttons last">
      <div style="float: left;"><%= link_to "Forgot your password?", { :action => "forgot" }, { :class => "obvious forgot" } %></div>
      <div class="last right" style=""><input type="submit" name="login" value="Login" class="right" id="login_button" /></div>
    </div>
  </div>
</form>
  
<% end %>

<% focus('email') %>
Use is_logged_in? rather than checkig session directly
Use is_logged_in? rather than checkig session directly
