function RemoveSpaces (s) {
	var pieces = s.split(" ");
	var t = "";
	for (var i=0; i<pieces.length; i++) {
		t += pieces[i];
	}
	return t;
}

var Town = function (name, locationx, locationy)
{
	this.firsttime = true;
	this.name = name;
	this.origin = new GLatLng(locationx, locationy);

	// Method for getting the name of the town
	this.placeName = function() { return this.name; }

	// Method for getting the location of the town
	this.LatLng = function () {
		if (this.firsttime) {
			this.firsttime = false;
			return this.origin;
		} else {
			this.x = this.origin.lat();
			this.y = this.origin.lng();
			this.x += (Math.random() - .5)/50.;
			this.y += (Math.random() - .5)/50.;
			return new GLatLng(this.x, this.y);
		}
	}

	// Creates a marker whose info window displays the give text in two tabs
	this.mark = function (map, icon, text) {
		// Set up our GMarkerOptions object
		markerOptions = { icon:icon, title:this.placeName() };
		latlng = this.LatLng();
		var marker = new GMarker(latlng, markerOptions);
	
		var infoTabs = [];
		infoTabs.push (new GInfoWindowTab(text[0], "<u>" + this.placeName() + "</u><BR>" + text[1]));

		if (!text[2]) {
			infoTabs.push (new GInfoWindowTab("Location", latlng.lat() + " " + latlng.lng()));
		}
		for (var i=2; text[i]; i+=2){
			infoTabs.push (new GInfoWindowTab(text[i], text[i+1]));
		}
		GEvent.addListener(marker, "click", function() {
			var win = marker.openInfoWindowTabsHtml(infoTabs);
			win.enableMaximize();
		});

		var type = "misc";
		if (icon == Father || icon == Mother) {
			type = "fathers";
		} else if (icon == Aunt || icon == Uncle) {
			type = "uncles";
		} else if (icon == CemeteryMarker) {
			type = "cemetery";
		} else if (icon == HistoricalSociety) {
			type = "societies";
		} else if (icon == Library) {
			type = "library";
		} else {
			if (type == "misc") {
				for (var j=0; j<14; j++) {
					if (icon == GF[j] || icon == GM[j]) {
						type = "fathers";
						break;
					}
				}
			}
			if (type == "misc") {
				for (var j=0; j<10; j++) {
					if (icon == GU[j] || icon == GA[j]) {
						type = "uncles";
						break;
					}
				}
			}
			if (type == "misc") {
				for (var j=0; j<6; j++) {
					if (icon == C[j]) {
						type = "cousins";
						break;
					}
				}
			}
		}
		map.addOverlay(marker);
		MyMarkers[type].push (marker);
	}
}
