jQuery Ruby on Rails code optimization
It's a working Embedded Ruby + jQuery code.  


    <%= f.fields_for(:role) do |r_f| %>
    	<%= r_f.check_box :is_student, {
    	    onclick: "
    			if ( document.getElementById('student_properties').style.display == 'block' )
    		    	{
    				    document.getElementById('student_properties').style.display = 'none';
    				}
    			else
    				{
					    document.getElementById('student_properties').style.display = 'block';
   					}
 				return true;"
    		}, true, false%>
    	<%= r_f.label :is_student %>
	<% end %>
	<br>
	<br>
	<div id="student_properties" style="display:none;">
        Some text just to test.
    </div>

As amateur, I don't know how to optimize it.  
I want to:  
- place it in separate *.js or *.js.coffee file, in a named function. To call this function with "onclick".  
- make this function to be able to receive a div_id as parameter.  
- call getElementById only once.

Help me, please.

jQuery Ruby on Rails code optimization
===

It's a working Embedded Ruby + jQuery code.  


    <%= f.fields_for(:role) do |r_f| %>
    	<%= r_f.check_box :is_student, {
    	    onclick: "
    			if ( document.getElementById('student_properties').style.display == 'block' )
    		    	{
    				    document.getElementById('student_properties').style.display = 'none';
    				}
    			else
    				{
					    document.getElementById('student_properties').style.display = 'block';
   					}
 				return true;"
    		}, true, false%>
    	<%= r_f.label :is_student %>
	<% end %>
	<br>
	<br>
	<div id="student_properties" style="display:none;">
        Some text just to test.
    </div>

As amateur, I don't know how to optimize it.  
I want to:  
- place it in separate *.js or *.js.coffee file, in a named function. To call this function with "onclick".  
- make this function to be able to receive a div_id as parameter.  
- call getElementById only once.

Help me, please.
