
function map_class()
{
	this.map            = null;
	this.geocoder       = null;
	this.markers        = [];
	this.markerCount    = 0;
	this.insertIconType = "lst";
	this.ajax           = new ajax_class();

	this.addNewCoord = function(inPid, inLat, inLng, inAdr, inDsc, inIms, inIcT, inIcX, inIcY, inHid)
	{
		var newPoint = new GLatLng(inLat, inLng);
		this.markerCount++;
		this.markers[this.markerCount] = new marker_class(inPid, newPoint, this.markerCount, inAdr, inDsc, inIms, inIcT, inIcX, inIcY, inHid);
		this.markers[this.markerCount].uid = this.markerCount;
		
		this.map.addOverlay(this.markers[this.markerCount].mkr);
	}

	this.initialize = function()
	{
  	if (GBrowserIsCompatible()) 
  	{
    	this.map = new GMap2(document.getElementById("map"));
    	this.map.addControl(new GLargeMapControl());
    	this.map.addControl(new GMapTypeControl());
    	this.geocoder = new GClientGeocoder();
    	this.map.setCenter(new GLatLng(42.032464, -93.633728), 13);
			this.map.addControl(new google.maps.LocalSearch());
			this.map.enableScrollWheelZoom();

			this.ajax.loadAddresses(); // load the already listed addresses
		}
	}

	this.initialize(); // Positioned here to run /after/ the initialize function has been declared  
	
	this.addAddress = function(address)
	{
		if (this.geocoder)
	  {
			this.geocoder.getLatLng(address, function(point)
	    {
				if (!point)
	      {
					if (address=="")
						address = "This address is";
						
					alert(address + " not found");
	      } else
	      {
					// SCOPE CHANGE
					this.map.map.setCenter(point);
					var img = map.getIconInfo();
					this.map.addNewPoint(point, address, "New Description", "default", img, 36, 32);
	      	// END OF SCOPE CHANGE
				}
	    });
	  }
	}

	this.getIconInfo = function()
	{
		var icon = "";
		
		switch (this.insertIconType)
		{
		case 'poi':
			icon = 'pointOfInterest'; 
			break;
		case 'glf':
			icon = 'golfCourse';
			break;
		case 'rst':
			icon = 'restaurant';
			break;
		case 'med':
			icon = 'medicalCenter';
			break;
		case 'prk':
			icon = 'park';
			break;
		case 'sch':
			icon = 'school';
			break;
		case 'shp':
			icon = 'shopping';
			break;
		case 'lst':
			icon = 'listing';
			break;
		}
		return icon;
	}

	this.hideIcons = function(inType, inVisible)
	{
		for (var i=1; i<=this.markerCount; i++)
		{
			if (this.markers[i].ict==inType && this.markers[i].act=="active")
			{
				if (inVisible)
				{
					this.markers[i].mkr.show();
				} else
				{
					this.markers[i].mkr.hide();
				}
			}
		}
	}

} // End class


