function Map_Panel_Class() {
    this.markers = [];
    this.gmap = null;

    this.bars_icon = 'http://labs.google.com/ridefinder/images/mm_20_brown.png';
    this.restaurants_icon = 'http://labs.google.com/ridefinder/images/mm_20_green.png';
    this.music_icon = 'http://labs.google.com/ridefinder/images/mm_20_blue.png';
    this.sports_icon = 'http://labs.google.com/ridefinder/images/mm_20_red.png';
    this.culture_icon = 'http://labs.google.com/ridefinder/images/mm_20_white.png';
    this.default_icon = 'http://labs.google.com/ridefinder/images/mm_20_purple.png';
    this.highlighted_icon = 'http://labs.google.com/ridefinder/images/mm_20_yellow.png';


    this.info_window_hidden_but_not_closed = false; //bug where hiding the info window is different then closing, causing errors w/events

    this.init = function(min_latitude, min_longitude, max_latitude, max_longitude) {
        var map = document.getElementById("map");

            if (GBrowserIsCompatible()) {
                this.gmap = new GMap2(map);
                this.gmap.addControl( new GSmallMapControl() );
                //gmap.addControl( new GOverviewMapControl(new GSize(100,100)) );
                var bounds = new GLatLngBounds(
                    new GLatLng(min_latitude, min_longitude),
                    new GLatLng(max_latitude, max_longitude)
                );
                this.gmap.setCenter ( bounds.getCenter(), this.gmap.getBoundsZoomLevel(bounds));
                
            } else {
                alert("Sorry, your browser does not support Google Maps");
            }

        GEvent.addListener(this.gmap, 'moveend', function() {
            tweets_panel.redraw();
        });
//        GEvent.addListener(this.gmap, 'click', function() {
///            if (filters_panel.is_single_business_selected)
//                filters_panel.hide_single_business();
//        });
    }

    this.get_marker_icon = function(business_id) {
        var business = businesses[business_id];
        //alert(business.categories[0]);fsd;
        if (jQuery.inArray("10", business.categories) != -1)
            return this.music_icon;
        if (jQuery.inArray("102", business.categories) != -1)
            return this.culture_icon;
        if (jQuery.inArray("101", business.categories) != -1)
            return this.sports_icon;
        if (jQuery.inArray("3", business.categories) != -1)
            return this.bars_icon;
        if (jQuery.inArray("1", business.categories) != -1)
            return this.restaurants_icon;
        
        return this.default_icon;
    }

    this.add_business_marker = function (business) {
        var marker = this.createMarker(business);
        this.gmap.addOverlay(marker);
        this.markers.push(marker);
    }

    this.infoTab = function (business) {
        var profile = profiles[business_to_profile_map[business.id]];
        var html 	 = "<div class=\"bubble\">";
        html            += '<img class="profile_image" src ="' + profile.profile_image_url + '"/>';
        html 		+= '<h2 class="business_title">' + business.title + '</h2>';
        html            += 'Categories: ';
        for(i in business.categories) {
            var description = business_categories[business.categories[i]].description;
            if (i > 0) description = ', ' + description
            html        += description;
        }
        html            += '<br/>';
        html 		+= "<p>" +business.address + '<br />';
        if(business.phone != null) {
            html        += '(' + business.phone.substring(0,3) +') '+ business.phone.substring(3,6)+'-'+business.phone.substring(6,10)+'<br />';
        }
        if(business.url != null) {
            html        += "<a href=\"" + business.url +"\">"+business.url+"</a>";
        }
        html            += "</p>";
        html		+= "</div>";
        return html;
    }

    this.createMarker = function (business) {
        var mapIcon = new GIcon(G_DEFAULT_ICON);
        mapIcon.image = this.get_marker_icon(business.id);
        mapIcon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
        mapIcon.iconSize = new GSize(12, 20);
        mapIcon.shadowSize = new GSize(22, 20);
        mapIcon.iconAnchor = new GPoint(6, 20);
        mapIcon.infoWindowAnchor = new GPoint(5, 1);

        // Set up our GMarkerOptions object
        markerOptions = { icon: mapIcon };
        var mythis = this;
        var gmap = this.gmap;
        point = new GLatLng(business.latitude, business.longitude)
        var marker = new GMarker(point, markerOptions);
        var tabs_array	= [new GInfoWindowTab("Information", this.infoTab(business) ) ];
        marker.tabs_array = tabs_array;
        
        GEvent.addListener(marker, "click", function() {
            //marker.openInfoWindowHtml(tabs_array);
            //businesses_panel.business_button_click(business.id);
            filters_panel.show_single_profile(business_to_profile_map[business.id]);
        });
        GEvent.addListener(marker, 'infowindowclose', function() {
            if(!map_panel.info_window_hidden_but_not_closed)
                filters_panel.hide_single_business();
            map_panel.info_window_hidden_but_not_closed = false;
        });
        GEvent.addListener(marker, "mouseover", function(LatLng) {
            var options = {
                "color": "#FFFFFF",
                "backgroundColor": "#666666",
                "border": "2px solid #333333",
                "offsetX": -50,
                "offsetY": 50
            };
            this.overlay = new MapTooltip(this, business.title, options);
            gmap.addOverlay(this.overlay);
            marker.setImage("http://labs.google.com/ridefinder/images/mm_20_yellow.png");
        });
        GEvent.addListener(marker, "mouseout", function() {
            gmap.removeOverlay(this.overlay);
            marker.setImage(mythis.get_marker_icon(business.id));
        });

        return marker;
    }

    this.highlight_business = function(business_id) {
        this.markers[business_id].setImage("http://labs.google.com/ridefinder/images/mm_20_yellow.png");
    }
    this.unhighlight_business = function(business_id) {
        this.markers[business_id].setImage(this.get_marker_icon(business_id));
    }

    this.redraw = function() {
        if (businesses_panel.selected_profiles.length == 0 && filters_panel.selected_categories.length == 0) {
            for(i in businesses)
                markers[i].show();
        } else {
            for(i in businesses) {
                if (filters_panel.should_show_profile(business_to_profile_map[businesses[i].id])) {
                    markers[i].show();
                } else {
                    markers[i].hide();
                }
            }
        }
    }

}