var map = null;
var geocoder = null;
function load ()
{
	if ( GBrowserIsCompatible () )
	{
		map = new GMap2 ( document.getElementById ( "map" ) );
		map.addControl ( new GSmallMapControl ( ) );
		map.addControl ( new GMapTypeControl ( ) );
		geocoder = new GClientGeocoder ();
	}
	$ ( 'mapWin' ).style.display = 'none';
}
function showAddress ( store_id, address, store_info, company, coordinates )
{
	//alert("ID: " + store_id + ", Info: " + store_info + ", Company: " + company + ", Coordinates: " + coordinates);
	var map_win = $ ( 'mapWin' );
	if	( map_win.style.display == 'none' )
	{
		Effect.Appear ( 'mapWin' );
	}
	if ( document.all )
	{
		new Effect.ScrollTo ( 'Cms_Store_Locator', { queue: { position:'beginning', scope: 'mapWin' } } );
	}
	if ( store_id == "226" )
	{
		var coords = new GLatLng(29.607561, -98.46331);
		map.setCenter ( coords, 13 );
		var marker = new GMarker ( coords );
		map.addOverlay ( marker );
		marker.openInfoWindowHtml ( '<strong>' + company  + '</strong><br />' + address + '<br />' + store_info + '<br /><p><a href="/store' + store_id + '/" title="View ' + company + ' Details">&raquo; View Store Details</a></p><p><a href="http://maps.google.com/maps?oi=map&q=' + address + '" target="_blank" title="Get Google Directions">&raquo; Get Google Directions</a></p>' );
	}
	else if ( store_id == "260" )
	{
		var coords = new GLatLng(41.753079, -88.012862);
		map.setCenter ( coords, 13 );
		var marker = new GMarker ( coords );
		map.addOverlay ( marker );
		marker.openInfoWindowHtml ( '<strong>' + company  + '</strong><br />' + address + '<br />' + store_info + '<br /><p><a href="/store' + store_id + '/" title="View ' + company + ' Details">&raquo; View Store Details</a></p><p><a href="http://maps.google.com/maps?oi=map&q=' + address + '" target="_blank" title="Get Google Directions">&raquo; Get Google Directions</a></p>' );
	}
	else if ( coordinates != "" )
	{
		var coordinates = coordinates.split ( ',' );
		var coords = new GLatLng ( coordinates[0], coordinates[1] );
		map.setCenter ( coords, 13 );
		var marker = new GMarker ( coords );
		map.addOverlay ( marker );
		marker.openInfoWindowHtml ( '<strong>' + company  + '</strong><br />' + address + '<br />' + store_info + '<br /><p><a href="/store' + store_id + '/" title="View ' + company + ' Details">&raquo; View Store Details</a></p><p><a href="http://maps.google.com/maps?oi=map&q=' + address + '" target="_blank" title="Get Google Directions">&raquo; Get Google Directions</a></p>' );
	}
	else if ( geocoder )
	{
		//alert(address);
		//address = '56-11 Marathon Parkway, 11362';
		geocoder.getLatLng ( address, function ( point )
		{
			if ( !point )
			{
				//alert ( "Address: " + address + " not found on Google Map" );
				document.location = "/store" + store_id;
			}
			else
			{
				map.setCenter ( point, 13 );
				var marker = new GMarker ( point );
				map.addOverlay ( marker );
				marker.openInfoWindowHtml ( '<strong>' + company  + '</strong><br />' + address + '<br />' + store_info + '<br /><p><a href="/store' + store_id + '/" title="View ' + company + ' Details">&raquo; View Store Details</a></p><p><a href="http://maps.google.com/maps?oi=map&q=' + address + '" target="_blank" title="Get Google Directions">&raquo; Get Google Directions</a></p>' );
			}
		});
	}
}