		var gMapContainer;
		var mapControl;	
var icon = new GIcon();
icon.shadow = "http://www.google.com/mapfiles/shadow50.png";
icon.iconSize = new GSize(20, 34);
icon.shadowSize = new GSize(37, 34);
icon.iconAnchor = new GPoint(9, 34);
icon.infoWindowAnchor = new GPoint(9, 2);
icon.infoShadowAnchor = new GPoint(18, 25);
       var bounds = new GLatLngBounds();
           
            
function setMapCenterZoom(map)
{
            
	      var mygmap=getMap();  
	     // alert("Center"+bounds.getCenter()); 
	      mygmap.setCenter(bounds.getCenter());
	      mygmap.setZoom(mygmap.getBoundsZoomLevel(bounds));
	      
 }       
 
 
function getMap()
{
	   if(gMapContainer)
	   {	
       	var mygmap=gMapContainer.getMap();
       //	alert("Size"+mygmap.getSize());
       	return mygmap;
	   }
	   else
	   {
	   	return null;
	   }
} 


function addMarker(icontype,mapname,lat,lon,name,rating,address,city,state,phone){           
            gMapContainer = Ext.getCmp(mapname);
			var mygmap=gMapContainer.getMap();
          
         var icontemp;
              icontemp = new GIcon(icon);
          if(rating>80)
      		 {
      		     icontemp.image= "images/googlemapsicons/greennumbers-zip1.png";
      		  }
      		  else if(rating>=50)
      		  {
      		       icontemp.image= "images/googlemapsicons/bluenumbers-zip1.png";
           	  }
      		  else
      		  {
     		     icontemp.image= "images/googlemapsicons/rednumbers-zip1.png";
       		  }
      		
      		if(icontype=="food")
      		     icontemp.image= "images/googlemapsicons/food.png";
      		     
    		icontemp.iconSize = new GSize(30, 30);
		    icontemp.shadowSize = new GSize(35, 35);
		    
		    if (icontype=="small")
		    {
		    	icontemp.image= "v2images/smallmapicon.png";
      		     
    			icontemp.iconSize = new GSize(16, 16);
		    	icontemp.shadowSize = new GSize(0,0);
		    
		    }
		    if (icontype=="normalblue")
		    {
		    	icontemp.image= "v2images/bluemarker.png";
      		     
    			icontemp.iconSize = new GSize(32, 32);
		    	icontemp.shadowSize = new GSize(16,16);
		    
		    }
       		  
       		  
      	  var latlng = new GLatLng(lat,lon);
           var html='<span style="font-size:110%; font-weight:bold">'+name+'</span><span style="font-weight:normal;"><br>'+address+'<br>'+city+' , '+state+'<br>'+phone+'</span>';
		   var label=name;
		   
		   //alert(latlng);
		   bounds.extend(latlng);
                
        	
      			   
           var gMarker = createMarker(latlng,label,html,icontemp,mygmap);	
           mygmap.addOverlay(gMarker);
           return gMarker;
    }
     
     
       // A function to create the marker and set up the event window

 function createMarker(point,name,html,icontype,mygmap) {
        var marker = new GMarker(point, {title:name, icon:icontype});

		GEvent.addListener(marker, "click", function() {
        marker.openExtInfoWindow(
          mygmap,
          "simple_example_window",
          html,
          {beakOffset: 3}
        ); 
		});	// marker click end
        return marker;
}

function clearBounds()
{
	bounds = new GLatLngBounds();
}

function clearMap()
{
	bounds = new GLatLngBounds();
	var mymap = getMap();
	if (mymap)
		mymap.clearOverlays();
}
