	$.GoogleMap = new Object();
	$.GoogleMap.map;
	$.GoogleMap.places = [];
	$.GoogleMap.directionsPanel;
	$.GoogleMap.directions;
	$.GoogleMap.startmarker;
	$.GoogleMap.gmarkers = [];
	$.GoogleMap.markerBounds;
	$.GoogleMap.showInfowindow = 0;
	$.GoogleMap.fixAddress = 0;
	$.GoogleMap.markerLabel;
	$.GoogleMap.previous_whichDetails = 0;
	$.GoogleMap.previous_whichDetails_unhighlight = 0;
	
	$.GoogleMap.imageDirectory = "http://media3.washingtonpost.com/wp-srv/gog/images/maps/";
	$.GoogleMap.starsDirectory = "http://media3.washingtonpost.com/wp-srv/gog/images/maps/";
	$.GoogleMap.drivingDirectionsURL = "/gog/driving-directions.html";
	
	document.write('<'+'script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=' + GOOGLE_API_KEY + '" type="text/javascript">' + '<'+'/script>');
	$(document).ready(function() {
		$("a[href=#highlight-on-map]").bind('click', function(){
				showOnMap($(this).attr('dataid'));
				//alert();
			});
	});
	
	function initMap()
	{
		loadMap();
	}
	
	function loadMap(whichMap)
	{

		if (GBrowserIsCompatible())
		{
			$.GoogleMap.map = new GMap2(document.getElementById("cgMap"));		// COMMENT: declare the map
			$.GoogleMap.map.setCenter(new GLatLng(38.889813, -77.008067), 12);
			$.GoogleMap.markerBounds = new GLatLngBounds();
			setCGParams();
			placeData();
			//if profile page, map is not pannable but clickable to "enlarge map"
			if ($.GoogleMap.pannable!=undefined&&!$.GoogleMap.pannable){
				$.GoogleMap.map.disableDragging();
			}
		}
		else
		{
			alert("Your browser is not compatible with Going Out Guide.  Please upgrade, thanks!");
		}
	}	


	function directions(i, j, whichDirection)
	{
		var html = "";
		html = "<div id=\"info-amenities\">";
		if ($.GoogleMap.places[i].length > 1)
		{//alert("creating a combo info window. length = '"  + $.GoogleMap.places[i].length + "'");
			html += "  <div class=\"combo-list\">";
			html += "    <div class=\"tiptext\">There are <span class=\"alert\">" + $.GoogleMap.places[i].length + "</span> listings at this address:</div>";
			html += "    <div class=\"selector\">";
			html += "      <div class=\"heightBlock\">";
			html += "        <div id=\"details_" + i + "\" class=\"options\">";
			for (var k = 0; k < $.GoogleMap.places[i].length; k++)
			{
				if (k == j)
				{
					html += "<span id=\"combo" + i + "_" + k + "\" class=\"unselected\" onmouseover=\"flipDetails(" + i + ", " + k + ");\">" + $.GoogleMap.places[i][k].name + "</span>";				
				}
				else
				{
					html += "<span id=\"combo" + i + "_" + k + "\" class=\"unselected\" onmouseover=\"flipDetails(" + i + ", " + k + ");\">" + $.GoogleMap.places[i][k].name + "</span>";
				}
			}
			html += "        </div>";
			html += "      </div>";
			html += "    </div>";
			html += "    <div class=\"heightblock\">";
			html += "      <div id=\"combo_details\" class=\"combo-detail\">";
		}
		else
		{
		//	html += "      <div id=\"combo_details\" class=\"single\">";
		}

		html += "<div style=\"width:280px;\">";
		if ($.GoogleMap.places[i][j].type != undefined)
		{
			html += "  <div id=\"infoWin-type\" class=\"res_kicker\"><b>" + $.GoogleMap.places[i][j].type + "</b></div>";
		}
		html += "  <div id=\"infoWin-name\" class=\"res_name\"><a href=\"" + $.GoogleMap.places[i][j].profileURL + "\">" + $.GoogleMap.places[i][j].name + "</a></div>";
		html += "  <div id=\"infoWin-address\" class=\"res_address\">" + $.GoogleMap.places[i][j].address + ", " + $.GoogleMap.places[i][j].city + ", " + $.GoogleMap.places[i][j].state + " " + $.GoogleMap.places[i][j].zip + " <br>  " + $.GoogleMap.places[i][j].phone + "</div>";
		if ($.GoogleMap.places[i][j].summary != undefined)
		{
			html += "  <div id=\"infoWin-teaser\" class=\"res_copy\">" + $.GoogleMap.places[i][j].summary + "</div>";
		}		
		if ($.GoogleMap.places[i][j].stars != undefined && $.GoogleMap.places[i][j].stars != "")
		{
			html += "  <div id=\"infoWin-rating\" class=\"reader_rated\">Average Reader Rating: <img src=\"" + $.GoogleMap.starsDirectory + "stars_" + $.GoogleMap.places[i][j].stars + "_sr.gif\" alt=\"\" border=\"0\" height=\"8\" width=\"35\"></div>";
		}
		switch (whichDirection)
		{
			case "to" :
				html += "  <div id=\"infoWin-directions\" class=\"res_directions\"><b>Directions:</b> <b>To Here</b> &nbsp;|&nbsp; <a href=\"javascript:void(0);\" onclick=\"return directions(" + i + ", " + j + ", 'from');\"\">From Here</a></div>";
				break;
			case "from" :
				html += "  <div id=\"infoWin-directions\" class=\"res_directions\"><b>Directions:</b> <a href=\"javascript:void(0);\" onclick=\"return directions(" + i + ", " + j + ", 'to');\"\">To Here</a> &nbsp;|&nbsp; <b>From Here</b></div>";
				break;
		}
		html += "  <div id=\"infoWin-directionsForm\">";
		html += "    <form action=\"" + $.GoogleMap.drivingDirectionsURL + "\" method=\"get\" name=\"driveDirect\" style=\"margin:0;padding:0;\" onsubmit=\"return checkInfoAddressForm();\">";
		html += "    <input name=\"mode\" type=\"hidden\" value=\"directions\">";
		switch (whichDirection)
		{
			case "to" :
				html += "      <div id=\"infoWin-startEnd\" style=\"font-family:arial;font-size:11px;font-weight:bold;color:#666666;\">Start Address:</div>";
				break;
			case "from" :
				html += "      <div id=\"infoWin-startEnd\" style=\"font-family:arial;font-size:11px;font-weight:bold;color:#666666;\">End Address:</div>";
				break;
		}
		html += "      <div id=\"infoWin-inputField\">";
		html += "		 <input name=\"id\" type=\"hidden\" value=\"" + $.GoogleMap.places[i][j].id + "\">";
		switch (whichDirection)
		{
			case "to" :
				html += "		 <input name=\"direction\" type=\"hidden\" value=\"To\">";
				break;
			case "from" :
				html += "		 <input name=\"direction\" type=\"hidden\" value=\"From\">";
				break;
		}		
		html += "        <input id=\"address\" name=\"address\" type=\"text\" style=\"width:260px;\" />";		
		html += "      </div>";
		html += "      <div style=\"margin-top:3px;\">";
		
		html += "        <div class=\"border-light-2px button-darkgrey tabs\">";
		html += "       	 <h5 class=\"position-center\"><a href=\"#\" class=\"info-window-submit-button\" value=\"Submit\">Get Directions</a></h5>";
		html += "        	<div class=\"shade ctr6-2px\">&nbsp;</div>";
		html += "        	<div class=\"shade ctl6-2px\">&nbsp;</div>";
		html += "        	<div class=\"shade cbr6-2px\">&nbsp;</div>";
		html += "        	<div class=\"shade cbl6-2px\">&nbsp;</div>";
		html += "      	 </div>";
		
		html += "      </div>";
		html += "    </form>";
		html += "  </div>";
		html += "</div>";

		if ($.GoogleMap.places[i].length > 1)
		{
			html += "      </div>";
			html += "    </div>";
			html += "    <div class=\"break\"></div>";
			html += "  </div>";
		}											
		else
		{
		//	html += "      </div>";
			html += "    <div id=\"combo_details\" class=\"single\">";
		}
		html += "</div>";

		$.GoogleMap.gmarkers[i].marker.openInfoWindowHtml(html);
		$("a.info-window-submit-button").bind("click", function(event){
			if (checkInfoAddressForm()){
			   $(this).parents('form').submit();
			   return false;
			}
			return false;
	 	});		
		if ( $.browser.msie && $.browser.version=="6.0" ){
			$("#info-amenities .button-darkgrey").hover(function() {
				$(this).addClass("hover");
			},function(){
				$(this).removeClass("hover");
			});
		}			
	//	document.getElementById($.GoogleMap.places[i][j].id).style.backgroundColor="#e7f0f9"; 
		return false;
	}	
	


	function directionsStart(whichDirection)
	{

		var html = "";

		html += "<div style=\"width:280px;\">";		
		if ($.GoogleMap.start.type != undefined)
		{
			html += "  <div id=\"infoWin-type\" class=\"res_kicker\"><b>" + $.GoogleMap.start.type + "</b></div>";
		}
		html += "  <div id=\"infoWin-name\" class=\"res_name\"><a href=\"" + $.GoogleMap.start.profileURL + "\">" + $.GoogleMap.start.name + "</a></div>";
		html += "  <div id=\"infoWin-address\" class=\"res_address\">" + $.GoogleMap.start.address + ", " + $.GoogleMap.start.city + ", " + $.GoogleMap.start.state + " " + $.GoogleMap.start.zip+"\&nbsp;";
		if ($.GoogleMap.start.phone != "")
		{
			html += " <br>" + $.GoogleMap.start.phone + "</div>";
		}
		else
		{
			html += "</div>";
		}
		if (start.summary != undefined)
		{
			html += "  <div id=\"infoWin-teaser\" class=\"res_copy\">" + $.GoogleMap.start.summary + "</div>";
		}
		if ($.GoogleMap.start.stars != undefined && $.GoogleMap.start.stars != "")
		{
			html += "  <div id=\"infoWin-rating\" class=\"reader_rated\">Average Reader Rating: <img src=\"" + $.GoogleMap.starsDirectory + "stars_" + $.GoogleMap.start.stars + "_sr.gif\" alt=\"\" border=\"0\" height=\"8\" width=\"35\"></div>";
		}

		switch (whichDirection)
		{
			case "to" :
				html += "  <div id=\"infoWin-directions\" class=\"res_directions\"><b>Directions:</b> <b>To Here</b> &nbsp;|&nbsp; <a href=\"javascript:void(0);\" onclick=\"return directionsStart('from');\"\">From Here</a></div>";
				break;
			case "from" :
				html += "  <div id=\"infoWin-directions\" class=\"res_directions\"><b>Directions:</b> <a href=\"javascript:void(0);\" onclick=\"return directionsStart('to');\"\">To Here</a> &nbsp;|&nbsp; <b>From Here</b></div>";
				break;
		}
		html += "  <div id=\"infoWin-directionsForm\">";
		html += "    <form action=\"" + $.GoogleMap.drivingDirectionsURL + "\" method=\"get\" name=\"driveDirect\" style=\"margin:0;padding:0;\" onsubmit=\"return checkInfoAddressForm(); \">";
		html += "    <input name=\"mode\" type=\"hidden\" value=\"directions\">";
		switch (whichDirection)
		{
			case "to" :
				html += "      <div id=\"infoWin-startEnd\" style=\"font-family:arial;font-size:11px;font-weight:bold;color:#666666;\">Start Address:</div>";
				break;
			case "from" :
				html += "      <div id=\"infoWin-startEnd\" style=\"font-family:arial;font-size:11px;font-weight:bold;color:#666666;\">End Address:</div>";
				break;
		}
		html += "      <div id=\"infoWin-inputField\">";
		html += "		 <input name=\"id\" type=\"hidden\" value=\"" + $.GoogleMap.start.id + "\">";
		switch (whichDirection)
		{
			case "to" :
				html += "		 <input name=\"direction\" type=\"hidden\" value=\"To\">";
				break;
			case "from" :
				html += "		 <input name=\"direction\" type=\"hidden\" value=\"From\">";
				break;
		}		
		html += "        <input id=\"address\" name=\"address\" type=\"text\" style=\"width:260px;\" />";		
		html += "      </div>";
		html += "      <div style=\"margin-top:3px;\">";
		html += "        <input name=\"submit\" type=\"submit\" value=\"Get Directions\" />";
		html += "      </div>";
		html += "    </form>";
		html += "  </div>";
		html += "</div>";

		html += "  </div>";	

		html += "</div>";

		$.GoogleMap.startmarker.openInfoWindowHtml(html);
		return false;
	}


	function createMarker(i)
	{
		var icon = new GIcon();
		if ($.GoogleMap.places[i].length > 1)
		{
			icon.image = $.GoogleMap.imageDirectory + "marker_combo" + $.GoogleMap.places[i].length + ".png";
			icon.shadow = $.GoogleMap.imageDirectory + "shadow_combo.png";					 		
			icon.iconSize = new GSize(26, 45);
			shadowSize = new GSize(64, 45);
		}
		else
		{
			icon.image = $.GoogleMap.imageDirectory + "info-marker.png"
			icon.shadow = $.GoogleMap.imageDirectory + "info-shadow.png";				
			icon.iconSize = new GSize(19, 33);
			icon.shadowSize = new GSize(36, 33);
		}	
		icon.iconAnchor = new GPoint(10, 33);
		icon.infoWindowAnchor = new GPoint(8, 14);
		
		var point = new GLatLng($.GoogleMap.places[i][0].lat, $.GoogleMap.places[i][0].lon);
		$.GoogleMap.markerBounds.extend(point);

		var marker = new GMarker(point, {icon:icon, zIndexProcess:importanceOrder});
		marker.importance = 1;
		$.GoogleMap.gmarkers[i] = [];
				
		for (var j = 0; j < $.GoogleMap.places[i].length; j++)
		{

			$.GoogleMap.gmarkers[i][j] = new Object();

			$.GoogleMap.gmarkers[i][j].html = "<div style=\"width:280px;\">";		
			if ($.GoogleMap.places[i][j].type != undefined)
			{
				$.GoogleMap.gmarkers[i][j].html += "  <div id=\"infoWin-type\" class=\"res_kicker\"><b>" + $.GoogleMap.places[i][j].type + "</b></div>";
			}
			$.GoogleMap.gmarkers[i][j].html += "  <div id=\"infoWin-name\" class=\"res_name\"><a href=\"" + $.GoogleMap.places[i][j].profileURL + "\">" + $.GoogleMap.places[i][j].name + "</a></div>";
			$.GoogleMap.gmarkers[i][j].html += "  <div id=\"infoWin-address\" class=\"res_address\">" + $.GoogleMap.places[i][j].address + ", " + $.GoogleMap.places[i][j].city + ", " + $.GoogleMap.places[i][j].state + " " + $.GoogleMap.places[i][j].zip+"\&nbsp;";
			if ($.GoogleMap.places[i][j].phone != "")
			{
				$.GoogleMap.gmarkers[i][j].html += " <br> " + $.GoogleMap.places[i][j].phone + "</div>";
			}
			else
			{
				$.GoogleMap.gmarkers[i][j].html += "</div>";
			}
		
			if ( $.GoogleMap.places[i][j].summary != undefined)
			{
				$.GoogleMap.gmarkers[i][j].html += "  <div id=\"infoWin-teaser\" class=\"res_copy\">" + $.GoogleMap.places[i][j].summary + "</div>";
			}
			if ($.GoogleMap.places[i][j].stars != undefined && $.GoogleMap.places[i][j].stars != "")
			{
				$.GoogleMap.gmarkers[i][j].html += "  <div id=\"infoWin-rating\" class=\"reader_rated\">Average Reader Rating: <img src=\"" + $.GoogleMap.starsDirectory + "stars_" + $.GoogleMap.places[i][j].stars + "_sr.gif\" alt=\"\" border=\"0\" height=\"8\" width=\"35\"></div>";
			}
			$.GoogleMap.gmarkers[i][j].html += "  <div id=\"infoWin-directions\" class=\"res_directions\"><b>Directions:</b> <a href=\"javascript:void(0);\" onclick=\"return directions(" + i + ", " + j + ", 'to');\"\">To Here</a> &nbsp;|&nbsp; <a href=\"javascript:void(0);\" onclick=\"return directions(" + i + ", " + j + ", 'from');\"\">From Here</a></div>";
			$.GoogleMap.gmarkers[i][j].html += "  </div>";	

		}	// end for (var j = 0; j < $.GoogleMap.places[i].length; j++)
//alert(i + ", " + j + " html<br><br>" +html);
		var html = "";
		html = "<div id=\"info-amenities\">";
		if ($.GoogleMap.places[i].length > 1)
		{
			html += "  <div class=\"combo-list\">";
			html += "    <div class=\"tiptext\">There are <span class=\"alert\">" + $.GoogleMap.places[i].length + "</span> listings at this address:</div>";
			html += "    <div class=\"selector\">";
			html += "      <div class=\"heightBlock\">";
			html += "        <div id=\"details_" + i + "\" class=\"options\">";
			for (var k = 0; k < $.GoogleMap.places[i].length; k++)
			{
				if (k == 0)
				{
					html += "<span id=\"combo" + i + "_" + k + "\" class=\"unselected\" onmouseover=\"flipDetails(" + i + ", " + k + ");\">" + $.GoogleMap.places[i][k].name + "</span>";				
				}
				else
				{
					html += "<span id=\"combo" + i + "_" + k + "\" class=\"unselected\" onmouseover=\"flipDetails(" + i + ", " + k + ");\">" + $.GoogleMap.places[i][k].name + "</span>";
				}
			}
			html += "        </div>";
			html += "      </div>";
			html += "    </div>";
			html += "    <div class=\"heightblock\">";
			html += "      <div id=\"combo_details\" class=\"combo-detail\">";
		}
		else
		{
		//	html += "      <div id=\"combo_details\" class=\"single\">";
		}
		html += $.GoogleMap.gmarkers[i][0].html;
		if ($.GoogleMap.places[i].length > 1)
		{
			html += "      </div>";
			html += "    </div>";
			html += "    <div class=\"break\"></div>";
			html += "  </div>";
		}											
		else
		{
		//	html += "      </div>";
			html += "    <div id=\"combo_details\" class=\"single\">";
		}
		html += "</div>";
//alert(i + ", " + j + " html<br><br>" +html);

		GEvent.addListener(marker, "click", function()
		{
			if ($.GoogleMap.showInfowindow)
			{	
					//alert("previous_whichDetails: " +$.GoogleMap.previous_whichDetails);
				$.GoogleMap.previous_whichDetails_unhighlight = $.GoogleMap.previous_whichDetails;			
				$.GoogleMap.previous_whichDetails = 0;		
				marker.openInfoWindowHtml(html);
				flipDetails(i, 0);
			}
		});			

		GEvent.addListener(marker, "infowindowbeforeclose", function()
		{
			//alert("previous_whichDetails_unhighlight: " +$.GoogleMap.previous_whichDetails_unhighlight);
			if ($.GoogleMap.previous_whichDetails_unhighlight > 0 )
			{
				$.GoogleMap.previous_whichDetails = $.GoogleMap.previous_whichDetails_unhighlight;
				$.GoogleMap.previous_whichDetails_unhighlight = 0;
			}
			
			//
			//alert("looking for this id: " + $.GoogleMap.places[i][$.GoogleMap.previous_whichDetails].id);
			//klb unhighlight the item in the search results list
			//document.getElementById($.GoogleMap.places[i][$.GoogleMap.previous_whichDetails].id).style.backgroundColor="#ffffff";
			
			$.GoogleMap.previous_whichDetails = 0;
		});

		GEvent.addListener(marker, "moveend", function()
		{
		});

		GEvent.addListener(marker, "mouseover", function()
		{	
			
			if ($.GoogleMap.whichMap !=  "profile"){
				if ($.GoogleMap.places[i].length > 1)
				{
					var text = "<div id=\"marker\"><nobr>There are " + $.GoogleMap.places[i].length + " listings at this address.</nobr></div>";
					markerLabel = new ELabel(point, text);
					markerLabel.pixelOffset=new GSize(14,-35);
					$.GoogleMap.map.addOverlay(markerLabel);
					marker.setImage($.GoogleMap.imageDirectory + "marker_combo" + $.GoogleMap.places[i].length + "-hover.png");
				}
				else
				{
					var text = "<div id=\"marker\"><nobr>" + $.GoogleMap.places[i][0].name + "</nobr></div>";
					markerLabel = new ELabel(point, text);
					markerLabel.pixelOffset=new GSize(14,-35);
					$.GoogleMap.map.addOverlay(markerLabel);
					marker.setImage($.GoogleMap.imageDirectory + "info-marker-hover.png"); // change graphic
									
				}
			}
		});

		GEvent.addListener(marker, "mouseout", function()
		{
			if ($.GoogleMap.whichMap !=  "profile"){
				if ($.GoogleMap.places[i].length > 1)
				{
					markerLabel.hide();
					$.GoogleMap.map.removeOverlay(markerLabel);
					marker.setImage($.GoogleMap.imageDirectory + "marker_combo" + $.GoogleMap.places[i].length + ".png");
				}else{
					markerLabel.hide();
					$.GoogleMap.map.removeOverlay(markerLabel);
					marker.setImage($.GoogleMap.imageDirectory + "info-marker.png"); // change graphic
				}
			}
		});

		$.GoogleMap.gmarkers[i].marker = marker
		return marker;

	}

	function flipDetails(which1, which2)
	{//alert(which1 + ", " + which2);
		if ($.GoogleMap.places[which1].length > 1)
		{
			if (document.getElementById("combo" + which1 + "_" + $.GoogleMap.previous_whichDetails)!=null){
				document.getElementById("combo" + which1 + "_" + $.GoogleMap.previous_whichDetails).className = "unselected";
			}
			//klb
			// this will unhighlight the row in the search results list
			//document.getElementById($.GoogleMap.places[which1][$.GoogleMap.previous_whichDetails].id).style.backgroundColor="#ffffff";
			if (document.getElementById("combo" + which1 + "_" + which2) != null) {
				document.getElementById("combo" + which1 + "_" + which2).className = "selected";
			}
			$.GoogleMap.previous_whichDetails = which2;
			if (document.getElementById("combo_details") != null) {
				document.getElementById("combo_details").innerHTML = $.GoogleMap.gmarkers[which1][which2].html;
			}
		}
		
		//klb:
		// This line will highlight the item in the search results  Do we need this?  
		// commenting out for testing
		//document.getElementById($.GoogleMap.places[which1][which2].id).style.backgroundColor="#e7f0f9";

	}

	// FUNCTION: when a user clicks on the item in the list view, load the correct infowindow (and combo item if applicable)
    function showOnMap(id)
    {
		for (var i = 0; i < $.GoogleMap.places.length; i++)
		{
			for (var j = 0; j < $.GoogleMap.places[i].length; j++)
			{
				if ($.GoogleMap.places[i][j].id == id)
				{
					GEvent.trigger($.GoogleMap.gmarkers[i].marker,"click");
					flipDetails(i, j);
				}	// end if ($.GoogleMap.places[i][j].id == id)
			}	// end for (var j = 0; j < $.GoogleMap.places[j].length; j++)
		}	// end for (var i = 0; i < $.GoogleMap.places[i].length; i++)
    }

	function centerMap()
	{
	//	if (map.getBoundsZoomLevel(markerBounds) < 14)
	//	{
			$.GoogleMap.map.setZoom(($.GoogleMap.map.getBoundsZoomLevel($.GoogleMap.markerBounds)));
	//	}
	//	else
	//	{
	//		map.setZoom(14);
	//	}
		var clat = ($.GoogleMap.markerBounds.getNorthEast().lat() + $.GoogleMap.markerBounds.getSouthWest().lat()) /2;
		var clng = ($.GoogleMap.markerBounds.getNorthEast().lng() + $.GoogleMap.markerBounds.getSouthWest().lng()) /2;
		$.GoogleMap.map.setCenter(new GLatLng(clat,clng));
	}
	
	function centerProfileMap()
	{
		
		$.GoogleMap.map.setZoom(($.GoogleMap.map.getBoundsZoomLevel($.GoogleMap.markerBounds)));		
		var clat = ($.GoogleMap.markerBounds.getNorthEast().lat() + $.GoogleMap.markerBounds.getSouthWest().lat()) /2;
		var clng = ($.GoogleMap.markerBounds.getNorthEast().lng() + $.GoogleMap.markerBounds.getSouthWest().lng()) /2;		
		$.GoogleMap.map.setCenter(new GLatLng(clat,clng),15);
	}
	

	function addMarkers()
	{

		for (var i = 0; i < $.GoogleMap.places.length; i++)
		{
			$.GoogleMap.map.addOverlay(createMarker(i));
		}

	}
	
	// Used by the "What's Nearby" map only
	function addStart()
	{

		var icon = new GIcon();
		
		icon.image = $.GoogleMap.imageDirectory + "mapStart.png";
		icon.shadow = $.GoogleMap.imageDirectory + "mapStart-shadow.png";	// COMMENT: icon size is 43width x 30height
		icon.shadowSize = new GSize(44, 26);
		icon.iconSize = new GSize(25, 33);
		icon.iconAnchor = new GPoint(12, 30);
		icon.infoWindowAnchor = new GPoint(12, 15);

		var point = new GLatLng($.GoogleMap.start.lat, $.GoogleMap.start.lon);
		$.GoogleMap.markerBounds.extend(point);

		var marker = new GMarker(point, {icon:icon, zIndexProcess:importanceOrder});
		marker.importance = 1;

		var html = "";

		html += "<div style=\"width:280px;\">";		
		if ($.GoogleMap.start.type != undefined)
		{
			html += "  <div id=\"infoWin-type\" class=\"res_kicker\"><b>" + $.GoogleMap.start.type + "</b></div>";
		}
		html += "  <div id=\"infoWin-name\" class=\"res_name\"><a href=\"" + $.GoogleMap.start.profileURL + "\">" + $.GoogleMap.start.name + "</a></div>";
		html += "  <div id=\"infoWin-address\" class=\"res_address\">" + $.GoogleMap.start.address + ", " + $.GoogleMap.start.city + ", " + $.GoogleMap.start.state + " " + $.GoogleMap.start.zip+"\&nbsp;";
		if ($.GoogleMap.start.phone != "")
		{
			html += " <br>" + $.GoogleMap.start.phone + "</div>";
		}
		else
		{
			html += "</div>";
		}
		if ($.GoogleMap.start.summary != undefined)
		{
			html += "  <div id=\"infoWin-teaser\" class=\"res_copy\">" + $.GoogleMap.start.summary + "</div>";
		}
		if ($.GoogleMap.start.stars != undefined && $.GoogleMap.start.stars != "")
		{
			html += "  <div id=\"infoWin-rating\" class=\"reader_rated\">Average Reader Rating: <img src=\"" + $.GoogleMap.starsDirectory + "stars_" + $.GoogleMap.start.stars + "_sr.gif\" alt=\"\" border=\"0\" height=\"8\" width=\"35\"></div>";
		}
		html += "  <div id=\"infoWin-directions\" class=\"res_directions\"><b>Directions:</b> <a href=\"javascript:void(0);\" onclick=\"return directionsStart('to');\"\">To Here</a> &nbsp;|&nbsp; <a href=\"javascript:void(0);\" onclick=\"return directionsStart('from');\"\">From Here</a></div>";
		html += "  </div>";	

		GEvent.addListener(marker, "click", function()
		{
			if ($.GoogleMap.showInfowindow)
			{
				marker.openInfoWindowHtml(html);
				//document.getElementById($.GoogleMap.places[i][j].id).style.backgroundColor="#e7f0f9";
			}
		});			

		GEvent.addListener(marker, "mouseover", function()
		{
			var text = "<div id=\"marker\"><nobr>" + start.name + "</nobr></div>";
			markerLabel = new ELabel(point, text);
			markerLabel.pixelOffset=new GSize(14,-35);
			$.GoogleMap.map.addOverlay(markerLabel);
		});

		GEvent.addListener(marker, "mouseout", function()
		{
			markerLabel.hide();
			$.GoogleMap.map.removeOverlay(markerLabel);
		});

		$.GoogleMap.startmarker = marker;

		$.GoogleMap.map.addOverlay($.GoogleMap.startmarker);
	}
	function placeData()
	{  
		switch ($.GoogleMap.whichMap)
		{
			case "profile" :
				$.GoogleMap.showInfowindow = 0;
				addMarkers();
				centerProfileMap();
				break;
			case "profile-map" :
				$.GoogleMap.map.addControl(new GSmallMapControl());	// COMMENT: map controls (zoom, northsoutheastwest, home)
				$.GoogleMap.map.enableDoubleClickZoom();			// COMMENT: allow double click zooming
				$.GoogleMap.map.enableContinuousZoom();				// COMMENT: allow continous zooming
				$.GoogleMap.showInfowindow = 0;
				addMarkers();
				centerProfileMap();
				break;
			case "search-map" :
				$.GoogleMap.map.addControl(new GSmallMapControl());	// COMMENT: map controls (zoom, northsoutheastwest, home)
				$.GoogleMap.map.enableDoubleClickZoom();			// COMMENT: allow double click zooming
				$.GoogleMap.map.enableContinuousZoom();				// COMMENT: allow continous zooming
				$.GoogleMap.showInfowindow = 1;
				addMarkers();
				centerMap();
				break;
			case "search-nearby" :
				$.GoogleMap.map.addControl(new GSmallMapControl());	// COMMENT: map controls (zoom, northsoutheastwest, home)
				$.GoogleMap.map.enableDoubleClickZoom();			// COMMENT: allow double click zooming
				$.GoogleMap.map.enableContinuousZoom();				// COMMENT: allow continous zooming
				$.GoogleMap.showInfowindow = 1;
				addStart();
				addMarkers();				
				centerMap();
				break;
			case "directions" :
				$.GoogleMap.map.addControl(new GSmallMapControl());					// COMMENT: map controls (zoom, northsoutheastwest, home)
				$.GoogleMap.map.enableDoubleClickZoom();		// COMMENT: allow double click zooming
				$.GoogleMap.map.enableContinuousZoom();			// COMMENT: allow continous zooming
				switch($.GoogleMap.fixAddress)
				{
					case 0:
					//	var directionsFromTo = "1515 North Courthouse Road, Arlington, Virginia 22201 to 6502 Nightwind Court, Alexandria, Virginia 22312";	// SAMPLE CORRECT DIRECTIONS
						//var directionsFromTo = $.GoogleMap.places[0].address + ", " + $.GoogleMap.places[0].city + ", " + $.GoogleMap.places[0].state + " " + $.GoogleMap.places[0].zip + " to " + $.GoogleMap.places[1].address + ", " + $.GoogleMap.places[1].city + ", " + $.GoogleMap.places[1].state + " " + $.GoogleMap.places[1].zip;
						var directionsFromTo = $.GoogleMap.places[0].completeAddress+ " to " + $.GoogleMap.places[1].completeAddress;
						$.GoogleMap.directionsPanel = document.getElementById("cg_textdirections");
						$.GoogleMap.directions = new GDirections($.GoogleMap.map, $.GoogleMap.directionsPanel);
						break;
					case 1:						
						directionsFromTo = document.getElementById("le_directions_error_from").value + " to " + document.getElementById("le_directions_error_to").value;
						//directionsPanel = document.getElementById("cg_textdirections");
						//directions = new GDirections(map, directionsPanel);
						break;
				}
  				$.GoogleMap.directions.load(directionsFromTo);
  				
  				GEvent.addListener($.GoogleMap.directions, "load", onGDirectionsLoad);
        		GEvent.addListener($.GoogleMap.directions, "error", handleErrors);
				break;
			default :
				alert("Invalid map type.");
				break;
		}
		return false;
	}
	function onGDirectionsLoad(){
	//nothing is needed here for now
	//alert("directions loaded");
	//alert("Status Code: " + $.GoogleMap.directions.getStatus().code);
	}

   function handleErrors()
   {

		if ($.GoogleMap.directions.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
		{
			//alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + directions.getStatus().code);
			switch($.GoogleMap.fixAddress)
			{
				case 0:
					document.getElementById("le_directions_error").className = "show";
					document.getElementById("le_directions_error_from").value = $.GoogleMap.places[0].completeAddress;
					document.getElementById("le_directions_error_to").value = $.GoogleMap.places[1].completeAddress;
					$.GoogleMap.fixAddress = 1;
					break;
				case 1:
					document.getElementById("le_directions_error").className = "show";
					break;
			}
		}
		else
		{
			//alert("An unknown error occurred.");
			console.log("An unknown error occurred.");
		}
	}	// end function handleErrors()

	function importanceOrder (marker,b)
	{
		return GOverlay.getZIndex(marker.getPoint().lat()) + marker.importance*1000000;
	}
	
	
// Driving directions form in profile-location.jsp
// To

function toClearAddress() {
	if(document.getElementById("to-address").value == "Address"){
		document.getElementById("to-address").value = "";
	}
}


function toCheckDirectionForm() {

	if (document.getElementById("to-address").value == "Address" || document.getElementById("to-address").value == "")
	{
		alert("Please enter an address");
		return false;
	}
	else 
	{

	return true; 
	}

}


// From


function fromClearAddress() {
	if(document.getElementById("from-address").value == "Address"){
		document.getElementById("from-address").value = "";
	}
}

function fromCheckDirectionForm() {

	if ( document.getElementById("from-address").value == "Address" || document.getElementById("from-address").value == "" )
	{
		alert("Please enter an address");
		return false;
	}
	else 
	{


	return true; 
	}

}

// Nearby Form

function clearOther(){			
	document.getElementById("gog-query").value = "";		
}
	
function checkOtherForm(){

	if (document.getElementById("gog-query").value == "e.g., metro" || document.getElementById("gog-query").value.length < 1)
	{
		document.getElementById("gog-query").value = "";		
		alert("Please enter a keyword or click on a What's Nearby category.");
		return false;			
	}
				
//	if (document.getElementById("searchTerm").value == "e.g., metro" || document.getElementById("searchTerm").value == "")
//	{
//		document.getElementById("searchTerm").value = "";
//		document.getElementById.lon.value = "";
//		document.getElementById.lat.value = "";												
//		document.getElementById.catName.value = "";
//		document.getElementById.displaySearchLocation.value = "";
//		document.getElementById.mr.value = "";
//		document.getElementById.vert.value = "";
//	} else if (document.getElementById("searchTerm").value != "e.g., metro" && document.getElementById("searchTerm").value != "")
//	{
//		document.getElementById("catName").value = "Other";				
//	}	
}
function checkInfoAddressForm() {
	if ( document.getElementById("address").value == "Address" || document.getElementById("address").value == "" )
	{
		alert("Please enter an address");
		return false;
	}
	return true; 
}

// Tabs

function mapTabs(whichTab){
	if (whichTab == "to")
	{
		$("#to-tab").attr("class", "to dn");
		$("#from-tab").attr("class", "from");
		$("#driving-to-here").attr("class", "directions-form");
		$("#driving-from-here").attr("class", "directions-form noshow");
	}
	if (whichTab == "from")
	{
		$("#to-tab").attr("class", "to");
		$("#from-tab").attr("class", "from dn");
		$("#driving-to-here").attr("class", "directions-form noshow");
		$("#driving-from-here").attr("class", "directions-form");
	}
}
	
function setMapClickable(mapId,url,omnitureType){
	$("#"+mapId).css("cursor","pointer");
	$("#"+mapId).bind("click",function(){
		WPNI.Util.Utility.logEvent("gog",omnitureType);
		window.location=url; 
	});	
}
	