//<!--
    var gmap, dynMapOv, hiliteOv, mapExtension, centerat, identifyTask, layers, overlays, qtask, whereClause, query, gOverlays, loadingInfoMessage, loadingMapRefresh, loadingPOS, clickPoint, exportURL, queryString,graphPdfUrl,printlistUrl, search_id;
	var layer, hilitelayer;

      function initialize(){
        //set a proxy page so we can make cross browser requests
        esri.arcgis.gmaps.Config.proxyUrl = "/secure/map/proxy.php";
        // create the map
        gmap = new GMap2(document.getElementById("map"));
		var mapWidth = document.getElementById("map").clientWidth;
        loadingPOS = mapWidth/2 -50;
        centerat = new GLatLng(39.876019, -96.240234);
        gmap.addControl(new GLargeMapControl3D());
        gmap.addControl(new GHierarchicalMapTypeControl());
        gmap.addMapType(G_PHYSICAL_MAP);
        gmap.setMapType(G_PHYSICAL_MAP);
        gmap.setCenter(centerat, 4);
        geocoder = new GClientGeocoder();
        gmap.enableScrollWheelZoom();

        mapExtension = new esri.arcgis.gmaps.MapExtension(gmap);

        // create a dynamic map service layer
        //var layer = new esri.arcgis.gmaps.DynamicMapServiceLayer("http://207.114.175.57/ArcGIS/rest/services/ConservationAlmanac/MapServer", {opacity:0.75}, addMapServiceLayer);
        layer = new esri.arcgis.gmaps.DynamicMapServiceLayer("http://207.114.175.57/ArcGIS/rest/services/ConservationAlmanac/MapServer", null, 0.75, dynmapcallback);
		
        // create an identify task
        identifyTask = new esri.arcgis.gmaps.IdentifyTask("http://207.114.175.57/ArcGIS/rest/services/ConservationAlmanac/MapServer");

        // register click event listener for the map
        GEvent.addListener(gmap, "click", identify);

        // Find Task used to for the view parcel on map function
        findTask = new esri.arcgis.gmaps.FindTask("http://207.114.175.57/ArcGIS/rest/services/ConservationAlmanac/MapServer");
		
		// Find Task used to for the get the bounding box of the parcel for the detailed parcel report
        findParcelBounds = new esri.arcgis.gmaps.FindTask("http://207.114.175.57/ArcGIS/rest/services/ConservationAlmanac/MapServer");

        // You can execute a task and listen for the complete event or use the callback to get the results
        GEvent.addListener(findTask, "executecomplete", function() {
          //console.debug("'find task complete' event fired!!!");
        });

        // Find Parameters
        params = new esri.arcgis.gmaps.FindParameters();
        params.layerIds = [7];
        params.searchFields = ["TPL_ID"];

        qtask = new esri.arcgis.gmaps.QueryTask("http://207.114.175.57/ArcGIS/rest/services/ConservationAlmanac/MapServer/7");
        GEvent.addListener(qtask, "executecomplete", function() {
          //console.debug("'query task complete' event fired!!!");
        });

        // Query
        query = new esri.arcgis.gmaps.Query();	
	    zoomstate= gup(window.location.href);
        if (zoomstate !="") {
            zoomState(zoomstate);
        }
		
		var htmlinfo='<div style="background-color:white; -moz-opacity: .9; padding: 5px; font-weight:bold; font-size:16px; color: #638c39; font-family:arial; text-align:center"><img src="/images_map/ajaxLoading.gif" border="0"><br>Getting Info...</div>';
		loadingInfoMessage=new HtmlControl(htmlinfo);
		
		var maprefresh='<div style="background-color:white; -moz-opacity: .9; padding: 5px; font-weight:bold; font-size:16px; color: #638c39; font-family:arial; text-align:center"><img src="/images_map/ajaxLoading.gif" border="0"><br>Updating map...</div>';
		loadingMapRefresh=new HtmlControl(maprefresh);

      }

    function dynmapcallback(groundov) {
      //Add groundoverlay to map using gmap.addOverlay()
      gmap.addOverlay(groundov);
      dynMapOv = groundov;
    }
	
	function hilitecallback(groundov) {
      //Add groundoverlay to map using gmap.addOverlay()
      gmap.addOverlay(groundov);
      hiliteOv = groundov;
    }



      function identify(overlay, latLng, overlaylatlng) { 
	    

        clearResults();
        if (overlay) {
            clickPoint = overlaylatlng;
            return false;
        } else {
            clickPoint = latLng;
        }

        // set the identify parameters
        var identifyParameters = new esri.arcgis.gmaps.IdentifyParameters();
        identifyParameters.geometry = latLng;
        clickPoint='';
        identifyParameters.tolerance = 3;
        identifyParameters.layerIds = [ 7 ];
        identifyParameters.layerOption = "all";
        identifyParameters.bounds = gmap.getBounds();
        var mapSize = gmap.getSize();
        identifyParameters.width = mapSize.width;
        identifyParameters.height = mapSize.height;

        // execute the identify operation
        identifyTask.execute(identifyParameters, function(response, error) { // function to be called when the result is available
          // display error message (if any) and return
          if (hasErrorOccurred(error)) return;

          // note that the location where the user clicked on the map (latLng) is visible in this function through closure
          addResultToMap(response, latLng);
        });
      }

      function addResultToMap(response, point) {
	  
          // aggregate the result per map service layer
          var idResults = response.identifyResults;
          layers = {"7": [] };
          for (var i = 0; i < idResults.length; i++) {
            var result = idResults[i];
            layers[result.layerId].push(result);
          }

          // create and show the info-window with tabs, one for each map service layer
          var tabs = [];
          for (var layerId in layers) {
            var results = layers[layerId];
            var count = results.length;
            var label = "", content = "";
            switch(layerId) {
              case "7":
                label = "ConservedLands";
                if (count == 0) break;
                content += "";
                for (var j = 0; j < 1; j++) {
               	 var attributes = results[j].feature.attributes;
				 gmap.addControl(loadingInfoMessage, new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(loadingPOS, 210)));
                	//get the unique ID and query the quickbase database
					
                	var qbURL = "/secure/map/infoWinContent.php?tpl_id=" + attributes["TPL_ID"];
		  	GDownloadUrl(qbURL, function(data, responseCode) {
  		          content+= data;
                        content += "";
			//   tabs.push(new GInfoWindowTab(label, content));
        		   //gmap.openInfoWindowTabsHtml(point, tabs);
				   gmap.removeControl(loadingInfoMessage);
                   gmap.openInfoWindowHtml(point, data);
          		   showFeature(7,0);
		  	});
                }
                break;
            }
          }
      }

      function showFeature(layerId, index) {
        mapExtension.removeFromMap(overlays);
        var idResult = layers[layerId][index];
        overlays = mapExtension.addToMap(idResult, {polygonOptions: { clickable: true}});
      }

      function addMapServiceLayer(layer, error) {
        // display error message (if any) and return
        if (hasErrorOccurred(error)) return;

        // add layer to the map
        mapExtension.addToMap(layer);
      }

      function clearResults() {
        mapExtension.removeFromMap(overlays);
        gmap.closeInfoWindow();
      }

      function hasErrorOccurred(error) {
        if (error) {
          alert("Error " + error.code + ": " + (error.message || (error.details && error.details.join(" ")) || "Unknown error" ));
          return true;
        }
        return false;
      }
	  
	  
	  // Rhonda added this for toggling layers:   - not sure if this is the best way, though
      function updateLayerVisibility() {
      	//select all dom nodes with with name=layers[]
		var numlayers = document.getElementsByName('layers[]').length;
		var inputs = document.getElementsByName('layers[]');
        visible = [];
       for (var i=0, il=numlayers; i<il; i++) {  
          if (inputs[i].checked) {
            visible.push(inputs[i].value);
          }
        }

        if(visible.length==0){
			layer.hide();
		}else{
			layer.show();
			layer.setVisibleLayers(visible);  
			layer.refresh();  
		}		
      } 

      function submit_query() {
	            var query1=document.getElementById('state_select').value;
    			var state = getSelectedText(document.getElementById('state_select'));
				if (query1 == "ALL") {
					alert ("Please select a state.");
					return;
				}
                document.getElementById('results_adv').innerHTML= '<img style="padding:20px;" src="/images_map/ajaxLoading.gif" border="0">';

                var county_idx=document.getElementById('county_select').selectedIndex;
                if (county_idx>0) {
                    query1=document.getElementById('county_select').value + "&" + document.getElementById('state_select').value;
					var county = getSelectedText(document.getElementById('county_select'));
                }
                var query2=document.getElementById('acreseval_select').value + "&" + document.getElementById('acres_select').value;
					var acres = getSelectedText(document.getElementById('acres_select'));
					var acreseval = getSelectedText(document.getElementById('acreseval_select'));
                var query3=document.getElementById('yeareval_select').value + "&" + document.getElementById('year_select').value;
					var year = getSelectedText(document.getElementById('year_select'));
					var yeareval = getSelectedText(document.getElementById('yeareval_select'));
                var year2_idx=document.getElementById('year_select2').selectedIndex;
                if (document.getElementById("year_select2").style.display=="block") {
                    query3=query3 + "&" + document.getElementById('year_select2').value;
					var year2= getSelectedText(document.getElementById('year_select2'));
                }
                var query4=document.getElementById('levgovt_select');
				var lev_gov_selections = '';
				var levgov='';
				for (var i=0; i<query4.options.length; i++) {
					if (query4.options[i].selected) {
						lev_gov_selections += query4.options[i].value + "&";
						if (i==0) {
							levgov+= query4.options[i].text;
						} else {
							levgov+= ", " + query4.options[i].text;
						}
					}
				}
                var query5=document.getElementById('prog_select').value;
				var fundprog = getSelectedText(document.getElementById('prog_select'));
                var query6=document.getElementById('pur_select').value;
				var purtype = getSelectedText(document.getElementById('pur_select'));
                queryString = query1+ "&" +query2+ "&" +query3+ "&" + lev_gov_selections +query5 + "&" +query6;
				paramsTitle = "";
				if (state) {paramsTitle += "State: " + state;}
				if (county) {paramsTitle += ", County: " + county;}
				if (levgov !="All Levels") {paramsTitle += ", Level of Government: " + levgov;}
				if (fundprog !="All Funding Programs") {paramsTitle += ", Funding Program: " + fundprog;}
				if (purtype !="All Purchase Types") {paramsTitle += ", Purchase Type: " + purtype;}
				if (year) {
				     paramsTitle += ", " + yeareval + " " + year;
					 if (year2) {paramsTitle += " and " + year2;}
			    }
				if (acres != 0) {paramsTitle += ", " + acreseval + " " + acres;}
				
				var skipn = parseInt(document.getElementById('skipn').value);
				if (skipn > 0) {
					var queryURL = "/secure/map/qbSearch.php?" + queryString + "&skipn=" + skipn;
				} else {
                var queryURL = "/secure/map/qbSearch.php?" + queryString;
				}
                exportURL = "/secure/map/qbExport.php?" + queryString;
                graphPdfUrl = "/secure/map/graphPDF.php?" + queryString;
				//get the query parameters to add to the results PDF so users know what the filters were
				var state_query = document.getElementById('state_select');
    			var selIndexquery = state_query.selectedIndex;
    			title_geo = state_query.options[selIndexquery].text;
                printlistUrl = "/secure/map/listPDF.php?" + queryString + "& paramsTitle=" + paramsTitle;
		  GDownloadUrl(queryURL, function(data, responseCode) {
			   document.getElementById('results_adv').innerHTML= data;
		  });
      }
	  
	  function nextPage(skipn,numresults,totalAcres,totalDollars) {
		  document.getElementById('skipn').value = parseInt(skipn);
		  document.getElementById('numresults').value = parseInt(numresults);
		  document.getElementById('totalAcres').value = parseInt(totalAcres);
		  document.getElementById('totalDollars').value = parseInt(totalDollars);
		  submit_query();
	  }
	  
	  function getSelectedText(selectName) {
			   var selIndex = selectName.selectedIndex;
			   var textName = selectName.options[selIndex].text;
			   return textName;
	  }
	 function submit_hilitequery() {
	            document.getElementById('hlight_res').style.display="none";
	            if (hiliteOv) {gmap.removeOverlay(hiliteOv);}
	            gmap.addControl(loadingMapRefresh, new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(loadingPOS, 210)));
                var query1=document.getElementById('yeareval_select_map').value + "&" + document.getElementById('year_select_map').value;
                var year2_idx=document.getElementById('year_select_map2').selectedIndex;
                if (document.getElementById("year_select_map2").style.display=="block") {
                    query3=query3 + "&" + document.getElementById('year_select_map2').value;
                }
                var query2=document.getElementById('levgovt_select_map');
				var lev_gov_selections = '';
				var levgov='';
				for (var i=0; i<query2.options.length; i++) {
					if (query2.options[i].selected) {
						lev_gov_selections += query2.options[i].value + "&";
					}
				}
                var query3=document.getElementById('prog_select_map').value;
				var query4=document.getElementById('prog_select_map_state').value;
                var query5=document.getElementById('pur_select_map').value;
				var query6=document.getElementById('state_select_map').value;
                queryString = query1+ "&" +lev_gov_selections +query3+ "&" +query4 + "&" +query5 + "&" +query6;
                var queryURL = "/secure/map/getParcelIDs.php?" + queryString;
		  GDownloadUrl(queryURL, function(data, responseCode) {
				var wherepos = data.search(/&whereclause=/i);
				var numresults = parseInt(data.substring(13, wherepos));
				whereClause = data.substring(wherepos+13);
				if (numresults > 0) {
			        executeQuery(whereClause, numresults);
				} else {
					gmap.removeControl(loadingMapRefresh);
					document.getElementById('hlight_res').style.display="block";
					document.getElementById('hlight_res').innerHTML="<p>No Results Found.</p>";
				}
		  });
      }

      function executeFind(searchID) {
        // clear map overlays and event listeners using MapExtension removeFromMap
        mapExtension.removeFromMap(overlays);

        // set find parameters
        params.searchText = searchID;

        // execute find task
        findTask.execute(params, findCompleteCallback);
      }

      function findCompleteCallback(findResults) {
        // add the findresults to google map without any style
        overlays = mapExtension.addToMap(findResults);

    	 //zoom and center on find result
    	 var findResult, findResultGeometry,polygonBounds,zoomLevel;
    	 findResult = findResults.findResults[0];
        if (findResult) {
        	// switch to map tab
	 	switcher('map');
    	 	findResultGeometry = findResult.feature.geometry[0];
    		polygonBounds = findResultGeometry.getBounds();
    	 	zoomLevel = gmap.getBoundsZoomLevel(polygonBounds)-2;
    	 	polygonCenter = polygonBounds.getCenter();
    	 	gmap.setCenter(polygonCenter, zoomLevel);
        } else {
		//alert ("Parcel is not available for map view.");
              window.open('missingParcel.html', 'missingparcel', config='height=150,width=300,top=400,left=400,toolbar=no, menubar=no, scrollbars=no, resizable=no,location=0, directories=no, status=no');
        }
      }

     function executeQuery(whereClause, numresults) {
	 
	  if (hiliteOv) {gmap.removeOverlay(hiliteOv);}
	  
	    query.where = whereClause;
		if (numresults<150) {
        query.returnGeometry = true;
		} else {
		query.returnGeometry = false;
		gmap.setCenter(centerat, 4);
		}

        // execute query task
        qtask.execute(query, false, mycallback);

	  //set Image Parameters
      var layerDefs = [];
      layerDefs[4] = whereClause;
	  layerDefs[5] = whereClause;

      var imageParams = new esri.arcgis.gmaps.ImageParameters();
      imageParams.format = "png";
      imageParams.transparent = true;
      imageParams.layerIds = [4,5];
      imageParams.layerDefinitions = layerDefs;

      hilitelayer = new esri.arcgis.gmaps.DynamicMapServiceLayer("http://207.114.175.57/ArcGIS/rest/services/ConservationAlmanac/MapServer", imageParams, 0.75, hilitecallback);
	  gmap.removeControl(loadingMapRefresh);
	  document.getElementById('hlight_res').style.display="block";
	  document.getElementById('hlight_res').innerHTML='<img style="margin-top: 5px;" src="/images_map/legend_highlight.jpg" alt="Legend" />'; 
      switcher('map');
      }

      function mycallback(fset) {

        	// switch to map tab
              if (fset.features.length >0) {
	 	    
    	 	    queryResultGeometry = fset.features[0].geometry[0];
    		    polygonBounds = queryResultGeometry.getBounds();
    	 	    zoomLevel = gmap.getBoundsZoomLevel(polygonBounds);
    	 	    polygonCenter = polygonBounds.getCenter();
    	 	    gmap.setCenter(polygonCenter, zoomLevel);
                  queryResults =fset.features;
                  var bounds = gmap.getBounds();
                  for (i=1;i<queryResults.length;i++) {
		        resultgeom = queryResults[i].geometry[0];
                      polygonBounds = resultgeom.getBounds();
                      polygonCenter = polygonBounds.getCenter();
                      bounds.extend(polygonCenter);	
                  }
                 // gmap.removeControl(loadingMapRefresh);
	              gmap.setCenter(bounds.getCenter(), gmap.getBoundsZoomLevel(bounds));
             } else {
			   // gmap.removeControl(loadingMapRefresh);
			   document.getElementById('hlight_res').style.display="block";
		        document.getElementById('hlight_res').innerHTML="<p>Map view not available for current selection.</p>"; 
             }
      }

     function exportList() {
       window.open(exportURL);
     }
     
     function openGraphTab() {
       switcher('simple');
       document.getElementById("adv_query").selected = true;
       displayGraph();
     }

     function toggleYearSelect(){
         if (document.getElementById("yeareval_select").value=="eval3=GTE&eval8=LTE") {
		document.getElementById("year_select2").style.display="block";
         } else {
              document.getElementById("year_select2").style.display="none";
              document.getElementById('year_select2').selectedIndex = 0;
         }
     }
	 
	function toggleYearSelect_map(){
         if (document.getElementById("yeareval_select_map").value=="eval3=GTE&eval8=LTE") {
		document.getElementById("year_select_map2").style.display="block";
		document.getElementById("andsign").style.display="block";
         } else {
              document.getElementById("year_select_map2").style.display="none";
			  document.getElementById("andsign").style.display="none";
              document.getElementById('year_select_map2').selectedIndex = 0;
         }
     }
	 
	function FedSelect(){       
		document.getElementById("prog_select_map").style.display="block";
		document.getElementById("state_select_map").style.display="none";
		document.getElementById("prog_select_map_state").style.display="none";	
        document.getElementById('prog_select_map_state').selectedIndex = 0;		
     }
	function StateSelect(){       
		document.getElementById("prog_select_map").style.display="none";
		document.getElementById("state_select_map").style.display="block";
		document.getElementById("prog_select_map_state").style.display="block";	
		document.getElementById('prog_select_map').selectedIndex = 0;	
     }	 
	 

     function showAddress() {
	var address = document.getElementById("addressquery").value;
  	geocoder.getLatLng(
    	address,
    	function(point) {
     	 	if (!point) {
        		alert(address + " not found");
      		} else {
        		gmap.setCenter(point, 11);
        		//var marker = new GMarker(point);
        		//gmap.addOverlay(marker);
      		}
     }
     );
     }

	function printMap(){
              //set Image Parameters
	    document.getElementById("print_proc").style.display="block";
		var imageParams = new esri.arcgis.gmaps.ImageParameters();
		if (whereClause) {
		    imageParams.layerDefinitions = [];
			imageParams.layerDefinitions[4] = whereClause;
			imageParams.layerDefinitions[5] = whereClause;
			imageParams.layerIds = [11,10,9,8,7,5,4];
		} else {
			imageParams.layerIds = [11,10,9,8,7];
		}
 
			imageParams.format = "jpg";
            imageParams.height = 510;
            imageParams.width = 632;
            imageParams.dpi = 65;
		//get the map image URL
   		layer.exportMapImage(imageParams, mapImageURLCallback);
    } 
    function mapImageURLCallback(mapImage) {
              //set the URL value in the form
              document.getElementById('mapImageURL').value = mapImage.href;
              //submit the PDF print form
              document.forms['mapPrint'].submit();
			  document.getElementById("print_proc").style.display="none";
    }	
	function printDetailedReport(tpl_id){
        search_id = tpl_id;
	    // set find parameters
        params.searchText = tpl_id;
		document.getElementById('tpl_id').value = tpl_id;
        // execute find task
        findTask.execute(params, findParcelBoundsCallback);
    } 
    function parcelReportMapURLCallback(mapImage) {
              //set the URL value in the form
              document.getElementById('parcelreportmapImageURL').value = mapImage.href;
              //submit the PDF print form
              document.forms['parcelReportPrint'].submit();
    }
	
	function findParcelBoundsCallback(findParcelResults) {

    	 //zoom and center on find result
    	 var parcel, parcelGeometry,polygonBounds,zoomLevel;
    	 parcel = findParcelResults.findResults[0];
        if (parcel) {
    	 	parcelGeometry = parcel.feature.geometry[0];
    		polygonBounds = parcelGeometry.getBounds();
    	 	zoomLevel = gmap.getBoundsZoomLevel(polygonBounds)-4;
    	 	polygonCenter = polygonBounds.getCenter();
    	 	gmap.setCenter(polygonCenter, zoomLevel);
			var imageParams = new esri.arcgis.gmaps.ImageParameters();
			//imageParams.bounds = polygonBounds;
			imageParams.layerIds = [11,10,9,8,7,5,4,3];
			imageParams.layerDefinitions = [];
			imageParams.layerDefinitions[4] = "TPL_ID = " + search_id;
			imageParams.layerDefinitions[5] = "TPL_ID = " + search_id;
			imageParams.format = "jpg";
			imageParams.height = 270;
			imageParams.width = 348;
			imageParams.dpi = 75;
			//get the map image URL
			layer.exportMapImage(imageParams, parcelReportMapURLCallback);
        } 
      }

    function printList(){
       window.open(printlistUrl);
    }
	
	function zoomState(zoomstate){
	var sw;
	var ne;
	switch(zoomstate){
		case 'AL':
			sw=new GLatLng(29.11377539511439, -92.7685546875); ne = new GLatLng(35.96022296929667, -80.4638671875);
			break;
		case 'AK':
			sw=new GLatLng(58.17070248348609, -175.166015625); ne = new GLatLng(71.63599288330606, -125.94726562500001);
			break;
		case 'AZ':
			sw=new GLatLng(30.977609093348686, -117.421875); ne = new GLatLng(37.68382032669382, -105.1171875);
			break;
		case 'AR':
			sw=new GLatLng(31.409912194070973, -97.998046875); ne = new GLatLng(38.08268954483802, -85.693359375);
			break;
		case 'CA':
			sw=new GLatLng(30.14512718337613, -127.13378906250001); ne = new GLatLng(43.13306116240612, -102.5244140625);
			break;
		case 'CO':
			sw=new GLatLng(35.55010533588551, -111.6650390625); ne = new GLatLng(41.88592102814744, -99.3603515625);
			break;
		case 'CT':
			sw=new GLatLng(40.75557964275588, -74.24560546875); ne = new GLatLng(42.27730877423709, -71.16943359375);
			break;
		case 'DE':
			sw=new GLatLng(37.361425501905146, -78.321533203125); ne = new GLatLng(40.52215098562377, -72.169189453125);
			break;
		case 'DC':
			sw=new GLatLng(37.142803443716836, -80.101318359375); ne = new GLatLng(40.3130432088809, -73.948974609375);
			break;
		case 'FL':
			sw=new GLatLng(24.86650252692691, -89.4287109375); ne = new GLatLng(32.008075959291055, -77.1240234375);
			break;
		case 'GA':
			sw=new GLatLng(29.286398892934763, -89.296875); ne = new GLatLng(36.12012758978146, -76.9921875);
			break;
		case 'HI':
			sw=new GLatLng(18.656654486539995, -160.499267578125); ne = new GLatLng(22.46180203533398, -154.346923828125);
			break;
		case 'ID':
			sw=new GLatLng(39.061849134291535, -127.17773437499999); ne = new GLatLng(50.54136296522161, -102.568359375);
			break;
		case 'IL':
			sw=new GLatLng(36.79169061907076, -95.009765625); ne = new GLatLng(43.02071359427862, -82.705078125);
			break;
		case 'IN':
			sw=new GLatLng(36.84446074079564, -92.26318359375); ne = new GLatLng(43.068887774169625, -79.95849609375);
			break;
		case 'IA':
			sw=new GLatLng(38.99357205820944, -99.99755859375); ne = new GLatLng(45.02695045318543, -87.69287109375);
			break;
		case 'KS':
			sw=new GLatLng(35.28150065789119, -104.39208984375); ne = new GLatLng(41.64007838467891, -92.08740234375);
			break;
		case 'KY':
			sw=new GLatLng(34.488447837809304, -91.4501953125); ne = new GLatLng(40.91351257612757, -79.1455078125);
			break;
		case 'LA':
			sw=new GLatLng(27.955591004642528, -98.67919921875); ne = new GLatLng(34.88593094075315, -86.37451171875);
			break;
		case 'ME':
			sw=new GLatLng(42.212245162885814, -75.12451171875); ne = new GLatLng(47.945786463687185, -62.81982421875);
			break;
		case 'MD':
			sw=new GLatLng(37.509725842937485, -80.057373046875); ne = new GLatLng(40.66397287638688, -73.905029296875);
			break;
		case 'MA':
			sw=new GLatLng(40.6723059714534, -75.047607421875); ne = new GLatLng(43.683763524273346, -68.895263671875);
			break;
		case 'MI':
			sw=new GLatLng(40.38002840251183, -90.17578125); ne = new GLatLng(46.28622391806705, -77.87109375);
			break;
		case 'MN':
			sw=new GLatLng(40.58058466412761, -105.5126953125); ne = new GLatLng(51.781435604431195, -80.9033203125);
			break;
		case 'MS':
			sw=new GLatLng(29.24806324379655, -95.361328125); ne = new GLatLng(36.08462129606931, -83.056640625);
			break;
		case 'MO':
			sw=new GLatLng(35.40696093270201, -98.7451171875); ne = new GLatLng(41.75492216766298, -86.4404296875);
			break;
		case 'MT':
			sw=new GLatLng(40.58058466412761, -122.12402343749999); ne = new GLatLng(51.781435604431195, -97.5146484375);
			break;
		case 'NE':
			sw=new GLatLng(38.70265930723801, -106.23779296875); ne = new GLatLng(44.762336674810996, -93.93310546875);
			break;
		case 'NV':
			sw=new GLatLng(35.79999392988527, -122.80517578125); ne = new GLatLng(42.114523952464246, -110.50048828125);
			break;
		case 'NH':
			sw=new GLatLng(42.512601715736665, -74.77294921875); ne = new GLatLng(45.43700828867389, -68.62060546875);
			break;
		case 'NJ':
			sw=new GLatLng(37.86618078529668, -77.926025390625); ne = new GLatLng(41.004775422229464, -71.773681640625);
			break;
		case 'NM':
			sw=new GLatLng(30.902224705171417, -111.708984375); ne = new GLatLng(37.614231415424165, -99.404296875);
			break;
		case 'NY':
			sw=new GLatLng(40.212440718286466, -80.88134765625); ne = new GLatLng(46.13417004624326, -68.57666015625);
			break;
		case 'NC':
			sw=new GLatLng(31.9148675032762, -87.1435546875); ne = new GLatLng(38.54816542304656, -74.8388671875);
			break;
		case 'ND':
			sw=new GLatLng(44.49650533109345, -106.80908203125); ne = new GLatLng(50.00773901463685, -94.50439453125);
			break;
		case 'OH':
			sw=new GLatLng(37.35269280367273, -87.978515625); ne = new GLatLng(43.5326204268101, -75.673828125);
			break;
		case 'OK':
			sw=new GLatLng(31.877557643340015, -104.12841796875); ne = new GLatLng(38.51378825951165, -91.82373046875);
			break;
		case 'OR':
			sw=new GLatLng(41.21172151054787, -126.123046875); ne = new GLatLng(47.040182144806664, -113.818359375);
			break;
		case 'PA':
			sw=new GLatLng(37.63163475580643, -83.43017578125); ne = new GLatLng(43.78695837311561, -71.12548828125);
			break;
		case 'RI':
			sw=new GLatLng(41.3500103516271, -72.2186279296875); ne = new GLatLng(42.108411365705855, -70.6805419921875);
			break;
		case 'SC':
			sw=new GLatLng(32.01739159980399, -83.814697265625); ne = new GLatLng(35.398005947151056, -77.662353515625);
			break;
		case 'SD':
			sw=new GLatLng(41.73852846935917, -106.36962890625); ne = new GLatLng(47.517200697839414, -94.06494140625);
			break;
		case 'TN':
			sw=new GLatLng(32.287132632616355, -92.900390625); ne = new GLatLng(38.89103282648846, -80.595703125);
			break;
		case 'TX':
			sw=new GLatLng(24.5271348225978, -112.060546875); ne = new GLatLng(38.341656192795924, -87.451171875);
			break;
		case 'UT':
			sw=new GLatLng(36.29741818650808, -117.44384765625); ne = new GLatLng(42.56926437219384, -105.13916015625);
			break;
		case 'VT':
			sw=new GLatLng(42.36666166373274, -75.706787109375); ne = new GLatLng(45.29807513870794, -69.554443359375);
			break;
		case 'VA':
			sw=new GLatLng(34.397844946449844, -85.4736328125); ne = new GLatLng(40.83043687764923, -73.1689453125);
			break;
		case 'WA':
			sw=new GLatLng(44.99588261816546, -126.58447265624999); ne = new GLatLng(50.45750402042055, -114.27978515625);
			break;
		case 'WV':
			sw=new GLatLng(35.79999392988527, -86.41845703125); ne = new GLatLng(42.114523952464246, -74.11376953125);
			break;
		case 'WI':
			sw=new GLatLng(41.62365539068639, -95.80078125); ne = new GLatLng(47.41322033016902, -83.49609375);
			break;
		case 'WY':
			sw=new GLatLng(39.99395569397331, -113.8623046875); ne = new GLatLng(45.93587062119052, -101.5576171875);
			break;
		default:
			sw=new GLatLng(10.141931686131018, -145.1953125); ne = new GLatLng(59.88893689676585, -46.7578125);
			break;
	}
	bound = new GLatLngBounds(sw,ne);
	gmap.setZoom(gmap.getBoundsZoomLevel(bound)+ 1);
	gmap.panTo(bound.getCenter());
}
function gup(url)
{
//get position of state abbreviation
var pos = url.search(/map.html/i);
var state = "";
if (pos >1) {
var state = url.substring(pos-3, pos-1);
state= state.toUpperCase();
}
if( state == "" ) {
    return "";
} else {
    return state;
}	
}
//-->
