var yellow_pin;
var red_pin;
var white_pin;

var map = null;
var manager = null;

function create_marker(point, html, icon) {
   var marker = new GMarker(point, icon);
   GEvent.addListener(marker, "click", function() {
     marker.openExtInfoWindow(
       map,
       "map_wide",
       html,
       {beakOffset: 5}
     );
   });
   return marker;
 }

 
 function load_map_data( my_map, map_points, default_zoom ) {
   var bounds = new GLatLngBounds();
   var batch  = new Array;
   my_map.clearOverlays();

   for( var i = 0; i < map_points.length; i++) {
     var marker = create_marker(map_points[i].point, map_points[i].html, map_points[i].icon);
     my_map.addOverlay(marker);
	 bounds.extend(map_points[i].point);
     batch.push( marker );
   }
	
	if(default_zoom != false) {
    map.setCenter(bounds.getCenter());
		map.setZoom(default_zoom);
	}
	else {
		if( map.getBoundsZoomLevel(bounds) > 10 )
			map.setZoom(10);
		else
			map.setZoom(map.getBoundsZoomLevel(bounds));
	    map.setCenter(bounds.getCenter());
		}
 }

function create_pins(){
	yellow_pin                  = new GIcon(G_DEFAULT_ICON);
	yellow_pin.iconSize         = new GSize(37, 51);
	yellow_pin.shadowSize       = new GSize( 0, 0);
	yellow_pin.iconAnchor       = new GPoint(18, 43);
	yellow_pin.infoWindowAnchor = new GPoint(11, 10);
	yellow_pin.image            = "/images/google_maps/yellow_pin.png";
	yellow_pin.transparent      = "/images/google_maps/yellow_pin_transparent.png";
	yellow_pin.imageMap         = [  13,8,  7,14,  7,22,  18,44,  29,22,  29,14,  23,8 ];
	
	orange_pin                  = new GIcon(G_DEFAULT_ICON);
	orange_pin.iconSize         = new GSize(37, 51);
	orange_pin.shadowSize       = new GSize( 0, 0);
	orange_pin.iconAnchor       = new GPoint(18, 43);
	orange_pin.infoWindowAnchor = new GPoint(11, 10);
	orange_pin.image            = "/images/google_maps/orange_pin.png";
	orange_pin.transparent      = "/images/google_maps/yellow_pin_transparent.png";
	orange_pin.imageMap         = [  13,8,  7,14,  7,22,  18,44,  29,22,  29,14,  23,8 ];
	
	red_pin                  = new GIcon(G_DEFAULT_ICON);
	red_pin.iconSize         = new GSize(37, 51);
	red_pin.shadowSize       = new GSize( 0, 0);
	red_pin.iconAnchor       = new GPoint(18, 43);
	red_pin.infoWindowAnchor = new GPoint(11, 10);
	red_pin.image            = "/images/google_maps/red_pin.png";
	red_pin.transparent      = "/images/google_maps/yellow_pin_transparent.png";
	red_pin.imageMap         = [  13,8,  7,14,  7,22,  18,44,  29,22,  29,14,  23,8 ];
	
	white_pin                  = new GIcon(G_DEFAULT_ICON);
	white_pin.iconSize         = new GSize(37, 51);
	white_pin.shadowSize       = new GSize( 0, 0);
	white_pin.iconAnchor       = new GPoint(18, 43);
	white_pin.infoWindowAnchor = new GPoint(11, 10);
	white_pin.image            = "/images/google_maps/white_pin.png";
	white_pin.transparent      = "/images/google_maps/yellow_pin_transparent.png";
	white_pin.imageMap         = [  13,8,  7,14,  7,22,  18,44,  29,22,  29,14,  23,8 ];
}