/**
 * HyperCities Clear Map Control
 *
 * @author    David Shepard
 * @copyright (c) 2009, by HyperCities Tech Team
 * @date      2009-07-02
 * @version   0.1
 * @description This control removes all maps and all objects from the screen, then resets the timeslider back to 1700-current year.
 *
 */
 
function ClearMapControl() {
	/*return {
		clearMap : function () {
			
		} // end clearMap function 
	
	}; // end public methods and objects
	*/
}

ClearMapControl.prototype = new GControl();

ClearMapControl.prototype.initialize = function (map) {
	//var container = this.getContainer();
	var container = document.createElement("div");
	//this.setButtonStyle_(container);
	container.id = "resetMapButton";
	//container.append(document.createTextNode("Reset Map"));
	var resetBtnImage = document.createElement("img");
	resetBtnImage.src = "images/TCBtn.png";
	resetBtnImage.alt = "Reset Map - Remove all objects and maps from screen, and reset time slider to 1700-current year";
	resetBtnImage.title = "Reset Map - Remove all objects and maps from screen, and reset time slider to 1700-current year";
	container.appendChild(resetBtnImage);
	GEvent.addDomListener(container, "click", function () {
//			HyperCities.debug("Resetting Collection List");
			HyperCities.collectionList.uncheckAllItems();
			HyperCities.collectionList.collapseAllFolders();
//			HyperCities.debug("Resetting Map List");
			HyperCities.mapList.clearMaps();
//			HyperCities.debug("Resetting Time slider");
			var startDate = new Date(),
				endDate   = new Date();
			// NOTE: Javascript Dates are offset by 1 year; this will return 1700
			startDate.setFullYear(1701, 0, 0);
			// setTime on timebar will triger HyperCities.syncSession, thus reloading intellilist and maplist
			HyperCities.timebar.setTime(null, startDate, endDate, null, true);
                        HyperCities.linkController.clearURL();
                        HyperCities.linkController.clearURL();
		});
	map.getContainer().appendChild(container);

	return container;
}

ClearMapControl.prototype.getDefaultPosition = function() {
//	HyperCities.debug("getDefaultPosition called.");
	return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(120, 5));
}

ClearMapControl.prototype.setButtonStyle_ = function (button) {
	button.style.textDecoration = "underline";
	button.style.color = "#0000cc";
	button.style.backgroundColor = "white";
	button.style.font = "small Arial";
	button.style.border = "1px solid black";
	button.style.padding = "2px";
	button.style.marginBottom = "3px";
	button.style.textAlign = "center";
	button.style.width = "6em";
	button.style.cursor = "pointer";
}
