<%= javascript_include_tag "ssamr_institutions" %>
<%= javascript_include_tag "ssamr_registration" %>

<h2><%=l(:label_register)%> <%=link_to l(:label_login_with_open_id_option), signin_url if Setting.openid? %></h2>

<% form_tag({:action => 'register'}, :class => "tabular") do %>
<%= error_messages_for 'user' %>

<div class="box">
<!--[form:user]-->
<% if @user.auth_source_id.nil? %>
<p><label for="user_login"><%=l(:field_login)%> <span class="required">*</span></label>
<%= text_field 'user', 'login', :size => 25 %></p>

<p><label for="password"><%=l(:field_password)%> <span class="required">*</span></label>
<%= password_field_tag 'password', nil, :size => 25  %><br />
<em><%= l(:text_caracters_minimum, :count => Setting.password_min_length) %></em></p>

<p><label for="password_confirmation"><%=l(:field_password_confirmation)%> <span class="required">*</span></label>
<%= password_field_tag 'password_confirmation', nil, :size => 25  %></p>
<% end %>

<p><label for="user_firstname"><%=l(:field_firstname)%> <span class="required">*</span></label>
<%= text_field 'user', 'firstname'  %></p>

<p><label for="user_lastname"><%=l(:field_lastname)%> <span class="required">*</span></label>
<%= text_field 'user', 'lastname'  %></p>

<p><label for="user_mail"><%=l(:field_mail)%> <span class="required">*</span></label>
<%= text_field 'user', 'mail'  %></p>

<!-- We only support English in this site 
<p><label for="user_language"><%=l(:field_language)%></label>
<%= select("user", "language", lang_options_for_select) %></p>
-->

<h3><%=l(:label_ssamr_details)%></h3>
	
		<% fields_for :ssamr_user_details, :builder => TabularFormBuilder, :lang => current_language do |ssamr_user_detail| %>	
			<p>
                          <%= ssamr_user_detail.text_area :description, :rows => 3, :cols => 40, :required => true, :class => 'wiki-edit' %>                          
                          <em> <%=l(:text_user_ssamr_description_info)%></em>
                        </p>

                        <p><label for="institution"><%=l("field_ssamr_user_detail.institution")%> <span class="required">*</span></label>
							<%= ssamr_user_detail.radio_button :institution_type, true %>
                          	<%= ssamr_user_detail.collection_select(:institution_id, Institution.find(:all, :order => "institutions.order"), :id, :name,  {:selected => @selected_institution_id, :prompt => true}).gsub('&amp;', '&')  %>
						</p>

                        <p>
                          <%= ssamr_user_detail.radio_button :institution_type, false %> Other:
                          <%= ssamr_user_detail.text_field(:other_institution) %>
                        </p>
                <% end %>
          
<% if Setting.openid? %>
<p><label for="user_identity_url"><%=l(:field_identity_url)%></label>
<%= text_field 'user', 'identity_url'  %></p>
<% end %>

<% @user.custom_field_values.select {|v| v.editable? || v.required?}.each do |value| %>
	<p><%= custom_field_tag_with_label :user, value %></p>
<% end %>
<!--[eoform:user]-->
</div>

<%= check_box :user, :terms_and_conditions %> <%= l(:accept_terms_and_conditions) %> <%= link_to("Terms and Conditions", "https://code.soundsoftware.ac.uk/projects/soundsoftware-site/wiki/TandCs", {:target => "_blank"}) %>.
<br />
<br />

<%= submit_tag l(:button_submit) %>
<% end %>
