$(document).ready (function ()
{

function toggle_row(this_id)
{
 if ($('#'+this_id).find('input').attr('checked') == false)
 {
  $('#'+this_id).removeClass ('active_row');
  
 $('#'+this_id).find('.item_sum > span').html('');

 $('#'+this_id).find('select').removeClass('active');

 }
 else
 {
 $('#'+this_id).find('.item_sum > span').html($('#'+row_id).find('select').val()+' руб.');

  $('#'+this_id).addClass ('active_row');
 $('#'+this_id).find('select').addClass('active');

 
 }

recount_price();

}
function recount_price ()
{
var final = 0;

      $("select.active").each(function (i) {
	  
	  
	 final = final + parseInt($(this).val());
	  
    });
	

$('#total_price').html(final);
	
}

recount_price();

$('#count_price').find('select').change(function ()
{


var row_id;
row_id = this.id;
row_id = row_id.replace('select','feature');

$('#'+row_id).find('input').attr('checked', true);
toggle_row (row_id);


$('#'+row_id).find('.item_sum > span').html($('#'+row_id).find('select').val()+' руб.');
$('#'+row_id).find('input').attr('checked', true);
$('#'+row_id).addClass('active_row');

recount_price();
});


$('#count_price').find('input').click(function ()
{
row_id = this.id.replace('input_checkbox', 'feature');

toggle_row (row_id);
});

});

