var YahooMapAPIUrl = "http://api.maps.yahoo.com/ajaxymap?v=3.8&appid={0}";

function showYahooMap( theBiz, divID )
{
	// Get coordinates
	var currentGeoPoint = null;
	if( !( isNaN(theBiz.latitude) || isNaN(theBiz.longitude) ) )
		currentGeoPoint = new YGeoPoint( Number(theBiz.latitude), Number(theBiz.longitude) );  

	 // Create a map object  
	 var map = new YMap( document.getElementById( divID ) );

	 // Add map zoom (long) control  
	 map.addZoomLong();  

	 // Add the Pan Control  
	 map.addPanControl();  

	 // Add map type control  
	 map.addTypeControl();  

	 // Set map type to either of: YAHOO_MAP_SAT, YAHOO_MAP_HYB, YAHOO_MAP_REG  
	 map.setMapType( YAHOO_MAP_REG );  

	 // Display the map centered on a geocoded location 
	if( null == currentGeoPoint )
	{
		//alert( "currentGeoPoint is null" );
		map.drawZoomAndCenter( theBiz.getFullAddress(), 3 );
		YEvent.Capture( map, EventsList.onEndGeoCode, addBusinessMarker );
	}
	else
	{
		//alert( "currentGeoPoint not null" );
		map.drawZoomAndCenter( currentGeoPoint, 3 );
		// Add marker
		addBusinessMarker( 
			{ // eventObjectGeoCode's properties
				ThisMap: map, 
				Address: theBiz.getFullAddress(), 
				GeoPoint: currentGeoPoint, 
				success: true 
			}, 
			currentGeoPoint );
	}
}

function addBusinessMarker( _e, _c )
{
	var map = _e.ThisMap;
	
	//alert( "in addBusinessMarker -> " + _e.constructor + "; " + _e.GeoPoint.Lat + "," + _e.GeoPoint.Lon + "; " + _c );
	//alert( "in addBusinessMarker -> map.getCenterLatLon(): " + map.getCenterLatLon() );
	//alert( "in addBusinessMarker -> currentGeoPoint: " + currentGeoPoint );
	
	if( _c == null )
		_c = map.getCenterLatLon();
	
	// Create marker
	var bizMarker = new YMarker( _c, new YImage(), "BizMarker" );
	bizMarker.addAutoExpand( 
		"<div class='BizMarker-Contracted'>"
			+ __theBiz.name.bold() 
			+ "<br /><small>(click to expand)</small>"
		+ "</div>" );
	
	// Enable the ability to show more details
	YEvent.Capture( 
		bizMarker, 
		EventsList.MouseClick, 
		function() {
			bizMarker.openSmartWindow( 
				"<div class='BizMarker-Expanded'>" 
					+ __theBiz.name.bold() 
					+ "<br />" 
					+ __theBiz.address 
					+ "<br />"
					+ __theBiz.getCSZ()
				+ "</div>" );
		}
	);

	// Add the marker
	map.addOverlay( bizMarker );
}
