<div class="container-fluid">
	<%= semantic_form_for @lva do |f| %>
		<div class="row-fluid">
			<%= f.inputs do %>
				<div class="span12">
					<%= f.input :typ, :as=>:select,  :include_blank=>false, :collection=>Lva::ERLAUBTE_TYPEN , :input_html=>{:style => "width:7em" } , :wrapper_html=> {style: "float: left"}%>
					<%= f.input :name , :input_html=>{:style => "width:14em" }%>
				</div>
		</div>
		<div class="row-fluid">
			<div class="span12"%>

					<%= f.input :lvanr, :input_html=>{:style => "width:9em" } , :wrapper_html=> {style: "float: left"}%>
					<%= f.input :ects , :input_html=>{:style => "width:5em" } , :wrapper_html=> {style: "float: left"}%>
					<%= f.input :stunden, :input_html=>{:style => "width:5em" } , :wrapper_html=> {style: "float: left"} %>

			</div>
		</div>
	  <div class="row-fluid">
			<%= f.input :forumlink, :wrapper_html=>{:class=>'span12'}%>
		</div>
		<div class="row-fluid">
			<div class="span9">
				
				<%= f.input :desc , :as=>:tinymce_text %>
				<%= f.input :pruefungsinformation %>
				<%= f.input :lernaufwand %>
			</div>
		
					
			<div class="span3">
				<h1> BILD </h1>
				<input id="lva" class="autocomplete-checkbox" data-checkboxdiv="lva_modul_input" data-checkboxname="lva[modul_ids][]" data-collection="<%= (Modul.all.map{|m| "{\"value\": \""+m.id.to_s + "\", \"label\": " + "\"" +escape_javascript( m.name.gsub("\"", "").gsub(";",",")).strip +  "\"}"}.join("; "))%>"> </input>
				<%= f.input :modul, :as => :check_boxes, :member_label=>:name, :collection => @lva.modul %>
				<% f.input :modul, :as=>:check_boxes%>	  
				<% f.input :semester, :as=>:check_boxes, :collection=>@semester%>
						
				<input id="lva" class="autocomplete-checkbox" data-checkboxdiv="lva_semester_input" data-checkboxname="lva[semester_ids][]" data-collection="<%= (Semester.all.map{|m| "{\"value\": \""+m.id.to_s + "\", \"label\": " + "\"" +escape_javascript( m.name.gsub("\"", "").gsub(";",",")).strip +  "\"}"}.join("; "))%>"> </input>
				<%= f.input :semester, :as => :check_boxes, :member_label=>:name, :collection => @lva.semester %>
						

				<input id="lva" class="autocomplete-checkbox" data-checkboxdiv="lva_lecturers_input" data-checkboxname="lva[lecturers_ids][]" data-collection="<%= (Lecturer.all.map{|m| "{\"value\": \""+m.id.to_s + "\", \"label\": " + "\"" +escape_javascript( m.name.gsub("\"", "").gsub(";",",")).strip +  "\"}"}.join("; "))%>"> </input>
				<%= f.input :lecturers, :as => :check_boxes, :member_label=>:name, :collection => @lva.lecturers %>
				
						
						
				<% f.input :lecturers, :as=>:check_boxes%>
			</div>
		</div>
			<% end %>
			<%= f.actions do %>
				<%= f.action :submit, :as => :input %>
			<% end %>
	<% end %>

</div>
<script>
$(function(){
	$( ".autocomplete-checkbox" ).autocomplete({
    minLength: 0,
    source: [],
    focus: function( event, ui ) {
      $( this ).val( ui.item.label );
      return false;
    },
    select: function( event, ui ) {
      $( this ).val( "" );
      $( "#"+$(this).data("checkboxdiv")).append($("<label>").append($("<div>").attr("class", "checkbox").append($("<input>").attr("type","checkbox").attr("value", ui.item.value).attr("checked","checked").attr("name",$(this).data("checkboxname"))).append(ui.item.label)));
      return false;
    }
  }).each(function() { // Goes through `.autocomplete` elements and sets source
    $(this).autocomplete("option", "source", $(this).data('collection').split(";").map(function(el){console.log(el);return JSON.parse(el)}));
  })
    .data( "ui-autocomplete" )._renderItem = function( ul, item ) {
      return $( "<li>" )
        .append( "<a>" + item.label +  "</a>" )
        .appendTo( ul );
    };
 	$("#tabs").tabs();
});
</script>


<%= tinymce %>



