    function initialize(flag) {

	  if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map"));
		 
         if(flag == 1) {
			map.addControl(new GMapTypeControl());
		  }

          if(flag == 0) {
            map.addControl(new GSmallMapControl());
          } else {
              map.addControl(new GLargeMapControl());
          }

		  
		  
	        //map.setCenter(new GLatLng(37.4419, -122.1419), 10);
		//	map.setMapType(G_HYBRID_MAP);
        geocoder = new GClientGeocoder();
      }

    }

	function call()
	{
		showAddress(addressArray[0]);
	}


	member_name = "";
	
	function createMarker(point,title, start_date, end_date, address) {

        var marker = new GMarker(point);
		map.addOverlay(marker);
        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml("Title: " + title +" <br>  Start Date: " + start_date  +" <br>  End Date: " + end_date +" <br> Location: " + address);
        });
        return marker;

	}
	

    function showAddress(title, start_date, end_date, address,  fl) {
	   

      if (geocoder) {

		geocoder.getLatLng(
          address,  
		  function(point) {
            if (!point) {

			  //document.getElementById("notfound").style.display = 'block';
            } else {
			
				
              map.setCenter(point, 1);
             
			 // marker.setImage('bluepushpin.png');
			 // marker.shadow = 'shadow.png';
			if(fl) {
					var marker = createMarker(point, title, start_date, end_date, address); 
			}else {
				 var marker = new GMarker(point);
			  	  map.addOverlay(marker);
				  GEvent.addListener(marker, "click", function() {
							marker.openInfoWindowHtml(title);
				  });
			}
			 
			
            }
          }
        );
      }
	  
    }
	
	function init(flag)
	{
		initialize(flag);
		//call();
		var address = Array();
		for(i=0; i<numberOfAdds; i++)
		{
			
		
			//alert(addressArray[i] +"---"+ addressArray[i].indexOf("$$$"));
		   if(addressArray[i].indexOf("$$$") >= 1) {
				// multiple events found on same location	   
				var arr = Array();

				arr = addressArray[i].split('$$$');
				var str = "";

				var location = arr[arr.length - 1].split("@@@")[3];
				
				for(j =0 ; j< arr.length; j++){
					str += 	"<br> Title: "+ arr[j].split("@@@")[0] + " Start Date: " + arr[j].split("@@@")[1];
					str += 	" End Date:  " +  arr[j].split("@@@")[2];
				}
				
				str += 	"<br> Location:  " +  location;
				
				showAddress(str, "",  "", location,   false);

		   } else {
			   address = addressArray[i].split('@@@');
			  
			   e_title = address[0]
			   e_start_date = address[1];
			   e_end_date = address[2];
			   e_location = address[3];
			  
			   showAddress(e_title, e_start_date,  e_end_date, e_location,   true);
		   }
   
		  
		}
	}
	

function load_members() {

  var parms =  
  		  'city=' +  $('city').value +
		  '&country=' +  $('country').value +
		  '&cmd=load_members';

  new Ajax.Request('gmap.php', 
    {
		  parameters: parms,
	  	  method: 'post',

		  onLoading: function(request) { Element.show ('loading')},
		  onComplete: function(request) {
				
				var arr = request.responseText.split("@@");
				
				$('members').innerHTML = arr[0]+ " Members found."
				arr = arr[1];
				var total = arr.length;
				for(i=0; i < total; i++)	{
					showAddress(arr[i], i);
				}
				Element.hide ('loading');
		  }
		  
    });
  return false;
}