 var minZoomLevel = 6;  
 
function initialize() 
{     
	var latlng = new google.maps.LatLng(40.555413,-82.725898);     
	var myOptions = {       zoom: 7, disableDefaultUI: true, mapTypeControl: true, panControl: false,    zoomControlOptions: {       style: google.maps.ZoomControlStyle.SMALL     },     center: latlng,       mapTypeId: google.maps.MapTypeId.ROADMAP     };     
	var map = new google.maps.Map(document.getElementById("map_canvas"),         myOptions);  
	setMarkers(map, trains); 
}  
/**  * Data for the markers consisting of a name, a LatLng and popup text 
  
*/



var trains = [
        ['Age of Steam Roundhouse', 40.371659, -82.86438, '<BR><a style="color: #800000" href="http://www.ageofsteamroundhouse.com/">Age of Steam Roundhouse</a>'],
        ['Ashtabula, Carson, & Jefferson Scenic Railroad', 41.740372, -80.763094, '<BR>  <a style="color: #800000" href="http://www.acjrscenic.net/">Ashtabula, Carson, & Jefferson Scenic Railroad</a>'],
        ['Bradford Ohio Railroad Museum', 40.132315, -84.430705, '<BR><a style="color: #800000"  href="http://www.bradfordohiorailroadmuseum.org/">Bradford Ohio Railroad Museum</a>'],
        ['Byesville Scenic Railway, Inc.', 40.024858, -81.592554, '<BR><a style="color: #800000" href="http://www.bsrw.org/">Byesville Scenic Railway, Inc.</a>'],
        ['Cuyahoga Valley Scenic Railway', 41.357687,-81.597107, '<BR><a style="color: #800000" href="http://www.cvsr.com/">Cuyahoga Valley Scenic Railway.</a>'],
       ['Cincinnati Railroad Club', 39.11, -84.537091, '<BR><a style="color: #800000" href="http://www.cincinnatirrclub.org">Cincinnati Railroad Club</a>'],
	    ['Dennison Railroad Depot, Inc.', 40.392226, -81.332825, '<BR><a style="color: #800000" href="http://dennisondepot.org">Dennison Railroad Depot, Inc.</a>'],
	    ['The Depot Event Facility and Rail Museum', 40.051413, -83.044888, '<BR><a style="color: #800000" href="http://www.the-depot.org">The Depot Event Facility and Rail Museum</a>'],
	    ['EnterTRAINment Junction', 39.351523, -84.374206, '<BR><a style="color: #800000" href="http://www.entertrainmentjunction.com">EnterTRAINment Junction</a>'],
	    ['Fostoria Rail Preservation Society', 41.158548,-83.414087, '<BR><a style="color: #800000" href="http://fostoriatrainntriangle.com">Fostoria Rail Preservation Society</a>'],
	    ['Hocking Valley Scenic Railway', 39.45862, -82.231935, '<BR><a style="color: #800000" href="http://www.hvsr.com">Hocking Valley Scenic Railway</a>'],
		['Lebanon, Mason & Monroe Railroad', 39.432558, -84.207033, '<BR><a style="color: #800000" href="http://www.lebanonrr.com">Lebanon, Mason & Monroe Railroad</a>'],
	    ['Lodi Station Outlets', 40.999108, -81.989508, '<BR><a style="color: #800000" href="http://www.lodistation.com">Lodi Station Outlets</a>'],
	     ['Mad River & NKP Railroad Museum', 41.271236,-82.84285, '<BR><a style="color: #800000" href="http://www.madrivermuseum.org">Mad River & NKP Railroad Museum</a>'],
	 ['Northern Ohio Railway Museum', 41.030837, -81.909952, '<BR><a style="color: #800000" href="http://www.northernohio.railway.museum">Northern Ohio Railway Museum</a>'],
	    ['Northwest Ohio Railroad Preservation, Inc.', 41.088469, -83.656184, '<BR><a style="color: #800000" href="http://www.nworrp.org">Northwest Ohio Railroad Preservation, Inc.</a>'],
	    ['Orrville Railroad Heritage Society, Inc.', 40.839823, -81.767636, '<BR><a style="color: #800000" href="http://www.orrvillerailroad.com">Orrville Railroad Heritage Society, Inc.</a>'],
	    ['Columbus Trolley', 39.963347, -83.075805, '<BR><a style="color: #800000" href="http://www.columbustrolley.com">Columbus Trolley</a>'],
		['Toledo, Lake Erie & Western Railway ', 41.500753, -83.723798, '<BR><a  style="color: #800000" href="http://www.tlew.org">Toledo, Lake Erie & Western Railway</a>']
	
];
 var image = 'train2.png';
 
 function setMarkers(map, locations) {
     // Add markers to the map   
     // Marker sizes are expressed as a Size of X,Y   
     // where the origin of the image (0,0) is located   
     // in the top left of the image.    
     // Origins, anchor positions and coordinates of the marker   
     // increase in the X direction to the right and in   
     // the Y direction down.


     var infowindow = new google.maps.InfoWindow();

     for (var i = 0; i < locations.length; i++) {
         var train = locations[i];
         var myLatLng = new google.maps.LatLng(train[1], train[2]);


         infowindow.setContent(trains[i][3]);

         var marker = new google.maps.Marker({
             position: myLatLng,
             map: map,
             icon: image,
             title: train[0],
             content: train[3],
            zIndex: i+1
            
         });
        
         google.maps.event.addListener(marker, 'mouseover', function() {

             infowindow.setContent(this.content);
             infowindow.open(map, this);
         });


    // Limit the zoom level    
	google.maps.event.addListener(map, 'zoom_changed', function() {      
		if (map.getZoom() < minZoomLevel) map.setZoom(minZoomLevel);    
	}); 


 // Bounds for Ohio
   var allowedBounds = new google.maps.LatLngBounds(   
 	new google.maps.LatLng(38.505191,-85.264893),   
	new google.maps.LatLng(42.073762,-80.222168)    
               );    
 // Listen for the dragend event    
	google.maps.event.addListener(map, 'dragend', function() {     
		 if (allowedBounds.contains(map.getCenter())) return;      
 // Out of bounds - Move the map back within the bounds       
	var c = map.getCenter(),          
	x = c.lng(),          
	y = c.lat(),         
	 maxX = allowedBounds.getNorthEast().lng(),          
	maxY = allowedBounds.getNorthEast().lat(),          
	minX = allowedBounds.getSouthWest().lng(),          
	minY = allowedBounds.getSouthWest().lat();      
	if (x < minX) x = minX;      
	if (x > maxX) x = maxX;      
	if (y < minY) y = minY;      
	if (y > maxY) y = maxY;       
	map.setCenter(new google.maps.LatLng(y, x));   
});  



     }
 

 }

