function collapse(switcher) {
  to_collapse = switcher.parent().children('.collapsable')
  switcher.toggleClass("collapsed");
  if (switcher.hasClass('collapsed')) {
    to_collapse.hide();
    to_collapse.find(':input').attr('disabled', 'disabled')
  }
  else {
    to_collapse.show();
    to_collapse.find(':input').removeAttr('disabled')
  }
}

function enable_inputs(switcher) {
  to_collapse = switcher.parent().children('.collapsable')
  to_collapse.find(':input').removeAttr('disabled')
}

function do_search()
{
   document.forms.search_form.onsubmit();
}

$j(document).ready(function() {
  $j('.plus-minus h4').click(function() {
    switcher = $j(this);
    collapse(switcher);
    return false;
  });


  $j('div.content :input[id!="selected_city"][type!="checkbox"]').change(do_search)
  $j('.checkboxes p.line span').click(do_search)
  $j('input#search_params_express').click(do_search)
  enable_inputs($j('.switcher').parent());
})

function resetSearchCriterea() {
 jQuery(".checkboxes p.line span input").each(function(){
   jQuery(this).parent().removeClass("onn");
   this.checked = false;
 })

 jQuery(".location select").each(function(){ this.value = -1 })
 $('search_form').onsubmit()
}