var googleMap = function(sKey, sContainerName, iWidth, iHeight)
{
	if (GBrowserIsCompatible())
	{
		var _this              = this;
	  this.sKey              = sKey || '';
	  this.sContainerName    = sContainerName || '';
	  this.iWidth            = iWidth || 400;
	  this.iHeight           = iHeight || 400;
	  this.iInitialLatitude  = 0;
	  this.iInitialLongitude = 0;
	  this.iInitialZoom      = 0;
	  this.aMarkers          = [];
	  if (this.sKey == '')
	  {
	  	alert('Google Map API key is required!');
	  	return false;
	  }
	  if (this.sContainerName == '')
	  {
	  	alert('Google Map container name is required!');
	  	return false;
	  }
	  this.oDiv = document.getElementById(this.sContainerName).appendChild(document.createElement('div'));	  
	  this.oDiv.style.width = this.iWidth;
	  this.oDiv.style.height = this.iHeight;
	  var oMap = this.oMap = new GMap2(this.oDiv);
	  //var oMap = this.oMap = new GMap(this.oDiv);
	  this.show = function()
	  {
	  	if (this.iInitialZoom < 0)
	  	{
	  		this.iInitialZoom = 0;
	  	}
	  	if (this.iInitialZoom > 20)
	  	{
	  		this.iInitialZoom = 20;
	  	}		
	  	this.oMap.setCenter(new GLatLng(this.iInitialLatitude, this.iInitialLongitude), this.iInitialZoom);
	  	if (this.aMarkers.length > 0)
	  	{
	  		var oGeoCoder = new GClientGeocoder();
	  	  for (var i = 0; i < this.aMarkers.length; i++)
	  	  {
	  	  	if (this.aMarkers[i].iLatitude && this.aMarkers[i].iLongitude)
	  	  	{
	  	  		var oPoint = new GLatLng(this.aMarkers[i].iLatitude, this.aMarkers[i].iLongitude);
	  	  		if (this.aMarkers[i].oOptions)
            {
            	var oIcon = new GIcon(G_DEFAULT_ICON);
            	if (this.aMarkers[i].oOptions.sImage)
            	{
            	  oIcon.image = this.aMarkers[i].oOptions.sImage;
              }
              if (this.aMarkers[i].oOptions.iWidth && this.aMarkers[i].oOptions.iHeight)
              {
              	oIcon.iconSize = new GSize(this.aMarkers[i].oOptions.iWidth, this.aMarkers[i].oOptions.iHeight);
              }
            	var oMarker = new GMarker(oPoint, oIcon);
            }
            else
            {
            	var oMarker = new GMarker(oPoint);
            }
            oMap.addOverlay(oMarker);
            if (this.aMarkers[i].aEvents)
            {
              for (var j = 0; j < this.aMarkers[i].aEvents.length; j++)
              {
                GEvent.addListener(oMarker, this.aMarkers[i].aEvents[j].sEvent, this.aMarkers[i].aEvents[j].oFunction);
              }
            }
	  	  	}
	  	  	else
	  	  	{
            eval("var oFunction = function(point) { if (point) { if (_this.aMarkers[" + i + "].oOptions) { var oIcon = new GIcon(G_DEFAULT_ICON); oIcon.image = _this.aMarkers[" + i + "].oOptions.sImage; var oMarker = new GMarker(point, oIcon); } else { var oMarker = new GMarker(point); } oMap.addOverlay(oMarker); for (var j= 0; j < _this.aMarkers[" + i + "].aEvents.length; j++) { GEvent.addListener(oMarker, _this.aMarkers[" + i + "].aEvents[j].sEvent, _this.aMarkers[" + i + "].aEvents[j].oFunction); } } };");
	  	  	  oGeoCoder.getLatLng(
              this.aMarkers[i].sAddress,
              oFunction
            );
          }
	  	  }
	    }
	  };
  }
  else
  {
  	alert('Your browser is not compatible!"');
  }
};