//
// File : weeds-rtwgmap-core.js
//
// Description : "Core" Javascript functions for the Weed Survey Google Map
//

   
    
	//
	// get all the gmarkers for the specified region
	//
	function getMarkersForRegion(regionId){
    	currentRegionId = regionId;
	    map.closeInfoWindow();    
    	closeDirections();
    	//unapplyFilter();
    	//filterChanged();
    	
	    for(var i = 0; i < regions.length; i++)
    	{
        	if(regions[i].id == regionId) {
    	        map.setCenter(new GLatLng(regions[i].latitude, regions[i].longitude), regions[i].zoomLevel);
	            globalRegion = regions[i];
        	    break;
	        }
    	}

		// the default is to get the rtwgmap lib to return/list the markers in the current view ...
		eval(getDataProviderClassName()).getMarkersForRegion(returnFilteredMarkers, globalRegion.id);
	}
	
   var printableMapWindow;

   //
   // Shows a printable view of the current map
   //
   var printCurrentListings = function (type) {
        var weed = selectedFilters[0].label;    
		var url = '/app68/printableweedsurveymap?commonName=';
		url += weed;
		
		printableMapWindow=window.open(url,'','width=700,height=675,scrollbars=yes,resizable=yes');
		if (printableMapWindow && window.focus) {printableMapWindow.focus()}
   
   		setTimeout('printMap()',1000);
    }
 	
 	
 	var printMap = function() {
		var counties = top.printableMapWindow.document.getElementById("counties");
		if(counties) {
			top.printableMapWindow.focus();
			top.printableMapWindow.print();
		} else {
			setTimeout('printMap()',1000);
		}
 	}
 	