		var map = null;
    	var mgr = null;
		var geocoder;
		var baseIcon;
		
		//used to fix flickering issue
		var infoWindowOpen = false;
		var t = null;
		var currIndex = 1;
		var t;
		var detailPage = false;
		
		//
		var bounds;
		var sumLat = 0;
		var sumLng = 0;
		var mkrCount = 0;
		
		// necessary for showMarkerBubble() to work properly
		var markers = new Array();
		
		function initialize(lat, long) {

			//icon initialization
    		baseIcon = new GIcon(G_DEFAULT_ICON);
	        baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
	        baseIcon.iconSize = new GSize(20, 34);
	        baseIcon.shadowSize = new GSize(37, 34);
	        baseIcon.iconAnchor = new GPoint(9, 34);
	        baseIcon.infoWindowAnchor = new GPoint(9, 2);
			
			if (GBrowserIsCompatible()) {
				map = new GMap2(document.getElementById("map"));
				
				geocoder = new GClientGeocoder();

				map.setCenter(new GLatLng(lat,long), 6);
        		map.setUIToDefault();	
				
				mgr = new MarkerManager(map);
				
				bounds = new GLatLngBounds();	
			}
    	}
		
		function markerBubble(marker, index){
			if (!detailPage) {
				GEvent.addListener(marker, "mouseover", function(){
					if (t) {
						clearTimeout(t);
					}
					
					marker.openInfoWindowHtml(html[index - 1]);
					document.getElementById("listing_id_" + index).style.background = '#dedede';
					
					
					if (index != currIndex) {
						document.getElementById("listing_id_" + currIndex).style.background = '#ffffff';
					}
				});
				
				GEvent.addListener(marker, "mouseout", function(){
					t = setTimeout('map.closeInfoWindow();resetBG(' + index + ');', 5000);
					
					currIndex = index;
				});
			} 
			else {
				GEvent.addListener(marker, "mouseover", function() {
					marker.openInfoWindow(html[index -1]);
				});
				
				GEvent.addListener(marker, "mouseout", function() {
					t = setTimeout('map.closeInfoWindow();', 5000);
				});
			}
		}
		
		function zoomfit(){
			var newzoom = map.getBoundsZoomLevel(bounds);
			var newcenter = bounds.getCenter();
			if (detailPage) {
				newzoom -= 4;
			}
			map.setCenter(newcenter, newzoom);	
		}	
        function createMarker(point, address, index){
			// Create a lettered icon for this point using our icon class
            var letter = String.fromCharCode("A".charCodeAt(0) + (index - 1));
            var letteredIcon = new GIcon(baseIcon);
            letteredIcon.image = "http://www.google.com/mapfiles/marker" + letter + ".png";
            
            // Set up our GMarkerOptions object
            markerOptions = {
                icon: letteredIcon,
                title: index
            };
            var marker = new GMarker(point, markerOptions);
            
            markerBubble(marker, index);
            
            mgr.addMarker(marker, 0);
            
            if (detailPage) {
                map.setCenter(marker.getLatLng(), 6);
            }
            
            bounds.extend(marker.getLatLng());
            zoomfit();
            
            return marker;
        }
		
		function google_geocoder(address, index, latitude, longitude) {
			if (!geocoder) {
				geocoder = new GCLientGeocoder();
			}
			
			//Start geocoding
			geocoder.getLatLng(address, function(point){
				if (!point) {
					//handle error
				}
				else {
					var lat = point.lat();
					var lng = point.lng();
					
					var marker = createMarker(point, address, index);
					
					map.setCenter(point, 6);
				}
			});
		}
		
		//MTech
		function jsonp(url,callbackName,query)
		{                
			url+='?callback='+callbackName+'&'+(new Hash(query).toQueryString())+"&"+(new Date().getTime().toString());
			var script = document.createElement("script");        		
			script.setAttribute("src",url);
			script.setAttribute("type","text/javascript");                
			document.body.appendChild(script);
		}
		
		function callback(result) {
			var marker = createMarker(new GLatLng(result.latitude, result.longitude), result.address, result.id);
			
			// necessary for showMarkerBubble() to work properly
			markers.push(marker);
		}
		
		function resetBG(index){
			if (map.isLoaded() && document.getElementById("listing_id_" + currIndex) != null) {
				document.getElementById("listing_id_" + index).style.background = '#ffffff';
			}
		}	
			
		function showMarkerBubble(index) {
			if (map.isLoaded() && document.getElementById("listing_id_" + currIndex) != null) {
				if (t) {
					clearTimeout(t);
				}
				
				if ((!infoWindowOpen || (index != currIndex)) && markers[index - 1] != null) {
					//	alert(index)
					markers[index - 1].openInfoWindowHtml(html[index - 1]);
					document.getElementById("listing_id_" + index).style.background = '#dedede';
				}
				
				if (index != currIndex) {
					document.getElementById("listing_id_" + currIndex).style.background = '#ffffff';
				}
				
				infoWindowOpen = true;
			}
		}
		
		function closeMarkerBubble(index) {
			if (infoWindowOpen) {
				var succeeded = false;
				t = setTimeout('map.closeInfoWindow();infoWindowOpen = false;succeeded = true;resetBG(' + index + ');', 2000);
			} 
			currIndex = index;
		}

		
		
		
		
	 
		