// A function to create the marker and set up the event window
       function createMarker(point,name,html,icontype) {
        var marker = new GMarker(point,icons[icontype]);
        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(html, {maxHeight:120,autoScroll:true});
        });
        return marker;
      }
	  
	  // Slider zoom function
	  $(function() {
			// slider target
			var target = $('#zoom-slider #zoom-path');
		
			// create the slider
			target.slider({
				orientation: 	'horizontal',
				value: 			currentZoomLevel,
				min: 			parseInt(G_NORMAL_MAP.getMinimumResolution()),
				max: 			parseInt(G_NORMAL_MAP.getMaximumResolution()),
				step: 			1,
				animate: 		true,
				stop: function() {
					map.setZoom(parseInt(target.slider('option','value')));
				}
			});
		
			// update slider on zoom with double click
			GEvent.addListener(map, 'moveend', function() { target.slider('option','value', map.getZoom()); });
		
			// maximum slider value
			var maxValue = parseInt(target.slider('option', 'max'));
		
			// minimum slider value
			var minValue = parseInt(target.slider('option', 'min'));
		
			// hook increase zoom control
			$('#zoom-control-plus').click(function() {
				// current slider value
				var currentValue = parseInt(target.slider('option','value'));
		
				// current slider value increased by 1
				var newValue = currentValue+1;
		
				// is new value greater than max value?
				if(newValue <= maxValue) {
					// increase slider value
					target.slider('option', 'value', newValue);
					map.setZoom(newValue);
				} else {
					// slider is at max value
					target.slider('option', 'value', maxValue);
					map.setZoom(maxValue);
				}
				return false;
			});
		
			// hook decrease zoom control
			$('#zoom-control-minus').click(function() {
				// current slider value
				var currentValue = parseInt(target.slider('option','value'));
		
				// current slider value increased by 1
				var newValue = currentValue-1;
		
				// is new value greater than max value?
				if(newValue >= minValue) {
					// increase slider value
					target.slider('option', 'value', newValue);
					map.setZoom(newValue);
				} else {
					// slider is at max value
					target.slider('option', 'value', minValue);
					map.setZoom(minValue);
				}
				return false;
			});
		});
	  
	  // A function to create clicking, rollover polygons. 
      function createbasegons(pts,strokeColor, strokeWeight, strokeOpacity, fillColor, fillOpacity,label,concathtml,lat,lng,header,category,Polytype) {
	  	
		
        // Set up the polygon
		var polygon = new GPolygon(pts,strokeColor, strokeWeight, strokeOpacity, fillColor, fillOpacity);
	
		
		//var bob1 = bob.replace("\(", "");
		//var bob2 = bob1.replace("\)", "");
		
		// Set up the Elabel to show the areas title
		var mylabel = new ELabel(polygon.getBounds().getCenter(), label, "style2", new GSize(-40,22), 80 );
		
        GEvent.addListener(polygon, "click", function() {
          //map.openInfoWindowHtml(gon.getBounds().getCenter(), concathtml, {maxWidth:175,autoScroll:true});
          tooltip.style.visibility="hidden"
		  //map.openInfoWindowHtml(gon.getBounds().getCenter(), concathtml, {maxWidth:175,autoScroll:true});
	    });
        GEvent.addListener(polygon, "mouseover", function() {
          polygon.setFillStyle({opacity:0.3});
          tooltip.style.visibility="hidden"
		  //map.openInfoWindowHtml(gon.getBounds().getCenter(), label, {maxWidth:175,autoScroll:true});
		  
		  // An ELabel with all optional parameters in use 
   
			//label.setPoint(gon.getBounds().getCenter());
      		map.addOverlay(mylabel);
        });
        GEvent.addListener(polygon, "mouseout", function() {
          polygon.setFillStyle({opacity:0});
          tooltip.style.visibility="hidden"
		  map.removeOverlay(mylabel);
		 
        });
         // Store various info as gon properties
        polygon.mycategory = category;
        polygon.mytype = Polytype;
        polygon.myname = label;
        polygon.mylat = lat;
        polygon.mylng = lng;
        polygon.myheader = header;
        basemarkerslinespolys.push(polygon);
        return polygon;
      }
	
	  // This function picks up the click and opens the corresponding info window
      function myclick(i) {
        GEvent.trigger(gmarkers[i], "click");
      }