Residential = {
    init: function() {
      if(jQuery().slider) {
          $('#slider').slider({ range: true, min:1500, max:7500, values: [3000, 6000], change: function(e, ui) { Residential.updateFromSlider(); } });
      }

      if($('#form_property_search').length === 1){
          Residential.disableOptions();
      }
    },

    updateFromSlider: function(){
        var values = $('#slider').slider('values');
        $("#id_price_min_amt").val(values[0]);
        $("#id_price_max_amt").val(values[1]);

        try{
            // die
        } catch(e){}
    },

    disableOptions: function(){
        var $properties = $("#id_properties"),
            $checkboxes = $(".options :checkbox");

        $properties.change(function(){
            if ($properties.val() === '0') {
                $checkboxes.removeAttr('disabled');
            }
            else {
                $checkboxes.attr('disabled', 'true');
            }
        });

        $checkboxes.click(function(){
            if($checkboxes.is(':checked')){
                $properties.attr('disabled', 'true');
            }
            else {
                $properties.removeAttr('disabled');
            }
        });
    }
};

// window load
$().ready(function(){
    Residential.init();
});

