(function($) { 
                                  
    $.fn.AdvancedSearchBox = function(opts) { 
        
        var defaults = {
            id: '#advancedSearchBox'
        },
        options = $.extend(true, {}, defaults, opts),
        timer = 500;

        $('#advanced-search-link_show').click(function(){
            $('#advancedSearchBox').show(timer);
            $('#advanced-search-link_show').hide();
            $('#advancedSearchExpand').show();
            return false; 
        });
        $('#advanced-search-link_hide').click(function(){
            $('#advancedSearchBox').hide(timer);
            $('#advanced-search-link_show').show();
            $('#advancedSearchExpand').hide();
            return false; 
        });
        $('#modify').click(function(){
            $('#advancedSearchBox').show(timer);
            $('#amenitiesTable tr:last').remove();
            $('#advanced-search-link_show').hide();
            $('#advancedSearchExpand').show();
            return false; 
        });
        
        $('#clearAll').click(function() {
            var fid = '#' + options.formID,
                type = '', 
                tag = '',
                f = $(fid);
            
            f.find(':input').each(function() { 
                    var $this = $(this),
                        type = $this.attr('type'),
                        tag = $this.get(0).tagName.toLowerCase(); 

                if(type == 'text' || type == 'password' || tag == 'textarea') { 
                    if($this.is("input[id^='ares-datepicker-']")) {
                        $this.val('mm/dd/yyyy');
                    } else {
                        $this.val('');
                    }
                } else if(type == 'checkbox' || type == 'radio') {
                    $this.attr('checked', false);
                } else if(tag == 'select') {
                    $this.get(0).selectedIndex = 0;
                } 
            });
            
            return false;
        });
  };

})(jQuery);



