
	// Define constants and variables
	var gmMaps = new Array();
	var Markers = new Array();
	var MarkersInfo = new Array();
	var gmCategories = new Array();
	var _SHOWMAPTYPE = 1;
	var _ADDLOCALSEARCH = 2;
	var _ADDMAPOVERVIEW = 3;
	var _ENABLEDOUBLECLICKZOOM = 4;
	var _DISABLEDOUBLECLICKZOOM = 5;
	var _LARGEZOOMTYPE = 6;
	var _SMALLZOOMTYPE = 7;	
	var _SATELLITEMAP = 8;
	var _HYBRIDMAP = 9;
	var _NORMALMAP = 10;
	var _TERRAINMAP = 11;
	
	/**
		Initialize a specifc map
	*/
	function initMap(id) {
		map = new GMap2(document.getElementById("googlemap_" + id));
		gmMaps[id] = map;
	}
	
	/**
		This function will add specific options to the map
	*/
	function addMapOption(id, feature) {
		switch (feature) {
			case _SHOWMAPTYPE:
				gmMaps[id].addControl(new GMapTypeControl());
				break;
			case _ADDLOCALSEARCH:
				gmMaps[id].addControl(new google.maps.LocalSearch());
				break;
			case _ADDMAPOVERVIEW:
				gmMaps[id].addControl(new GOverviewMapControl());
				break;
			case _ENABLEDOUBLECLICKZOOM:
				gmMaps[id].enableDoubleClickZoom();
				break;
			case _DISABLEDOUBLECLICKZOOM:
				gmMaps[id].disableDoubleClickZoom();
				break;				
			case _LARGEZOOMTYPE:
				gmMaps[id].addControl(new GLargeMapControl());
				break;
			case _SMALLZOOMTYPE:
				gmMaps[id].addControl(new GSmallMapControl());
				break;		
			case _SATELLITEMAP:
				gmMaps[id].addMapType(G_SATELLITE_MAP);
				gmMaps[id].setMapType(G_SATELLITE_MAP);				
				break;
			case _HYBRIDMAP:
				gmMaps[id].addMapType(G_HYBRID_MAP);
				gmMaps[id].setMapType(G_HYBRID_MAP);				
				break;
			case _NORMALMAP:
				gmMaps[id].addMapType(G_NORMAL_MAP);
				gmMaps[id].setMapType(G_NORMAL_MAP);				
				break;
			case _TERRAINMAP:
				gmMaps[id].addMapType(G_PHYSICAL_MAP);
				gmMaps[id].setMapType(G_PHYSICAL_MAP);				
				break;												
		}
	}
	
	/**
		This function will specify the maps center
	*/
	function setMapCenter(id,lat,lng,zoom) {
		gmMaps[id].setCenter(new GLatLng(lat,lng),zoom);
	}
	
	/**
		Add an object to the specified map
	*/
	function addOverlay(id,obj) {
		gmMaps[id].addOverlay(obj);
	}
	
	
function openInfoWindow(mapid,id,usetabs) {  
	if (usetabs == 'N') {     
		Markers[mapid,id].openInfoWindowHtml(MarkersInfo[mapid,id]);
	} else {     
		Markers[mapid,id].openInfoWindowTabsHtml(MarkersInfo[mapid,id]);   
	}
}	
	

function changeMarkerPosition(mapid,marker,lat,lng) {
	var curPosition = marker.getPoint();
	map = gmMaps[mapid];
	map.setCenter(marker.getPoint());
	lat.value = curPosition.lat();
	lng.value = curPosition.lng();
}

function previewMarkerInfoWindow(marker) {
    var title = "<div class='markerName'>" + document.adminForm.name.value + "</div>";
    var desc = "<div class='markerDescription'>" + document.adminForm.description.value + "</div>";
	marker.openInfoWindowHtml(title + desc);
}


function geocodeMarkerAddress(mapid,mid) {
  var address = document.adminForm.geocodeaddr.value
  var lat = document.adminForm.latitude;
  var lng = document.adminForm.longitude;
  var id = document.adminForm.id.value;
  var geocoder = new GClientGeocoder();
  var marker = Markers[mapid,mid];
  var map = gmMaps[mapid];
  geocoder.getLatLng(
    address,
    function(point) {
      if (!point) {
        alert(address + " not found");
      } else {
        map.setCenter(point, 13);
        marker.setPoint(point);
//        map_0.addOverlay(marker);
		lat.value = point.lat();
		lng.value = point.lng();
      }
    }
  );
  
  
}

/*	
var jrequest = false;
function getHttpRequest() {
	var http_request = false;

	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/html');
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	return http_request;
}

function getAjaxMap(mapid,element) {
	jrequest = getHttpRequest();
    jrequest.onreadystatechange = alertContents;
  //  alert(url + "/index2.php?option=com_jleague&page=getTeamGames&no_html=1&teamid=" + teamid + "&season=" + season);
  //  request.open('GET', url + "/index2.php?option=com_jleague&page=getTeamGames&no_html=1&teamid=" + teamid + "&season=" + season, true);
  alert('index2.php?option=com_gmapspro&task=getajaxmap&no_html=1&map_id=' + mapid);
    jrequest.open('GET','index2.php?option=com_gmapspro&task=getajaxmap&no_html=1&map_id=' + mapid,true);
    jrequest.send(null);	
}

function alertContents() {
	http_request = jrequest;
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            result = http_request.responseText;
            document.getElementById('gmaps1').innerHTML = result;            
         } else {
            alert('There was a problem with the request.');
         }
      }
}
*/