SJJS.pageInstance = new function() {
	var me = this;
	var _map;
	var _zoomcontrol;
	var _heightOffset = 120, _widthOffset = 190;
	var _overlays;
	var _legend, _list, _maplist, _menu;
	var _loadingoverlay;
	var _labels = [];
	var _cookiename = "mapinfo";
	var _styles = {};
	var _highlightcolor = "#44EE88";
	//var _highlightcolor = "#FFFF7E";
	//var _highlightcolor = "#FF7777";
	var _curmaptype = "";
	var _shownonmapped = true;

	SJJS.using("SJJS.GMap.Overlays.Data");
	SJJS.using("SJJS.GMap.Overlays.GISOverlay");
	SJJS.using("SJJS.GMap.Overlays.GeoLabel");
	SJJS.using("SJJS.GMap.Controls.GList");
	SJJS.using("SJJS.GMap.Controls.GLegend");
	SJJS.using("SJJS.GMap.Controls.GMenuBar");
	SJJS.using("SJJS.GMap.Controls.Label");
	SJJS.using("SJJS.GMap.Controls.DivList");
	SJJS.using("SJJS.GMap.Overlays.GISOverlayManager");

	me.removeLabels = function() {
		var x;
		for (x = 0; x < _labels.length; x++) {
			_map.removeOverlay(_labels[x]);
		}
		_labels = null;
		_labels = [];
	};

	me.showList = function(show) {
		if (show) {
			_menu.checkItem("ListID", "ViewID");
		} else {
			_menu.uncheckItem("ListID", "ViewID");
		}
	};

	me.resizeMap = function() {
		document.getElementById("map_canvas").style.height = (SJJS.util.getBodyHeight() - _heightOffset) + "px";
		document.getElementById("map_canvas").style.width = (SJJS.util.getBodyWidth() - _widthOffset) + "px";
	};
	
	me.getCPStyle = function(id) {
		return _styles[_curmaptype + _overlays.get("cp").getAttributeById(id, "groupname")];
	};

	me.getCDStyle = function(id) {
		return _styles[_curmaptype + "CD"];
	};

	me.setListHeaders = function(list) {
		list.setTextForGroup("Pre Construction (" + list.getNumberOfEntriesForSection("Pre Construction") + ")", "Pre Construction");
		list.setTextForGroup("Construction (" + list.getNumberOfEntriesForSection("Construction") + ")", "Construction");
		list.setTextForGroup("Completed (" + list.getNumberOfEntriesForSection("Completed") + ")", "Completed");
	};

	me.onUnload = function() {
		var _values = [], i;
		_values[0] = 0;
	
		for (i = 0; i < _map.getMapTypes().length; i++) {
			if (_map.getCurrentMapType() == _map.getMapTypes()[i]) {
				_values[0] = i;
			}
		}

		_values[1] = _shownonmapped;

		SJJS.util.setCookie(_cookiename, _values);

		google.maps.Unload();
	};

	me.onLoad = function() {
		var _maptype = 0;
		var _values;
		var _groups, _sections;
		var x, y;

		_styles["Pre Construction"] = { name:"Pre Construction", width: 10, height: 20, color: "#B22222", weight: 3, opacity: 1.0, fillcolor: "#B22222", fillopacity: 0.1, fill: true };
		_styles["Construction"] = { name:"Construction", width: 10, height: 20, color: "#1874CD", weight: 3, opacity: 1.0, fillcolor: "#1874CD", fillopacity: 0.1, fill: true };
		_styles["Completed"] = { name:"Completed", width: 10, height: 20, color: "#66CD00", weight: 3, opacity: 1.0, fillcolor: "#66CD00", fillopacity: 0.1, fill: true };
		_styles["Highlight"] = { name:"Highlight", width: 10, height: 20, color: _highlightcolor, weight: 3, opacity: 1.0, fillcolor: _highlightcolor, fillopacity: 0.1, fill: true };
		_styles["CD"] = {color: "#555555", weight: 2, opacity: 1.0, fillcolor: "#FF5555", fillopacity: 0.07, fill:true};
		_styles["SatPre Construction"] = { name:"Pre Construction", width: 10, height: 20, color: "#EE5C42", weight: 3, opacity: 1.0, fillcolor: "#EE5C42", fillopacity: 0.1, fill: true };
		_styles["SatConstruction"] = { name:"Construction", width: 10, height: 20, color: "#33A1DE", weight: 3, opacity: 1.0, fillcolor: "#33A1DE", fillopacity: 0.1, fill: true };
		_styles["SatCompleted"] = { name:"Completed", width: 10, height: 20, color: "#BCED91", weight: 3, opacity: 1.0, fillcolor: "#BCED91", fillopacity: 0.1, fill: true };
		_styles["SatHighlight"] = { name:"Highlight", width: 10, height: 20, color: _highlightcolor, weight: 3, opacity: 1.0, fillcolor: _highlightcolor, fillopacity: 0.1, fill: true };
		_styles["SatCD"] = {color: "#DDDDDD", weight: 3, opacity: 1.0, fillcolor: "#DDDDDD", fillopacity: 0.07, fill:true};
		_styles["TerPre Construction"] = { name:"Pre Construction", width: 10, height: 20, color: "#B22222", weight: 3, opacity: 1.0, fillcolor: "#B22222", fillopacity: 0.1, fill: true };
		_styles["TerConstruction"] = { name:"Construction", width: 10, height: 20, color: "#1874CD", weight: 3, opacity: 1.0, fillcolor: "#1874CD", fillopacity: 0.1, fill: true };
		_styles["TerCompleted"] = { name:"Completed", width: 10, height: 20, color: "#66CD00", weight: 3, opacity: 1.0, fillcolor: "#66CD00", fillopacity: 0.1, fill: true };
		_styles["TerHighlight"] = { name:"Highlight", width: 10, height: 20, color: _highlightcolor, weight: 3, opacity: 1.0, fillcolor: _highlightcolor, fillopacity: 0.1, fill: true };
		_styles["TerCD"] = {color: "#555555", weight: 2, opacity: 1.0, fillcolor: "#FF5555", fillopacity: 0.07, fill:true};

		SJJS.util.Event.addDomListener(window, "unload", me.onUnload);
		SJJS.util.Event.addDomListener(window, "resize", me.resizeMap);

		me.resizeMap();
		_map = SJJS.map.createMap("Gv2", "map_canvas")
		if (_map) {
			_overlays = new GISOverlayManager(_map);
			me.overlays = _overlays;
			_maptype = 0;
	
			_values = SJJS.util.getCookie(_cookiename);
			if (_values[0]) {
				x = _map.getMapTypes()[_values[0]].getName();
				if (x === "Satellite" || x === "Hybrid") {
					_curmaptype = "Sat";
				} else if (x === "Terrain") {
					_curmaptype = "Ter";
				}
				_maptype = _values[0];
			}
			if (_values[1]) {
				if (_values[1] === "true") {
					_shownonmapped = true;
				} else {
					_shownonmapped = false;
				}
			}

			if (document.getElementById("map_canvas").offsetHeight < 200) {
				_zoomcontrol = new google.maps.SmallZoomControl3D();
			} else {
				_zoomcontrol = new google.maps.LargeMapControl3D();
			}
			_map.addControl(_zoomcontrol);
			_map.addMapType(G_PHYSICAL_MAP);
			_map.setMapType(_map.getMapTypes()[_maptype]);
			_map.addControl(new google.maps.ScaleControl());

			google.maps.Event.addListener(_map, "maptypechanged", function() {
				var _curtype = _map.getCurrentMapType().getName();
				_curmaptype = "";
				if (_curtype === "Satellite" || _curtype === "Hybrid") {
					_curmaptype = "Sat";
				} else if (_curtype === "Terrain") {
					_curmaptype = "Ter";
				}

				_overlays.get("cp").setStyleByAttribute("groupname", "Pre Construction", _styles[_curmaptype + "Pre Construction"]);
				_overlays.get("cp").setStyleByAttribute("groupname", "Construction", _styles[_curmaptype + "Construction"]);
				_overlays.get("cp").setStyleByAttribute("groupname", "Completed", _styles[_curmaptype + "Completed"]);
				_overlays.get("cd").setStyle(_styles[_curmaptype + "CD"]);
				_overlays.get("maincd").setStyle(_styles[_curmaptype + "CD"]);
				_overlays.get("sni").setStyle(_styles[_curmaptype + "CD"]);
				if (_overlays.get("circle")) {
					_overlays.get("circle").setStrokeStyle({color:_styles[_curmaptype + "CD"].color});
				}
			});

			google.maps.Event.addListener(_map, "zoomend", function (o, n) {
			});

			_overlays.add("address", new google.maps.Marker(new google.maps.LatLng(37.313477473067, -121.880502070713), {draggable:true}));
	
			google.maps.Event.addListener(_overlays.get("address"), "dragstart", function() {
				_overlays.removeAllBut("address");
			});
			google.maps.Event.addListener(_overlays.get("address"), "dragend", function() {
				var point = _overlays.get("address").getLatLng();
				_overlays.get("cp").setData("locator_data/CPMSData.aspx", me.getCPStyle, "cq=cwd&lat=" + point.lat() + "&lng=" + point.lng());
				_overlays.add("circle", SJJS.GMap.createCircle(point.lat(), point.lng(), {sides:30, color:_styles[_curmaptype + "CD"].color}));
				_map.addOverlay(_overlays.get("circle"));
			});

//Legend Control code
			_legend = new SJJS.GMap.Controls.GLegend("Legend", "150px");
			_map.addControl(_legend);
			for (x in _styles) {
				if (x === "Pre Construction" || x === "Construction" || x === "Completed") {
					_legend.AddEntry(_styles[x].name, { iconhtml: "<img src='" + SJJS.map.createIcon({ width: 14, height: 24, primaryColor: _styles[x].color, cornerColor: _styles[x].color, _strokeColor: "#000000" }).image + "' />" + 
						"<img src='http://chart.apis.google.com/chart?chs=14x24&cht=ls&chco=" + _styles[x].color.replace("#", "") + "&chls=4,0,0&chd=t:0,65,45,100' />", name: _styles[x].name, hascheck: false, checked: true });
				}
			}

//List Control code
			_list = new DivList({visible: false, hasdividers: true, everyotherbackcolor: SJJS.util.Color.FromHex("#E0EBF7"), highlightbackcolor: SJJS.util.Color.FromHex(_highlightcolor)});
			_maplist = new GList(_list);
			_PCon = SJJS.util.Color.FromHex(_styles["Pre Construction"].color);
			_PCon.setL(_PCon.getL() + 0.35);
			_Con = SJJS.util.Color.FromHex(_styles["Construction"].color);
			_Con.setL(_Con.getL() + 0.35);
			_Com = SJJS.util.Color.FromHex(_styles["Completed"].color);
			_Com.setL(_Com.getL() + 0.35);
			_ePCon = SJJS.util.Color.FromHex(_styles["Pre Construction"].color);
			_ePCon.setL(_ePCon.getL() + 0.50);
			_eCon = SJJS.util.Color.FromHex(_styles["Construction"].color);
			_eCon.setL(_eCon.getL() + 0.50);
			_eCom = SJJS.util.Color.FromHex(_styles["Completed"].color);
			_eCom.setL(_eCom.getL() + 0.50);
			_list.addSection("Pre Construction (0)", "Pre Construction", {sectioncolor:SJJS.util.Color.FromHex("#000000"), sectionbackcolor: _PCon, everyotherbackcolor: _ePCon});
			_list.addSection("Construction (0)", "Construction", {sectioncolor:SJJS.util.Color.FromHex("#000000"), sectionbackcolor: _Con, everyotherbackcolor: _eCon});
			_list.addSection("Completed (0)", "Completed", {sectioncolor:SJJS.util.Color.FromHex("#000000"), sectionbackcolor: _Com, everyotherbackcolor: _eCom});
			SJJS.util.Event.addListener(_list, "mouseoveritem", function(group, section) {
				_overlays.get("cp").setStyleByAttribute("prjid", group, _styles[_curmaptype + "Highlight"]);
			});
			SJJS.util.Event.addListener(_list, "mouseoutitem", function(group, section) {
				_overlays.get("cp").setStyleByAttribute("prjid", group, _styles[_curmaptype + section]);
			});
			SJJS.util.Event.addListener(_list, "clickitem", function(group, section) {
				var featurearray;

				if (group.toString().substr(0, 9) !== "NotMapped") {
					featurearray = _overlays.get("cp").getFeaturesByAttribute("prjid", group);
					if (featurearray[0].getLatLng) {
						google.maps.Event.trigger(featurearray[0], "click", featurearray[0].getLatLng());
						_map.setCenter(featurearray[0].getLatLng());
					} else {
						google.maps.Event.trigger(featurearray[0], "click", featurearray[0].getVertex(0));
						_map.setCenter(featurearray[0].getVertex(0));
					}
				} else {
					window.open("https://cpms.sanjoseca.gov/pub/PrjDetail.cfm?prj_id=" + group.substr(9), "_blank");
				}
			});
			_map.addControl(_maplist);
//Menu Control code
			/*SJJS.util.Event.addDomListener(document, "click", function(e) {
				if (!e) {
					e = event;
				}
				google.maps.Log.write(e.srcElement);
			});*/
			_menu = new SJJS.GMap.Controls.GMenuBar(_map);
			_map.addControl(_menu);
	
			addresswindow = new SJJS.GMap.Controls.AddressWindow({ top: 300, left: 350, title: "Search By Address", hidden: true, titlecolor: "#eaeaea", titlebackgroundcolor: "#003366", backgroundimage: "url('http://www.sanjoseca.gov/images/leftnav_bg.gif')" }, function(point) {
				me.removeLabels();
				_map.setCenter(point, 13);
				if (_overlays.get("circle")) {
					_overlays.remove("circle");
				}
				_overlays.get("cp").setData("locator_data/CPMSData.aspx", me.getCPStyle, "cq=cwd&lat=" + point.lat() + "&lng=" + point.lng());
				_overlays.get("address").setLatLng(point);
				_map.addOverlay(_overlays.get("address"));
				_overlays.add("circle", SJJS.GMap.createCircle(point.lat(), point.lng(), {sides:30, color:_styles[_curmaptype + "CD"].color}));
				_map.addOverlay(_overlays.get("circle"));
				_overlays.removeAllBut("cp", "circle", "address");
				_menu.checkItem("ListID", "ViewID");
			});

			me.cdwindow = new SJJS.GMap.Controls.GWindow({ width: 200, height: 100, top: 300, left: 350, title: "Search By Council District", hidden: true, titlecolor: "#eaeaea", titlebackgroundcolor: "#003366", backgroundimage: "url('http://www.sanjoseca.gov/images/leftnav_bg.gif')" });
			me.cdwindow.addPage("cdsearch.asp");
			me.sniwindow = new SJJS.GMap.Controls.GWindow({ width: 300, height: 100, top: 300, left: 350, title: "Search By SNI", hidden: true, titlecolor: "#eaeaea", titlebackgroundcolor: "#003366", backgroundimage: "url('http://www.sanjoseca.gov/images/leftnav_bg.gif')" });
			me.sniwindow.addPage("snisearch.asp");
			me.catwindow = new SJJS.GMap.Controls.GWindow({ width: 350, height: 300, top: 300, left: 350, title: "Filter", hidden: true, titlecolor: "#eaeaea", titlebackgroundcolor: "#003366", backgroundimage: "url('http://www.sanjoseca.gov/images/leftnav_bg.gif')" });
			me.catwindow.addPage("catsearch.asp");
	
			_menu.addMenuItem("ViewID", "View", {type:"menu"});
			_menu.addMenuItem("ListID", "List", {type:"check", parentid:"ViewID", checked:false});
			_menu.addMenuItem("LegendID", "Legend", {type:"check", parentid:"ViewID", checked:true});
	
			_menu.addMenuItem("OptionsID", "Options", {type:"menu", itemwidth:60, menuwidth: 120});
			_menu.addMenuItem("ResetID", "Reset", {type:"button", parentid:"OptionsID"});
			_menu.addMenuItem("FilterID", "Filter", {type:"button", parentid:"OptionsID"});
			//_menu.addMenuItem("NonmappedID", "Show Non-Mapped", {type:"check", parentid:"OptionsID", checked:_shownonmapped});
	
			_menu.addMenuItem("SearchID", "Search", {type:"menu", itemwidth:60});
			_menu.addMenuItem("AddressSearchID", "Address", {type:"button", parentid:"SearchID"});
			_menu.addMenuItem("CDSearchID", "Council District", {type:"button", parentid:"SearchID"});
			_menu.addMenuItem("SNISearchID", "SNI", {type:"button", parentid:"SearchID"});
	
			_menu.addMenuItem("HelpID", "Help", {type:"menu"});
			_menu.addMenuItem("DisclaimerID", "Disclaimer", {type:"button", parentid:"HelpID"});
	
			SJJS.util.Event.addListener(_menu, "itemclicked", function(id) {
				switch (id) {
					case "ResetID":
						me.removeLabels();
						_overlays.get("maincd").setData("locator_data/CPMSData.aspx", me.getCDStyle, "cq=cd");
						_overlays.get("centers").setData("locator_data/CPMSData.aspx", "cq=cdcenter");
						_overlays.removeAllBut("maincd", "centers");
	
						_map.setCenter(new google.maps.LatLng(37.313477473067, -121.880502070713), 11);
						_menu.uncheckItem("ListID", "ViewID");
						_list.sortList(false);
						break;
					case "FilterID":
						me.catwindow.show();
						break;
					case "AddressSearchID":
						addresswindow.show();
						break;
					case "CDSearchID":
						me.cdwindow.show();
						break;
					case "SNISearchID":
						me.sniwindow.show();
						break;
					case "DisclaimerID":
						alert("The City of San Jose does not guarantee map accuracy in depicting current conditions. The maps provided are for general information purposes and are not intended for design purposes at this time.");
						break;
				}
			});
			SJJS.util.Event.addListener(_menu, "itemchecked", function(id) {
				switch (id) {
					case "ListID":
						_list.show();
						break;
					case "LegendID":
						_legend.show();
						break;
					/*case "NonmappedID":
						_shownonmapped = true;
						//_overlays.get("notdigitized").setData("locator_data/CPMSData.aspx", "cq=cng");
						break;*/
				}
			});
			SJJS.util.Event.addListener(_menu, "itemunchecked", function(id) {
				switch (id) {
					case "ListID":
						_list.hide();
						break;
					case "LegendID":
						_legend.hide();
						break;
					/*case "NonmappedID":
						_shownonmapped = false;
						_overlays.get("notdigitized").removeData();
						_sections = ["Pre Construction", "Construction", "Completed"];
						for (y = 0; y < _sections.length; y++) {
							_groups = _list.Groups(_sections[y]);
							for (x = 0; x < _groups.length; x++) {
								if (_groups[x].substr && _groups[x].substr(0, 9) === "NotMapped") {
									_list.removeEntry(_groups[x], _sections[y]);
								}
							}
						}
						me.setListHeaders(_list);
						_list.sortList(false);
						break;*/
				}
			});

//Overlays
//Loading Bar
			_loadingoverlay = new google.maps.ScreenOverlay("loading2.gif", new google.maps.ScreenPoint(-0.5, 0.5, 'fraction', 'fraction'), new google.maps.ScreenPoint(-0.5, 0.5, 'fraction', 'fraction'), new google.maps.ScreenSize(220, 19));
			_map.addOverlay(_loadingoverlay);
			_loadingoverlay.hide();
//SNI Overlay
			_overlays.add("sni", new GISOverlay(_map));
			SJJS.util.Event.addListener(_overlays.get("sni"), "enddownload", function() {
				_map.setCenter(_overlays.get("sni").getBounds().getCenter(), _map.getBoundsZoomLevel(_overlays.get("sni").getBounds()));
			});
//CP Overlay
			_overlays.add("cp", new GISOverlay(_map));
			SJJS.util.Event.addListener(_overlays.get("cp"), "begindownload", function() {
				_loadingoverlay.show();
				_list.sortList(false);
			});
			SJJS.util.Event.addListener(_overlays.get("cp"), "enddownload", function() {
				_loadingoverlay.hide();
				me.setListHeaders(_list);
				_list.sortList(false);
			});
			SJJS.util.Event.addListener(_overlays.get("cp"), "dataremoved", function() {
				me.setListHeaders(_list);
			});
			SJJS.util.Event.addListener(_overlays.get("cp"), "featureshidden", function() {
				me.setListHeaders(_list);
				_list.sortList(false);
			});
			SJJS.util.Event.addListener(_overlays.get("cp"), "featuresshown", function() {
				me.setListHeaders(_list);
				_list.sortList(false);
			});
			SJJS.util.Event.addListener(_overlays.get("cp"), "featureadded", function(id) {
				var _featurename = _overlays.get("cp").getAttributeById(id, "name");
				var _featuregroup = _overlays.get("cp").getAttributeById(id, "prjid");
				var _group = _overlays.get("cp").getAttributeById(id, "groupname");
				_list.addEntry(_featurename, _featuregroup, {section: _group, highlightbackcolor: SJJS.util.Color.FromHex(_highlightcolor)});
				_list.setSortByGroup(_featuregroup, _featurename, _group);
			});
			SJJS.util.Event.addListener(_overlays.get("cp"), "featureremoved", function(id) {
				var _featuregroup = _overlays.get("cp").getAttributeById(id, "prjid");
				var _group = _overlays.get("cp").getAttributeById(id, "groupname");
				_list.removeEntry(_featuregroup, _group);
				me.setListHeaders(_list);
			});
			_overlays.get("cp").addEventToFeatures("mouseover", function(id, latlng) {
				_overlays.get("cp").setStyleById(id, _styles[_curmaptype + "Highlight"]);
				_list.highlightByGroup(_overlays.get("cp").getAttributeById(id, "prjid"), _overlays.get("cp").getAttributeById(id, "groupname"));
		
				if (_overlays.get("name"))
				{
					_overlays.remove("name", true);
				}

	
				if (latlng) {
					_overlays.add("name", new SJJS.GMap.Controls.Label(_overlays.get("cp").getAttributeById(id, "name"), latlng));
				} else {
					_overlays.add("name", new SJJS.GMap.Controls.Label(_overlays.get("cp").getAttributeById(id, "name"), this.getVertex(0)));
				}
				_map.addOverlay(_overlays.get("name"));
			});
			_overlays.get("cp").addEventToFeatures("mouseout", function(id, latlng) {
				var _section = _overlays.get("cp").getAttributeById(id, "groupname");
				_overlays.get("cp").setStyleById(id, _styles[_curmaptype + _section]);
				_list.unhighlightByGroup(_overlays.get("cp").getAttributeById(id, "prjid"), _section);
		
				if (_overlays.get("name"))
				{
					_overlays.remove("name", true);
				}
			});
			_overlays.get("cp").addEventToFeatures("click", function(id, latlng) {
				SJJS.util.download("locator_data/capitalprojects_description.aspx?featureid=" + _overlays.get("cp").getAttributeById(id, "id"), function(data, responseCode) {
					var _jdescription = eval( '(' + data + ')' );
					_map.openInfoWindowHtml(latlng, _jdescription.description[0].data, {maxWidth:250});
				});
			});
//CD Overlays
			_overlays.add("maincd", new GISOverlay(_map));
			_overlays.get("maincd").addEventToFeatures("click", function(id) {
				var cdid = _overlays.get("maincd").getAttributeById(id, "id") + "";
				if (cdid.length === 1) {
					cdid = "0" + cdid;
				}
				_overlays.get("cp").setData("locator_data/CPMSData.aspx", me.getCPStyle, "cq=cbycdid&districtid=" + cdid);
				_overlays.get("notdigitized").setData("locator_data/CPMSData.aspx", "cq=cngbycdid&districtid=" + cdid);
				_menu.checkItem("ListID", "ViewID");
			});

			_overlays.add("cd", new GISOverlay(_map));
			SJJS.util.Event.addListener(_overlays.get("cd"), "enddownload", function() {
				_map.setCenter(_overlays.get("cd").getBounds().getCenter(), _map.getBoundsZoomLevel(_overlays.get("cd").getBounds()));
			});

			_overlays.add("centers", new Data());
			SJJS.util.Event.addListener(_overlays.get("centers"), "rowadded", function(id) {
				var cx = _overlays.get("centers").getFieldById(id, "centerlng");
				var cy = _overlays.get("centers").getFieldById(id, "centerlat");
	
				_labels.push(new GeoLabel(new google.maps.LatLng(cy, cx), _overlays.get("centers").getFieldById(id, "id"), "#4499FF", 24, "Arial"));
				_map.addOverlay(_labels[_labels.length - 1]);
			});
			SJJS.util.Event.addListener(_overlays.get("centers"), "dataremoved", function(id) {
				me.removeLabels();
			});
//Non-mapped
			_overlays.add("notdigitized", new Data());
			SJJS.util.Event.addListener(_overlays.get("notdigitized"), "rowadded", function(id) {
				var phase = _overlays.get("notdigitized").getFieldById(id, "phase");
				var nametext = _overlays.get("notdigitized").getFieldById(id, "name") + "(Not Mapped)";
				var groupid = "NotMapped" + _overlays.get("notdigitized").getFieldById(id, "id");
				var category;
				if (phase === "Completed - Beneficial Use") {
					category = "Completed";
				} else if (phase === "Phase V - Construction") {
					category = "Construction";
				} else {
					category = "Pre Construction";
				}
				_list.addEntry(nametext, groupid, {section: category, highlightbackcolor: SJJS.util.Color.FromHex(_highlightcolor)});
				_list.setSortByGroup(groupid, nametext, category);
			});
			SJJS.util.Event.addListener(_overlays.get("notdigitized"), "dataremoved", function() {
				_sections = ["Pre Construction", "Construction", "Completed"];
				for (y = 0; y < _sections.length; y++) {
					_groups = _list.Groups(_sections[y]);
					for (x = 0; x < _groups.length; x++) {
						if (_groups[x].substr && _groups[x].substr(0, 9) === "NotMapped") {
							_list.removeEntry(_groups[x], _sections[y]);
						}
					}
				}
				me.setListHeaders(_list);
				_list.sortList(false);
			});
			SJJS.util.Event.addListener(_overlays.get("notdigitized"), "enddownload", function(id) {
				me.setListHeaders(_list);
				_list.sortList(false);
			});
			if (_shownonmapped) {
				//_overlays.get("notdigitized").setData("locator_data/CPMSData.aspx", "cq=cng");
			}
//Initialize overlays
			if (SJJS.pageInstance.RequestValue) {
				_overlays.get("cp").setData("locator_data/CPMSData.aspx", me.getCPStyle, "cq=cbycdid&districtid=" + SJJS.pageInstance.RequestValue);
				_overlays.get("notdigitized").setData("locator_data/CPMSData.aspx", "cq=cngbycdid&districtid=" + SJJS.pageInstance.RequestValue);
				_overlays.get("cd").setData("locator_data/CPMSData.aspx", me.getCDStyle, "cq=cdbyid&districtid=" + SJJS.pageInstance.RequestValue);
				_menu.checkItem("ListID", "ViewID");
			} else {
				_overlays.get("maincd").setData("locator_data/CPMSData.aspx", me.getCDStyle, "cq=cd");
				_overlays.get("centers").setData("locator_data/CPMSData.aspx", "cq=cdcenter");
			}
		}
	};
};
