<div id="UserRole_block" class="roles_block">
	<h2><%= t("admin.user_#{@attribute}") %></h2>
	<div class="info_input">
		<table border="0" cellspacing="0" cellpadding="0">
			<thead class="list_head">
				<tr>
					<td><%= t('admin.key') %></td>
					<% @site_valid_locales.each do |locale| %>
			      <td style="color:<%= colorize_in_use_locale(locale) %>"><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
			    <% end %>
				</tr>
			</thead>
			<tbody>
			<tr class="list_item">
			    <td><%= is_new ? (f.text_field :key, {:style => "width:150px"}) : @user_attribute_model.key %></td>
			    <% @site_valid_locales.each do |locale| %>
			      <td>
			        <%= text_field_tag "user_#{@attribute}_model[i18n_variable][#{locale}]", (@i18n_variable[locale] if @i18n_variable), :style => "width:150px" %>
			      </td>
			    <% end %>
			  </tr>
			</tbody>
		</table>
	</div>
</div>


<div id="attributes_block" class="roles_block">
	<h2>Attributes</h2>
	<div class="info_input">
		<table id='attributes' border="0" cellspacing="0" cellpadding="0">
			<thead class="list_head">
				<tr>
					<td><%= t('admin.key') %></td>
					<td><%= t('admin.multilingual') %></td>
					<% @site_valid_locales.each do |locale| %>
			      <td style="color:<%= colorize_in_use_locale(locale) %>"><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
			    <% end %>
					<td><%= t('admin.type')%></td>
					<td>&nbsp;</td>
				</tr>
			</thead>
			<tfoot>
				<tr>
					<td colspan="5"><a href="#" class="add"><%= t(:add) %></a></td>
				</tr>
			</tfoot>
			<tbody>
				<%= render :partial => 'admin/user_attribute_models/attribute_model', :collection => @user_attribute_model.attribute_models %>
			</tbody>
		</table>
	</div>
</div>

<% content_for :page_specific_javascript do %>
  <script type="text/javascript" charset="utf-8">
    $('#attributes_block a.delete').live('click', function(){
      $(this).parent().parent().parent().remove();
    });
    
    $('#attributes_block a.add').click(function(){
      $('#attributes').append("<%= escape_javascript(render(:partial => 'admin/user_attribute_models/attribute_model', :object => @user_attribute_model.attribute_models.build)) %>");
    });

    $('#attributes_block a.remove_existing_record').click(function(){
      $(this).next('.should_destroy').attr('value', 1);
      $(this).parent().parent().hide();
    });

    $('#attributes_block a.change_built_in').click(function(){
      $(this).parent().toggleClass('disable');
			var $am = $(this).next('.built_in_state')
			$am.attr('value', ($am.attr('value') == "false") ? "true" : "false");
    });
    
    $('.select_mulitlingual input').live('click', function(){
      $(this).next().attr('value', this.checked);
    });
    
    $('.select_type select').live('change', function(){
      if(this.value == 'select')
      {
        $(this).next().show();
      }
      else
      {
        $(this).next().hide();
      }
    });
    

  </script>
<% end -%>
