
var SearchSlider = Class.create();

SearchSlider.prototype = Object.extend(new Search(), 
{
    setDefaults: function(defaults) 
    {
      this.defaults = {
              min_price: 0,
            max_price: 1025000,
            bedrooms: 0,
            bathrooms: 0,
            garage: 0,
            min_year: 0,
            max_year: 2011,
            home_type: '',
            list_class: '',
            district: '',
            high_school: '',
            max_sq_feet: 10200,
            min_sq_feet: 0,
            acreage: 0,
            city_id: -1,
            county_id: -1,
            city:'',
            zip_code:'',
            listing_office: '',
            part_address: '',
            attr_set1: '0x0',
            attr_set2: '0x0',
            attr_set3: '0x0',
            part_address_fields: '',
            subdivision: '',
            sub_area: ''   // match a portion of area field (wild card)
      }
      Object.extend(this.defaults, defaults || {});
    },
    createQuery:function()
    {
        var min_price = $('price-bottom').value == "" ? 0 : $('price-bottom').value;
        var max_price = $('price-top').value;        
        var bedrooms = $('bed').value;
        var bathrooms = $('bath').value;
        var garage = $('garage').value;
        var min_year = $('year-bottom').value;
        var max_year = $('year-top').value;
        var slider_year_min = 0;
        var slider_year_max = 2011;

        if (typeof(s3) != 'undefined')
        {
            slider_year_min = s3.getMinimum();
            slider_year_max = s3.getMaximum();
            if (min_year == s3.getMinimum())
                min_year = 0;
            if (max_year == s3.getMinimum())
                max_year = 1;
        }
        var home_type = $('home_type').options[$('home_type').selectedIndex].value;
//        var list_class = $('list_class').options[$('list_class').selectedIndex].value;

        var list_class = "";
        if ($('list_class'))
                list_class = $('list_class').value;

        var part_address = $('part_address') ? $('part_address').value : "";
        var part_address_fields = $('part_address_fields') ? $('part_address_fields').value : "";

        var district = '';
        var high_school = '';
        var area = '';
        var snh_avail = '';
        var sub_area = '';

        if ($('district') != null)
        {
            district = getSelectedDistrict();
            if (district == null)
            {
                district = '';
            } else district = district.name;
        }
        if ($('high_school') != null)
        {
            high_school = getSelectedHighSchool();
            if (high_school == null)
            {
                high_school = '';
            } else high_school = high_school.name;
        }

        if ($('snh_avail') != null)
        {
           snh_avail = util_getSelectValue($('snh_avail'));
        }
        if ($('area') != null)
        {
            area = getSelectedArea();
            if (area == null)
            {
                area = '';
            }
            else  area = area.name;
        }
        if ($('sub_area') != null)
        {
           sub_area = util_getSelectValue($('sub_area'));
        }

        var max_sq_feet = $('sqft-top').value;
        var min_sq_feet = $('sqft-bottom').value;
        var acreage = formatNumber($('lot-size').value/10,1,',','.','','','-','');

        var listing_office = "";
        if ($('listing_office'))
        {
                var listing_office = $('listing_office').value;
                if ($('listing_office').type == 'hidden')
                {
                        $('listing_office').value = "";
                }
        }
    
        this.ext_search = false;
        //create homeQuery
        var search_query = "home.price >= " + min_price;
                
        if(max_price < this.defaults.max_price && max_price > 0)
        {
            search_query += " AND home.price <= " + max_price;
        }        
        
        if (part_address != "")
        {
            part_address_cleaned = part_address.replace(/[^a-zA-Z0-9]/, "%");

            fields = new Array('street', 'city', 'zip');
            if (part_address_fields != "")
                fields = part_address_fields.split(',');

            search_query += " AND (";

            clauses = new Array();
            for (i = 0; i < fields.length; i++)
            {
                if (fields[i].match("ext."))
                    this.ext_search = true;

                if (!fields[i].match("home.") && !fields[i].match("ext."))
                    fields[i] = "home."+fields[i];

                clauses[i] = fields[i]+" LIKE '%"+part_address_cleaned+"%'";
            }

            search_query += clauses.join(' OR ');
            search_query += ") ";
            this.no_geo = true;
            if ($('part_address').type == 'hidden')
            {
                $('part_address').value = "";
            }

//if (window.location.href == "http://pruflorida.blueroof360.com/site/index.php?test=1")
//        alert(search_query);
        }
        if ($('subdivision') && $('subdivision').value.length > 0)
        {
            search_query += " AND home.subdivision like '"+$('subdivision').value+"%'";
            this.no_geo = true;
        }

        if(bedrooms > 0)
        {        
            search_query += " AND home.bedrooms >= " + bedrooms;
        }
        
        if(bathrooms > 0)
        {
            search_query += " AND home.bathrooms >= " + bathrooms;
        }
        
        if(min_sq_feet > 0)
        {
            search_query += " AND home.sq_feet >= " + min_sq_feet;
        }
        
        if(max_sq_feet > 0 && max_sq_feet < this.defaults.max_sq_feet)
        {
            search_query += " AND home.sq_feet <= " + max_sq_feet;
        }
            
        if(garage > 0)
        {
            search_query += " AND home.garage_cap >= " + garage;
        }
        
        if(acreage > 0)
        {
            search_query += " AND home.acreage >= " + acreage;
        }

        if (listing_office != '')
                search_query += " AND home.listing_office = '" + listing_office + "'";

        if (min_year > slider_year_min) 
        {
            search_query += " AND home.year >= " + min_year;
        }
        
        if(max_year != slider_year_max && max_year != "")
        {
            search_query += " AND home.year <= " + max_year;
        }
        
        if(home_type.length > 0)
        {
            search_query += " AND home.home_type = '" + home_type+"'"; 
        }
        
        if (area.length > 0)
                search_query += " AND home.area = '"+area+"'";

        if(list_class.length > 0)
        {
            if (list_class.substring(0,2) == '--')
            {
                search_query += " AND home.property_subtype='"+list_class.substring(2)+"'";
            }
            else
            {
                search_query += " AND home.list_class = '" + list_class+"'"; 
            }
        }
        
        if(area.length > 0)
        {
            search_query += " AND home.area = '" +area+"'"; 
        }
        if(district.length > 0)
        {
            search_query += " AND ext.district = '" + district+"'"; 
            this.ext_search = true;
        }
        if(high_school.length > 0)
        {
            search_query += " AND ext.high_school = '" + high_school+"'";
        }
        if (snh_avail.length > 0)
        {
            search_query += " AND home.build_status = '" +snh_avail+"'";
        }
        if (sub_area.length > 0)
        {
            search_query += " AND home.area like '%" +sub_area+"%'";
            this.no_geo = true;
        }
        if ($('search_open_house') != null && $('search_open_house').checked == true)
        {
            search_query += " AND ext.open_house_end >= DATE(NOW())";
            this.ext_search = true;
        }
        if ($('private_pool') != null && $('private_pool').checked == true)
        {
            search_query += " AND ext.pool like '%Pool - Private%'";
            this.ext_search = true;
        }
        if ($('search_pru_only') != null && $('search_pru_only').checked == true)
        {
            search_query += " AND home.listing_office_id in (19500, 22400, 203056, 203010, 203011)";
        }
        if ($('recent_listing') != null && $('recent_listing').checked == true)
        {
            search_query += " AND home.list_date >= date_sub(now(), interval 7 day)";
        }

        if (($('show_fsbo_agent') != null) && ($('show_fsbo_agent').disabled == false) && ($('show_fsbo_agent').checked))
        {
            search_query += " AND home.realtor != '0'";
        }

        // this forclosure option was done for ARMLS. They had several options in a listing_condition field. I might change it to use
        // the more simple version that is next, which is just a y/n option. The ARMLS version is spelled wrong (without the e)
        if ($('forclosure') != null && $('forclosure').checked== true)
        {
            search_query += " AND (home.listing_condition & 98 > 0)";
        }
        if ($('foreclosure') != null && $('foreclosure').checked== true)
        {
            search_query += " AND home.foreclosure = 'y'";
        }
        if ($('short_sale') != null && $('short_sale').checked== true)
        {
            search_query += " AND home.short_sale = 'y'";
        }
        if ($('sold_listings') != null && $('sold_listings').checked == true)
        {
            search_query += " AND home.sold = 'y'";
        }
        if ($('sold_date') != null && $('sold_date').value != '')
        {
            search_query += " AND home.list_date >= DATE_SUB(CURDATE(),INTERVAL "+$('sold_date').value+" MONTH)";
        }
        if ($('lake') != null)
        {
            var lake = $('lake').options[$('lake').selectedIndex].value;
            if (lake == 'ANY')
            {
                search_query += " AND length(home.lake) > 0";
            }
            else if (lake != "")
            {
                search_query += " AND home.lake like '%"+lake+"%'";
            }
        }
        if ($('adv_table') != null)
        {
            var adv_choices = get_adv_choices();
            if ((adv_choices.attr_set1 != '0x0') || (adv_choices.attr_set2 != '0x0') || (adv_choices.attr_set3 != '0x0'))
            {
                search_query += " AND ((home.attr_set1 & "+adv_choices.attr_set1+") OR (home.attr_set2 & "+adv_choices.attr_set2+") OR (home.attr_set3 & "+adv_choices.attr_set3+"))";
            }
            hide_adv_search();
        }
        else if (this.attr_set1 && this.attr_set2 && this.attr_set3 && (this.attr_set1 != '0x0' || this.attr_set2 != '0x0' || this.attr_set3 != '0x0'))
        {
            search_query += " AND ((home.attr_set1 & "+this.attr_set1+") OR (home.attr_set2 & "+this.attr_set2+") OR (home.attr_set3 & "+this.attr_set3+"))";
        }

        if ($('city_id_filter') != null)
        {
            this.city_id_filter = $('city_id_filter').value;
        }

        var city = "";
        city = getSelectedCity();
        if (city == null)
        {
             var county = getSelectedCounty();
             if (county != null && (county.updateCity != -1 || this.filter_on_county))
             {
                 this.setCityFilter(true);
             }
/*             else
             {
                 if (county != null && this.filter_on_county)
                 {
                     search_query +=" AND home.county = '"+county.id+"'";
                 }
                 this.setCityFilter(false);
             }
*/
        }
        else if ($('search_city_zips') != null) 
        {
            if ($('search_city_zips').checked == false)
            {
                search_query += " AND home.zip = '" + city.zip + "'";
                this.setCityFilter(false);
            }
            else
            {
                this.setCityFilter(true);
            }
        }

        if ($('city_name') != null)
        {
            if($('city_name').value != '')
            {
                var re = new RegExp('^[0-9]{5}$');
                if ($('city_name').value.match(re))
                {
                    search_query += " AND home.zip = '"+$('city_name').value+"'";
                }
                else
                {
                    search_query += " AND home.city like '"+$('city_name').value+"%'";
                }
                this.no_geo = false; // in the city or zip code case, we will use the geocode from the city table
            }
            this.setCityFilter(false);
        }

        return search_query;
    },
    cleanParens:function(value)
    {
        return(value.replace(/[\(\)\s]/g, ""));
    },
    appendQueryValue:function(name_value, value_array)
    {
        //part address stuff: parse the actual data out of the query
        if (name_value.substring(0, 6) == "(home." || name_value.substring(0, 5) == "(ext.")
        {
            //There could be multiple clauses, but just look at the first to find the value
            value = name_value.match(/'%(.*?)%'/)[1];

            //Clean it up and save it
            value = value.replace(/%/, " ");
            name = "part_address";
            value_array[name] = value;

            //Get the list of fields we're searching (street/community/subdivision/etc)
            fields = name_value.match(/(home|ext)\.(.+?)\b/g);
            //for (i = 0; i < fields.length; i++)
            //        fields[i] = fields[i].substring(5);

            if (fields)
                value_array['part_address_fields'] = fields.join(',');
        }

        // check for advanced search attributes
        if (name_value.indexOf("attr_set") != -1)
        {
            var parts = name_value.split(' OR ');
            for (var i=0; i<parts.length; i++)
            {
                var attr = parts[i].split(' & ');
                var key = this.cleanParens(attr[0]).substring(5);
                var attr_value = this.cleanParens(attr[1]);
                value_array[key] = attr_value;
                this[key] = attr_value;
            }
            return;
        }

        var start = 0;
        var index = name_value.indexOf(' ', start);
        var name = name_value.substring(5, index);
        
        start = name.length+5+1;
        index = name_value.indexOf(' ', start);
        var op = name_value.substring(start, index);
        
        start += op.length + 1;
        var value = name_value.substring(start, name_value.length);
        
        if(name == 'price' || name == 'year' || name == 'sq_feet')
        {
            if(op == '>=')
            {
                name = 'min_'+name;
            }
            else
            {
                name = 'max_'+name;
            }
        }
        else if (name == 'listing_office')
        {
                value = value.substring(1, value.length-1);
        }
        else if(name == 'garage_cap')
        {
            name = 'garage';
        }
        else if(name == 'home_type')
        {
            value = value.substring(1, value.length-1);
        }
        else if(name == 'list_class')
        {
            value = value.substring(1, value.length-1);
        }
        else if(name == 'area')
        {
            if (op == 'like')
            {
               name = 'sub_area';
               value = value.substring(2,value.length-2);
            }
            else
            {
                value = value.substring(1, value.length-1);
            }
        }
        else if (name == 'property_subtype')
        {
            name = 'list_class';
            value = '--'+value.substring(1,value.length-1);
        }
        else if(name == 'istrict') // lost the d in district because it started out as ext.district, and then cut off first 5 letters.
        {
            name = 'district';
            value = value.substring(1, value.length-1);
        }
        else if(name == 'igh_school') // lost the h.
        {
            name = 'high_school';
            value = value.substring(1, value.length-1);
        }
        else if(name == 'pen_house_end') // lost the o open_house because it started out as ext.district, and then cut off first 5 letters.
        {
            name = 'open_house_end';
            value = 'true';
        }
        else if (name == 'ool') // searching for pool;
        {
            name = 'pool';
            value = 'true';
        }
        else if (name == 'listing_office_id')
        {
            value = 'true';
        }
        else if (name == 'realtor')
        {
            value = 'true';
        }
        else if (name == 'foreclosure')
        {
            value = 'true';
        }
        else if (name == 'short_sale')
        {
            value = 'true';
        }
        else if (name == 'sold')
        {
            value = 'true';
        }
        else if (name == 'list_date' && value.length == 37)
        {
            // value looks like: DATE_SUB(CURDATE(),INTERVAL 01 MONTH)
            value = value.substring (28,30);
            name="sold_date";
        }
        else if (name == 'lake')
        {
            if (op=='like')
            {
                value = value.substring(2,value.length-2);
            }
            else
            {
                value = 'ANY';
            }
        }
        else if (name=='county' || name == 'city' || name == 'zip' || name== 'subdivision')
        {
            value = value.replace(/[%']/g, "");
            if (name == 'zip')
                name='zip_code';
        }
            
        value_array[name] = value;
    },
    setSearchValues:function(query)
    {
        var values = new Array();
        Object.extend(values, this.defaults);
        if(query != null)
        {
            var parts = query.split(' AND ');
            var newValues = new Array();
            for(var i = 0; i < parts.length; i++)
            {
                this.appendQueryValue(parts[i], newValues);
            }
            
            Object.extend(values, newValues);
        }
        
        s1.setTopValue(values.max_price);
        s1.setBottomValue(values.min_price);
        s2.setTopValue(values.max_sq_feet);
        s2.setBottomValue(values.min_sq_feet);
        s3.setTopValue(values.max_year);
        s3.setBottomValue(values.min_year);
        s4.setValue(values.bedrooms);
        s5.setValue(values.bathrooms);
        s6.setValue(values.garage);
        s7.setValue(values.acreage*10);
        
        util_setSelectValue($('home_type'), values.home_type);
        if ($('list_class') != null)
        {
            var list_class=values.list_class;
            if ($('list_class').type == 'select-one')
            {
                if (list_class != null)
                {
                    util_setSelectValue($('list_class'), list_class);
                }
                else
                {
                    util_setSelectValue($('list_class'), "");
                }
            }
            else if ($('list_class').type == 'radio')
            {
                list_classes = document.search.list_class;
                for (var i=0; i<list_classes.length; i++)
                {
                    if (list_classes[i].value == list_class)
                    {
                        list_classes[i].checked = true;
                    }
                }
            }
        }
        if ($('district') != null)
        {
            var dist = getDistrictByName(values.district);
            if (dist != null)
            {
                util_setSelectValue($('district'), dist.id);
            }
            else
            {
                util_setSelectValue($('district'), "");
            }
        }
        if ($('subdivision') != null)
        {
            $('subdivision').value = values.subdivision;
        }
        if ($('snh_avail') != null)
        {
            var avail = util_setSelectValue($('snh_avail'), values.snh_avail);
            resetSearchSNHS();
        }
        if ($('sub_area') != null && values.sub_area != null)
        {
            util_setSelectValue($('sub_area'),values.sub_area);
        }
        if ($('area') != null && values.area != null)
        {
            if (values.area.length > 2)
                values.area = values.area.substring(1,values.area.length-1); // get rid of the surrounding quotes
            var area = getAreaByName(values.area); 
            if (area != null)
            {
                util_setSelectValue($('area'), area.id);
            }
            else
            {
                util_setSelectValue($('area'), "");
            }
        }

        if ($('lake') != null)
        {
            util_setSelectValue($('lake'), values.lake);
        }
        if ($('search_open_house') != null)
        {
            if (values.open_house_end != null && values.open_house_end == 'true')
            {
                $('search_open_house').checked = true;
            }
        }
        if ($('private_pool') != null && values.pool == 'true')
        {
            $('private_pool').checked = true;
        }
        if ($('foreclosure') != null && values.foreclosure == 'true')
        {
            $('foreclosure').checked = true;
        }
        if ($('short_sale') != null && values.short_sale == 'true')
        {
            $('short_sale').checked = true;
        }
        if ($('sold_listings') != null && values.sold == 'true')
        {
            $('sold_listings').checked = true;
            if ($('sold_date') != null)
            {
                util_setSelectValue($('sold_date'), values.sold_date);
            }
        }
        
        if ($('part_address_fields') && values.part_address_fields)
        {
                $('part_address_fields').value = values.part_address_fields;
        }
        if ($('part_address'))
        {
                if (values.part_address)
                    $('part_address').value = values.part_address;
                else if (values.city && $('part_address_fields') && ($('part_address_fields').value.indexOf('home.city') != -1))
                    $('part_address').value = values.city;
        }

        if ($('listing_office'))
        {
                $('listing_office').value = values.listing_office;
        }

        if ($('city_name'))
        {
            if (values.city)
                $('city_name').value = values.city;
            else if (values.zip_code)
                $('city_name').value = values.zip_code;
            else $('city_name').value = '';
        }

        $('home_num').value = "";

        if (($('recent_listing') != null) && values.list_date!= null && values.list_date.length> 0)
        {
            $('recent_listing').checked= true;
/*            var day = values.list_date.indexOf('day')-1;
            var interval = values.list_date.indexOf('interval') + 9;
            lc = values.list_date.substring(interval, day);
            util_setSelectValue($('recent_listing'), lc);
*/
        }

        if ($('search_pru_only') != null)
        {
            if (values.listing_office_id != null && values.listing_office_id == 'true')
            {
                $('search_pru_only').checked=true;
            }
        }
/*        if ($('city') != null)
        {
            $('city').value = values.city;
        }
*/
        if ($('city_id_filter') != null)
        {
            $('city_id_filter').value = values.city_id == -1 ? "" : values.city_id;
        }

        if (values.county !=null)
        {
            util_setSelectValue($('county'), values.county);
            updateCitySelect();
            if (_mdc != null && _mdc.map != null)
            {
                updateCountyMap();
            }
        }

        if ($('adv_table') != null)
        {
            clear_adv_choices();
            set_adv_choices(values.attr_set1, values.attr_set2, values.attr_set3);
        }

        
//        this.setTablePrefix(null);
        if ($('show_fsbo_agent') != null)
        {
            if (values.realtor != null && values.realtor)
            {
                $('show_fsbo_agent').checked=true;
            }
            if (this.getTablePrefix() == 'fsbo')
            {
                $('show_fsbo_agent').disabled = false;
            }
        }
    },
    getSummaryTable:function(query)
    {
        var summary = document.createElement("table");
        summary.cellpadding=0;
        summary.cellspacing=0;
        summary.border=0;
        summary.width="100%";
        summary.className = 'cdgrey';
        
        var min_price = $('price-bottom').value;
        var max_price = $('price-top').value;        
        var bedrooms = $('bed').value;
        var bathrooms = $('bath').value;
        var garage = $('garage').value;
        var min_year = $('year-bottom').value;
        if (min_year == 1800)
            min_year = 1;
        var max_year = $('year-top').value;
        if (max_year == 1800)
            max_year = 1;
        var home_type = $('home_type').options[$('home_type').selectedIndex].value;
//        var list_class = $('list_class').options[$('list_class').selectedIndex].value;
        var list_class = $('list_class').value;
        var district = '';
        if ($('district') != null)
            district = $('district').options[$('district').selectedIndex].value;
        var subdivision = '';
        if ($('subdivision') != null)
            subdivision = $('subdivision').value;
        var max_sq_feet = $('sqft-top').value;
        var min_sq_feet = $('sqft-bottom').value;
        var acreage = formatNumber($('lot-size').value/10,1,',','.','','','-','');
        
        var search_type = this.getTablePrefix();
        
        // Set min and max price in the save search pannel
        var format = new NumberFormat(min_price);
        format.setCurrency(true);        
        var price = format.toFormatted();
        if(max_price < this.defaults.max_price)
        {
            format = new NumberFormat(max_price);
            format.setCurrency(true);
            price += " - " + format.toFormatted();
        }
        else
        {
            price += ' - Any';
        }
    
        var tr = summary.insertRow(0);
        this.appendSummaryCells('Price:&nbsp;', price, tr, 3);
        
        var sq_feet = 'Any';
        if(max_sq_feet > 0 && max_sq_feet < this.defaults.max_sq_feet && min_sq_feet == 0)
        {
            sq_feet = 'Less Than '+max_sq_feet;
        }
        else if(max_sq_feet == this.defaults.max_sq_feet && min_sq_feet > 0)
        {
            sq_feet = 'More Than '+min_sq_feet;
        }
        else if(min_sq_feet > 0 && max_sq_feet > 0 && max_sq_feet < this.defaults.max_sq_feet)
        {
            sq_feet = min_sq_feet+' - '+max_sq_feet;
        }
            
        
        tr = summary.insertRow(1);
        this.appendSummaryCells('Square feet:&nbsp;', sq_feet, tr, 3);
        
        tr = summary.insertRow(2);
        this.appendSummaryCells('Bedrooms:&nbsp;', (bedrooms == '0')? 'Any':bedrooms, tr);
        this.appendSummaryCells('Baths:&nbsp;', (bathrooms == '0')? 'Any':bathrooms, tr);
        
        tr = summary.insertRow(3);
        this.appendSummaryCells('Garage Size:&nbsp;', (garage == '0')? 'Any':garage+'+ cars', tr);
        this.appendSummaryCells('Lot Size:&nbsp;', (acreage == '0')? 'Any':acreage+'+ acres', tr);
        
        tr = summary.insertRow(4);
        var year = '';
        if (min_year == 1)
        {
            if (max_year == s3.getTopValue())
            {
                year = "Any";
            }
            else
            {
                year = "before "+max_year;
            }
        }
        else
        {
            year = "after "+min_year;
            if (max_year != s3.getTopValue())
            {
                year += " - before "+max_year;
            }
        }
        this.appendSummaryCells('Year Built:&nbsp;', year, tr, 3);
        
        tr = summary.insertRow(5);
        this.appendSummaryCells('Home Type:&nbsp;', (home_type == '')? "Any":home_type, tr, 3);
        
        tr = summary.insertRow(6);
        this.appendSummaryCells('Property Type:&nbsp;', (list_class == '')? "Any":list_class, tr, 3);
        
        tr = summary.insertRow(7);
        this.appendSummaryCells('Search For:&nbsp;', $(search_type+'_name').value, tr, 3);
        
        var nextCell = 8;
        if ($('district') != null)
        {
            tr = summary.insertRow(nextCell);
            nextCell++;
            this.appendSummaryCells('School Dist:&nbsp;', (district == '')? "Any":district, tr, 3);
        }
        if (subdivision != '')
        {
            tr = summary.insertRow(nextCell);
            nextCell++;
            this.appendSummaryCells('Subdivision:&nbsp;', subdivision, tr, 3);
        }
        if($('search_open_house') != null && $('search_open_house').checked)
        {
            tr = summary.insertRow(nextCell);
            this.appendSummaryCells('Open Houses:', 'true', tr, 3);
        }
        if($('search_pru_only') != null && $('search_pru_only').checked)
        {
            tr = summary.insertRow(nextCell);
            this.appendSummaryCells('Prudential Listings:', 'true', tr, 3);
        }
        if($('recent_listings') != null && $('recent_listings').checked)
        {
            tr = summary.insertRow(nextCell);
            this.appendSummaryCells('Recent Listings:', 'true', tr, 3);
        }
        return summary;
    }
});

function rem_quotes_slashes(str)
{
    if (str == null)
        return('');
    if (str.charAt(0) == '\\')
        return(str.substring(2,str.length-2));
    return(str.substring(1,str.length-1));
}


