function redirectToUrl(value){
    if (value && value != 0)
        window.location = value;
}

function set_search_price(price_min, price_max){
    $('#id_price_min').val(price_min)
    $('#id_price_max').val(price_max)
}

var SearchForm = {
    change_realestate: function() {
    	disabled_obj = SearchForm.area_box;
    	enable_obj = SearchForm.room_count_box;
    	realestate_type = $(SearchForm.realestate_type).val();
        if (realestate_type == 3 || realestate_type == 5) {
            disabled_obj = SearchForm.room_count_box;
            enable_obj = SearchForm.area_box;
    	}
    	$(enable_obj).css('display','block');
    	$(enable_obj).find('input').removeAttr('disabled');	
        $(enable_obj).find('select').removeAttr('disabled');
    	$(disabled_obj).css('display','none');	
    	$(disabled_obj).find('input').attr('disabled','disabled');
    	$(disabled_obj).find('select').attr('disabled','disabled');
    },
    
    change_market_type: function() {
        market_type = $(SearchForm.market_type).val();
        if (market_type == 0) {
            $(SearchForm.market_type).attr('name','secondary_market');
        }
        if (market_type == 1) {
            $(SearchForm.market_type).attr('name','primary_market');
        }
    },
    
    init: function() {
    	this.realestate_type = $('#id_realestate_type');
    	$(this.realestate_type).change(SearchForm.change_realestate);
    	this.room_count_box = $('#room_count_search_box');
    	this.area_box = $('#area_search_box');
    	this.change_realestate();
    	
    	this.market_type = $('#id_market_type');
    	$(this.market_type).change(SearchForm.change_market_type);
    	this.change_market_type();
    }
}


