				// Begins the process of creating the hovering infotip for sections
				function querySectionInfoTips() {
					projectLatLong(map.extent.getCenter());
					
					if (map.getLevel() >= 10) {
						//create query task with url to map service
						queryTask = new esri.tasks.QueryTask("http://206.248.207.3/ArcGIS/rest/services/ADHSWMAS/MapServer/6");

						//create query filter
						query = new esri.tasks.Query();    
						query.returnGeometry = true;
						query.outFields = ["ARC.DBO.Estimate2005.SECTIONID", "ARC.DBO.Estimate2005.LRS_BEGINN", "ARC.DBO.Estimate2005.LRS_ENDING"];
						query.geometry = map.extent;
						query.spatialRelationship = esri.tasks.Query.SPATIAL_REL_INTERSECTS;
						
						infoTemplate = new esri.InfoTemplate("${ARC.DBO.Estimate2005.SECTIONID}", "BMP: ${ARC.DBO.Estimate2005.LRS_BEGINN}<br />EMP: ${ARC.DBO.Estimate2005.LRS_ENDING}");
						
						queryTask.execute(query, displaySectionInfoTips);
					}
				}
				
				function displaySectionInfoTips(results) {
					//remove all graphics on the maps graphics layer
					map.graphics.clear();
					
					if (dojo.byId('info').style.visibility == 'visible') {
						dojo.fadeOut({node : 'info', duration: 500, easing: dojo.fx.easing.easeOut, onEnd: function(){dojo.byId('info').style.visibility='hidden';}}).play();
					}
					
					//var features = featureSet.features;

					//QueryTask returns a featureSet.  Loop through features in the featureSet and add them to the map.
					for (var i=0, il=results.features.length; i<il; i++) {
						//Get the current feature from the featureSet.
						//Feature is a graphic
						var graphic = results.features[i];
						graphic.setSymbol(symbol);
						
						//Set the infoTemplate.
						graphic.setInfoTemplate(infoTemplate);
						
						//Add graphic to the map graphics layer.
						map.graphics.add(graphic);
					}
					
					// disconnect all the handlers for the graphics layer
					dojo.disconnect(sectionClick_handler);
					dojo.disconnect(sectionMouseMove_handler);
					dojo.disconnect(sectionMouseOut_handler);
					
					// do the identify on the section when clicked
					sectionClick_handler = dojo.connect(map.graphics, "onClick", sectionClick);
					
					// show infotips on mouseover and hide on mouseout
					sectionMouseMove_handler = dojo.connect(map.graphics, "onMouseMove", sectionMouseMove);
					sectionMouseOut_handler = dojo.connect(map.graphics, "onMouseOut", sectionMouseOut);
				}
				
				// First step of the Identify/Info tool
				// On click, highlights the selected section, queries the section for more detail
				function sectionClick(evt) {
					var g = evt.graphic;
					
					for (var i=0, il=map.graphics.graphics.length; i<il; i++) {
						// if hover/blue/width:32 or if selected/orange/width:33, make the feature transparent (deselect the graphic)
						if ((map.graphics.graphics[i].symbol.width == 32) || (map.graphics.graphics[i].symbol.width == 33)) {
							map.graphics.graphics[i].setSymbol(new esri.symbol.CartographicLineSymbol(esri.symbol.CartographicLineSymbol.STYLE_SOLID, new dojo.Color([0,175,200,0.01]), 31, esri.symbol.CartographicLineSymbol.CAP_ROUND));
						}
					}
					
					g.setSymbol(new esri.symbol.CartographicLineSymbol(esri.symbol.CartographicLineSymbol.STYLE_SOLID, new dojo.Color([255,115,0,0.5]), 33, esri.symbol.CartographicLineSymbol.CAP_ROUND));
					
					// Query the point
					
					//create query task with url to map service
					queryTask = new esri.tasks.QueryTask("http://206.248.207.3/ArcGIS/rest/services/ADHSWMAS/MapServer/6");

					//create query filter
					query = new esri.tasks.Query();    
					query.returnGeometry = false;
					query.outFields = ["ARC.DBO.Estimate2005.SECTIONID", "ARC.DBO.Estimate2005.LRS_BEGINN", "ARC.DBO.Estimate2005.LRS_ENDING", "ARC.DBO.Estimate2005.DEV_STATUS", "ARC.DBO.Estimate2005.FIN_CODE", "ARC.DBO.Estimate2005.SECTION_LE", "ARC.DBO.Estimate2005.URBAN_CODE", "ARC.DBO.Estimate2005.FIPS_STATE", "ARC.DBO.Estimate2005.FIPS_CNTY_", "ARC.DBO.Estimate2005.CONGRESS", "ARC.DBO.Estimate2005.HPMS_INV_R", "ARC.DBO.Estimate2005.HPMS_SUB_R", "ARC.DBO.Estimate2005.HPMS_SIGN_", "ARC.DBO.Estimate2005.STRIP_MAP_", "ARC.DBO.Estimate2005.EST_SECTIO", "ARC.DBO.Estimate2005.EST_SECT_1", "ARC.DBO.Estimate2005.DSGN_SPD", "ARC.DBO.Estimate2005.ADT_BASE", "ARC.DBO.Estimate2005.ADT_2000", "ARC.DBO.Estimate2005.DSGN_YR", "ARC.DBO.Estimate2005.ADT", "ARC.DBO.Estimate2005.DHV", "ARC.DBO.Estimate2005.TRUCK_DHV_", "ARC.DBO.Estimate2005.TRUCK_ADT_", "ARC.DBO.Estimate2005.DDFACTOR_P", "ARC.DBO.Estimate2005.NO_OF_LANE", "ARC.DBO.Estimate2005.ULT_NO_OF_", "ARC.DBO.Estimate2005.XSECT_REF", "ARC.DBO.Estimate2005.ACCESS_CON", "ARC.DBO.Estimate2005.ROW_WIDTH", "ARC.DBO.Estimate2005.MEDIAN_WID", "ARC.DBO.Estimate2005.PE_LOC", "ARC.DBO.Estimate2005.PE_DSGN", "ARC.DBO.Estimate2005.ROW_ACQ", "ARC.DBO.Estimate2005.ROW_RELOC", "ARC.DBO.Estimate2005.UTIL_ADJ", "ARC.DBO.Estimate2005.ERSN_CNTL", "ARC.DBO.Estimate2005.SURFACE", "ARC.DBO.Estimate2005.RR_GRADE", "ARC.DBO.Estimate2005.HWY_GRADE_", "ARC.DBO.Estimate2005.INTERCHG", "ARC.DBO.Estimate2005.BRTUNWALL", "ARC.DBO.Estimate2005.TC_DEVICES", "ARC.DBO.Estimate2005.ENV_MIT", "ARC.DBO.Estimate2005.LANDSCAPE", "ARC.DBO.Estimate2005.OVERLOOKS", "ARC.DBO.Estimate2005.OTHER_COST", "ARC.DBO.ESTIMATE2005PERCENTAGE.PERCENTAGE"];
					query.where = "ARC.DBO.Estimate2005.SECTIONID = '" + g.getTitle() + "'";
					query.geometry = map.extent;
					query.spatialRelationship = esri.tasks.Query.SPATIAL_REL_INTERSECTS;
					//query.geometry = g.geometry;
					//query.spatialRelationship = esri.tasks.Query.SPATIAL_REL_WITHIN;
					
					queryTask.execute(query, displayInfo);
					

				}
				
				// Creates Information Details and shows window
				function displayInfo(results) {
					var foo1, foo2 = "";
					var tbl = "<table style='width: 500px; border: 1px solid black; border-collapse: collapse;'>";
					var rowstart = "<tr>";
					var rowend = "</tr>";
					
					var s = "";
					for (var i=0, il=results.features.length; i<il; i++) {
						//alert(results.fieldAliases["LRS_BEGINN"]);
						
						var fa = results.features[i].attributes;
						for (att in fa) {
							s = s + fa[att] + "\n";
							
						}
					}
					
					var status, status_color, status_desc = "";
					status = String(fa["ARC.DBO.Estimate2005.DEV_STATUS"]).substring(0,1);
					
					switch (status) {
						case ("N"):
							status_desc = "NP"
							status_color = "white";
							break;
						case ("1"):
							status_desc = "Completed"
							status_color = "lightgreen";
							break;
						case ("3"):
							if (fa["ARC.DBO.Estimate2005.DEV_STATUS"] == "3A2") {
								status_desc = "Final Construction";
								status_color = "#EEDD82";
							}
							else {
								status_desc = "Stage Construction";
								status_color = "#EEDD82";
							}
							break;
						case ("4"):
							status_desc = "Design/RoW";
							status_color = "lightskyblue";
							break;
						case ("5"):
							status_desc = "Location Study";
							status_color = "lightpink";
							break;
					}
					
					foo1 = tbl;
					foo1 += composeRow("<div style='font-weight:bold;'>Section ID</div>", "<div style='font-weight:bold;'>" + fa["ARC.DBO.Estimate2005.SECTIONID"] + "</div>");
					foo1 += composeRowAlt("<div style='font-weight:bold;'>LRS Milepoint: Beginning/Ending</div>", "<div style='font-weight:bold;'>" + fa["ARC.DBO.Estimate2005.LRS_BEGINN"].toFixed(3) + "/" + fa["ARC.DBO.Estimate2005.LRS_ENDING"].toFixed(3) + "</div>");
					
					foo1 += composeRowCustom("<div style='font-weight:bold;'>Status</div>", "<div style='font-weight:bold;'>" + status_desc + "</div>", "#EEEEEE", status_color);
					foo1 += composeRowAlt("<div style='margin:-2px; padding:2px; border-top: 1px solid #0000cc'>1. Finance Code</div>", "<div style='margin:-2px; padding:2px; border-top: 1px solid #0000cc'>" + fa["ARC.DBO.Estimate2005.FIN_CODE"] + "</div>");
					
					foo1 += composeRow("2. Section Length (miles)", fa["ARC.DBO.Estimate2005.SECTION_LE"]);
					foo1 += composeRowAlt("3. Class/Urban Code", fa["ARC.DBO.Estimate2005.URBAN_CODE"]);
					
					foo1 += composeRow("4. Location:", "&nbsp;");
					foo1 += composeRowAlt("---- a. FIPS State/County/Congressional", fa["ARC.DBO.Estimate2005.FIPS_STATE"] + "/" + fa["ARC.DBO.Estimate2005.FIPS_CNTY_"] + "/" + fa["ARC.DBO.Estimate2005.CONGRESS"]);
					foo1 += composeRow("---- b. HPMS Route/Subroute", fa["ARC.DBO.Estimate2005.HPMS_INV_R"] + "/" + fa["ARC.DBO.Estimate2005.HPMS_SUB_R"]);
					foo1 += composeRowAlt("---- c. HPMS Signed Route/Strip Map #", fa["ARC.DBO.Estimate2005.HPMS_SIGN_"] + "/" + fa["ARC.DBO.Estimate2005.STRIP_MAP_"]);
					
					foo1 += composeRow("5. Estimate Section/NHS Designation", fa["ARC.DBO.Estimate2005.EST_SECTIO"] + "/" + fa["ARC.DBO.Estimate2005.EST_SECT_1"]);
					foo1 += composeRowAlt("6. Design Speed (mph)", fa["ARC.DBO.Estimate2005.DSGN_SPD"]);
					foo1 += composeRow("7. Traffic:", "&nbsp;");
					foo1 += composeRowAlt("---- a. ADT-Base Year (2005)", fa["ARC.DBO.Estimate2005.ADT_BASE"]);
					foo1 += composeRow("---- b. ADT-Year 2015", fa["ARC.DBO.Estimate2005.ADT_2000"]);
					
					foo1 += composeRowAlt("---- c. Design Year", fa["ARC.DBO.Estimate2005.DSGN_YR"]);
					foo1 += composeRow("---- d. ADT-Design Year", fa["ARC.DBO.Estimate2005.ADT"]);
					foo1 += composeRowAlt("---- e. DHV-Design Year", fa["ARC.DBO.Estimate2005.DHV"]);
					foo1 += composeRow("---- f. % Truck Design Year (DHV)", fa["ARC.DBO.Estimate2005.TRUCK_DHV_"]);
					foo1 += composeRowAlt("---- g. % Truck Design Year (ADT)", fa["ARC.DBO.Estimate2005.TRUCK_ADT_"]);
					foo1 += composeRow("---- h. Directional Distribution Factor", fa["ARC.DBO.Estimate2005.DDFACTOR_P"]);
					foo1 += composeRowAlt("8. Number of Lanes to be Constructed this Estimate", fa["ARC.DBO.Estimate2005.NO_OF_LANE"]);
					foo1 += composeRow("9. Ultimate Number of Through Traffic Lanes", fa["ARC.DBO.Estimate2005.ULT_NO_OF_"]);
					foo1 += composeRowAlt("10. Typical X-Section of Reference/Access Control", fa["ARC.DBO.Estimate2005.XSECT_REF"] + "/" + fa["ARC.DBO.Estimate2005.ACCESS_CON"]);
					foo1 += composeRow("11. Right-of-Way Width (ft), prevailing", fa["ARC.DBO.Estimate2005.ROW_WIDTH"]);
					foo1 += composeRowAlt("12. Median Width (ft), prevailing", fa["ARC.DBO.Estimate2005.MEDIAN_WID"]);
					foo1 += composeRow("13. Status of Development (Figure 4)", fa["ARC.DBO.Estimate2005.DEV_STATUS"]);
					foo1 += "</table>";
					
					foo2 = tbl;
					foo2 += composeRow("<b>Section ID", "<b>" + fa["ARC.DBO.Estimate2005.SECTIONID"]);
					foo2 += composeRowAlt("<b>LRS Milepoint: Beginning/Ending", "<b>" + fa["ARC.DBO.Estimate2005.LRS_BEGINN"].toFixed(3) + "/" + fa["ARC.DBO.Estimate2005.LRS_ENDING"].toFixed(3));
					foo2 += composeRowCustom("<b>Status", "<b>" + status_desc + "</div>", "#EEEEEE", status_color);
					
					foo2 += composeRowAlt("<div style='margin:-2px; padding:2px; border-top: 1px solid #0000cc'>14. Preliminary Engineering:</div>", "<div style='margin:-2px; padding:2px; border-top: 1px solid #0000cc'>&nbsp;</div>");
					foo2 += composeRow("---- a. Location", fa["ARC.DBO.Estimate2005.PE_LOC"]);
					foo2 += composeRowAlt("---- b. Design", fa["ARC.DBO.Estimate2005.PE_DSGN"]);
					foo2 += composeRow("15. Right-of-Way:", "&nbsp;");
					foo2 += composeRowAlt("---- a. Acquisition", fa["ARC.DBO.Estimate2005.ROW_ACQ"]);
					foo2 += composeRow("---- b. Relocation", fa["ARC.DBO.Estimate2005.ROW_RELOC"]);
					foo2 += composeRowAlt("<div style='margin:-2px; padding:2px; border-bottom: 1px solid #0000cc'>16. Utility Adjustments</div>", "<div style='margin:-2px; padding:2px; border-bottom: 1px solid #0000cc'>" + fa["ARC.DBO.Estimate2005.UTIL_ADJ"] + "<div>");
					
					var SubTotal = 0;
					foo2 += composeRow("17. Erosion Control/Clear/Grade/Drain/Minor Structure", fa["ARC.DBO.Estimate2005.ERSN_CNTL"]);
					SubTotal += fa["ARC.DBO.Estimate2005.ERSN_CNTL"];
					foo2 += composeRowAlt("18. Subbase, Base, Surfacing, Shoulders", fa["ARC.DBO.Estimate2005.SURFACE"]);
					SubTotal += fa["ARC.DBO.Estimate2005.SURFACE"];
					foo2 += composeRow("19. Railroad Grade Seperations", fa["ARC.DBO.Estimate2005.RR_GRADE"]);
					SubTotal += fa["ARC.DBO.Estimate2005.RR_GRADE"];
					foo2 += composeRowAlt("20. Highway Grade Seperations without Ramps", fa["ARC.DBO.Estimate2005.HWY_GRADE_"]);
					SubTotal += fa["ARC.DBO.Estimate2005.HWY_GRADE_"];
					foo2 += composeRow("21. Interchanges", fa["ARC.DBO.Estimate2005.INTERCHG"]);
					SubTotal += fa["ARC.DBO.Estimate2005.INTERCHG"];
					foo2 += composeRowAlt("22. Other Bridges, Tunnels, and Walls", fa["ARC.DBO.Estimate2005.BRTUNWALL"]);
					SubTotal += fa["ARC.DBO.Estimate2005.BRTUNWALL"];
					foo2 += composeRow("23. Traffic Control", fa["ARC.DBO.Estimate2005.TC_DEVICES"]);
					SubTotal += fa["ARC.DBO.Estimate2005.TC_DEVICES"]; 
					foo2 += composeRowAlt("24. Environmental Mitigation", fa["ARC.DBO.Estimate2005.ENV_MIT"]);
					SubTotal += fa["ARC.DBO.Estimate2005.ENV_MIT"];
					foo2 += composeRow("25. Roadside Improvements", "&nbsp;");
					foo2 += composeRowAlt("---- a. Landscape Planting", fa["ARC.DBO.Estimate2005.LANDSCAPE"]);
					SubTotal += fa["ARC.DBO.Estimate2005.LANDSCAPE"];
					foo2 += composeRow("---- b. Rest Area, Overlooks", fa["ARC.DBO.Estimate2005.OVERLOOKS"]);
					SubTotal += fa["ARC.DBO.Estimate2005.OVERLOOKS"];
					foo2 += composeRowAlt("<div style='margin:-2px; padding:2px; border-bottom: 1px solid #0000cc'>26. All Other Items</div>", "<div style='margin:-2px; padding:2px; border-bottom: 1px solid #0000cc'>" + fa["ARC.DBO.Estimate2005.OTHER_COST"] + "</div>");
					SubTotal += fa["ARC.DBO.Estimate2005.OTHER_COST"];
					
					foo2 += composeRow("<div style='color:#0000cc;font-weight:bold;'>27. Subtotal (lines 17 thru 26)</div>", "<div style='font-weight:bold;'>" + SubTotal + "</div>");
					
					// Special Note: We use Gaussian/Banker's Rounding
					var consEngi = (fa["ARC.DBO.ESTIMATE2005PERCENTAGE.PERCENTAGE"] / 100) * SubTotal;
					foo2 += composeRowAlt("<div style='color:#0000cc;'>28. Construction Engineering (" + fa["ARC.DBO.ESTIMATE2005PERCENTAGE.PERCENTAGE"].toFixed(3) + "% of line 27)</div>", "<div style='font-weight:bold;'>" + gaussianRound(consEngi) + "</div>");
					
					var totalCostofConstruction = SubTotal + consEngi;
					foo2 += composeRow("<div style='color:#0000cc;'>29. Total Cost of Construction (lines 27 & 28)</div>", "<div style='font-weight:bold;'>" + gaussianRound(totalCostofConstruction) + "</div>"); 
					
					var totalEstimatedCost = fa["ARC.DBO.Estimate2005.PE_LOC"] + fa["ARC.DBO.Estimate2005.PE_DSGN"] + fa["ARC.DBO.Estimate2005.ROW_ACQ"] + fa["ARC.DBO.Estimate2005.ROW_RELOC"] + fa["ARC.DBO.Estimate2005.UTIL_ADJ"] + totalCostofConstruction;
					totalEstimatedCost = gaussianRound(totalEstimatedCost * 1.05);
					foo2 += composeRowAlt("<div style='color:#0000cc;font-weight:bold;'>30. Total Estimated Cost (lines 14, 15, 16, 29 & 5% Contingency)</div>", "<div style='font-weight:bold;'>" + totalEstimatedCost + "</div>");
					
					foo2 += "</table>";
					foo2 += "<span style='font-family: Verdana; font-size: x-small; color: #0000cc; font-weight: bold;'>Estimated Cost ($1,000) per Work Classification</span>";			
					
					dojo.byId("Tab1").innerHTML = foo1;
					dojo.byId("Tab2").innerHTML = foo2;
										
					// Pop up information regarding this section
					resizeInfo();
					dojo.byId('info').style.visibility = 'visible';
					dojo.fadeIn({node : 'info', duration: 250, easing: dojo.fx.easing.easeIn}).play();
				}
				
				// On MouseMove, show the tooltip for the section
				function sectionMouseMove(evt) {
					if (evt.graphic.symbol.width != 33) {
						var g = evt.graphic;
						g.setSymbol(new esri.symbol.CartographicLineSymbol(esri.symbol.CartographicLineSymbol.STYLE_SOLID, new dojo.Color([0,175,200,0.5]), 32, esri.symbol.CartographicLineSymbol.CAP_ROUND));
						
						map.infoWindow.setContent(g.getContent());
						map.infoWindow.setTitle(g.getTitle());
						map.infoWindow.resize(100,80);
						
						var pointOffset = new esri.geometry.Point;
						
						if (map.getInfoWindowAnchor(evt.screenPoint) == "lowerleft") {
							pointOffset.x = evt.screenPoint.x - 10;
							pointOffset.y = evt.screenPoint.y + 10;
						}
						else if (map.getInfoWindowAnchor(evt.screenPoint) == "upperleft") {
							pointOffset.x = evt.screenPoint.x - 10;
							pointOffset.y = evt.screenPoint.y - 10;
						}
						else if (map.getInfoWindowAnchor(evt.screenPoint) == "upperright") {
							pointOffset.x = evt.screenPoint.x + 10;
							pointOffset.y = evt.screenPoint.y - 10;
						}
						else if (map.getInfoWindowAnchor(evt.screenPoint) == "lowerright") {
							pointOffset.x = evt.screenPoint.x + 10;
							pointOffset.y = evt.screenPoint.y + 10;
						}
						else {
							pointOffset.x = evt.screenPoint.x;
							pointOffset.y = evt.screenPoint.y;
						}
						map.infoWindow.show(pointOffset,map.getInfoWindowAnchor(evt.screenPoint));
					}
				}
				
				// On MouseOut, hide the tooltip for the section
				function sectionMouseOut(evt) {
					map.infoWindow.hide();
					// if graphic is hovered/blue, make the feature transparent (deselect the graphic)
					if (evt.graphic.symbol.width != 33) {
						evt.graphic.setSymbol(new esri.symbol.CartographicLineSymbol(esri.symbol.CartographicLineSymbol.STYLE_SOLID, new dojo.Color([0,175,200,0.01]), 31, esri.symbol.CartographicLineSymbol.CAP_ROUND));
					}
				}
				
				function composeRow(cell1, cell2) {
					r = "<tr><td style='padding:2px;font-family:Verdana;font-size:x-small;background-color:#EEEEEE; border: 1px solid black; border-top: 0px solid white; border-bottom: 0px solid white;'>" + cell1 + "</td><td style='padding:2px;font-family:Verdana;font-size:x-small;width:110px;background-color:#EEEEEE; border: 1px solid black; border-top: 0px solid white; border-bottom: 0px solid white; text-align:right;'>" + cell2 + "</td></tr>"; return r;
				}
				function composeRowAlt(cell1, cell2) {
					r = "<tr><td style='padding:2px;font-family:Verdana;font-size:x-small;background-color:#DCDCDC; border: 1px solid black; border-top: 0px solid white; border-bottom: 0px solid white;'>" + cell1 + "</td><td style='padding:2px;font-family:Verdana;font-size:x-small;width:110px;background-color:#DCDCDC; border: 1px solid black; border-top: 0px solid white; border-bottom: 0px solid white; text-align:right;'>" + cell2 + "</td></tr>"; return r;
				}
				function composeRowCustom(cell1, cell2, backcolor1, backcolor2) {
					r = "<tr><td style='padding:2px;font-family:Verdana;font-size:x-small;background-color:" + backcolor1 + "; border: 1px solid black; border-top: 0px solid white; border-bottom: 0px solid white;'>" + cell1 + "</td><td style='padding:2px;font-family:Verdana;font-size:x-small;width:110px;background-color:" + backcolor2 + "; border: 1px solid black; border-top: 0px solid white; border-bottom: 0px solid white; text-align:right;'>" + cell2 + "</td></tr>"; return r;
				}
								
				//Query Task for Corridors
				function getCorridors(state) {
					if (state != "...") {
						//create query task with url to map service
						queryTask = new esri.tasks.QueryTask("http://206.248.207.3/ArcGIS/rest/services/ADHSWMAS/MapServer/6");

						//create query filter
						query = new esri.tasks.Query();
						query.returnGeometry = false;
						query.outFields = ["ARC.DBO.Estimate2005.CORRIDOR_L", "ARC.DBO.Estimate2005.CORRIDOR_N"];
						query.where = "ARC.DBO.Estimate2005.STATE_ABBR = '" + state + "'";
						queryTask.execute(query,fillCorridors);
					}
				}
				
				
				function fillCorridors(results) {
					// clear all options from Sections combobox
					var combo = dojo.byId('cboSections');
					removeAllOptions(combo);
					// clear all options from Corridors combobox
					combo = dojo.byId('cboCorridors');
					removeAllOptions(combo);
					// create an array of corridors (number + letter); trim right whitespaces
					
					var arr = new Array();
					for (var i=0, il=results.features.length; i<il; i++) {
						var featureAttributes = results.features[i].attributes;
						for (att in featureAttributes) {
							var s = featureAttributes["ARC.DBO.Estimate2005.CORRIDOR_L"] + featureAttributes["ARC.DBO.Estimate2005.CORRIDOR_N"];
							arr[i] = s.rtrim();
						}
					}

					// Add unique and sorted values to the combobox	
					var yooneek = arr.unique();
					var sorted = yooneek.sort();
					
					for (var j=0; j<sorted.length; j++) {
						var option = document.createElement("option");  
						option.text = sorted[j];  
						option.value = sorted[j];  
						try {  
							combo.add(option, null); //Standard  
						}catch(error) {  
							combo.add(option); // IE only  
						}
					}
				}
				
				//Query Task for Sections
				function getSections(state, corridor) {
					//create query task with url to map service
					queryTask = new esri.tasks.QueryTask("http://206.248.207.3/ArcGIS/rest/services/ADHSWMAS/MapServer/6");

					//create query filter
					query = new esri.tasks.Query();    
					query.returnGeometry = true;
					query.outFields = ["ARC.DBO.Estimate2005.SECTIONID"];
					if (corridor.length == 1) {
						query.where = "ARC.DBO.Estimate2005.STATE_ABBR = '" + state + "' AND ARC.DBO.Estimate2005.CORRIDOR_L = '" + corridor.slice(0,1) + "'";
					} 
					else { 
						query.where = "ARC.DBO.Estimate2005.STATE_ABBR = '" + state + "' AND ARC.DBO.Estimate2005.CORRIDOR_L = '" + corridor.slice(0,1) + "' AND ARC.DBO.Estimate2005.CORRIDOR_N = '" + corridor.slice(1,2) + "'";
					}
					
					queryTask.execute(query,fillSections);
				}
				
				function fillSections(results) {
					// clear Sections combobox
					var combo = dojo.byId('cboSections');
					removeAllOptions(combo);
					// create an array of sections
					var arr = new Array();
					for (var i=0, il=results.features.length; i<il; i++) {
						var featureAttributes = results.features[i].attributes;
						for (att in featureAttributes) {
							var s = featureAttributes["ARC.DBO.Estimate2005.SECTIONID"];
							arr[i] = s;
						}
					}
					
					// Add unique and sorted values to the combobox
					var yooneek = arr.unique();
					var sorted = yooneek.sort();
					for (var j=0; j<sorted.length; j++) {
						var option = document.createElement("option");  
						option.text = sorted[j];  
						option.value = sorted[j];  
						try {  
							combo.add(option, null); //Standard  
						}catch(error) {  
							combo.add(option); // IE only  
						}
					}
					zoomToResults(results);
				}
				
				function removeAllOptions(selectbox) {
					var i;
					for(i=selectbox.options.length-1;i>=0;i--) {
						selectbox.remove(i);
					}
					// Add ellipsis to combobox first
					var option = document.createElement("option");  
					option.text = "...";  
					option.value = "...";
					try {  
							selectbox.add(option, null); //Standard  
						}catch(error) {  
							selectbox.add(option); // IE only  
						}
				}

				//Query Task for State/Corridor/Section
				function querySection(state, section) {
					//create query task with url to map service
					queryTask = new esri.tasks.QueryTask("http://206.248.207.3/ArcGIS/rest/services/ADHSWMAS/MapServer/6");

					//create query filter
					query = new esri.tasks.Query();
					query.returnGeometry = true;
					query.outFields = ["ARC.DBO.Estimate2005.STATE_ABBR","ARC.DBO.Estimate2005.SECTIONID"];
					query.where = "ARC.DBO.Estimate2005.STATE_ABBR = '" + state + "' AND ARC.DBO.Estimate2005.SECTIONID = '" + section + "'";
					queryTask.execute(query,zoomToSections);
				}	
				
				// query Task for state/counties so we can zoom to the ARC state
				function queryState(state) {
					//create query task with url to map service
					queryTask = new esri.tasks.QueryTask("http://206.248.207.3/ArcGIS/rest/services/ADHSWMAS/MapServer/10");

					//create query filter
					query = new esri.tasks.Query();
					query.returnGeometry = true;
					query.outFields = ["STATE"];
    var statenum, statename;
    switch (state) {
        case "AL":
            statenum = "01";
			statename = "Alabama";
            break;
        case "GA":
            statenum = "13";
			statename = "Georgia";
            break;
        case "KY":
            statenum = "21";
			statename = "Kentucky";
            break;
        case "MD":
            statenum = "24";
			statename = "Maryland";
            break;
        case "MS":
            statenum = "28";
			statename = "Mississippi";
            break;
        case "NY":
            statenum = "36";
			statename = "New York";
            break;
        case "NC":
            statenum = "37";
			statename = "North Carolina";
            break;
        case "OH":
            statenum = "39";
			statename = "Ohio";
            break;
        case "PA":
            statenum = "42";
			statename = "Pennsylvania";
            break;
        case "SC":
            statenum = "45";
			statename = "South Carolina";
            break;
        case "TN":
            statenum = "47";
            statename = "Tennessee";
			break;
        case "VA":
            statenum = "51";
			statename = "Virginia";
            break;
        case "WV":
            statenum = "54";
			statename = "West Virginia";
            break;
    }
    query.where = "STATE = '" + statename + "'";
					queryTask.execute(query,zoomToResults);
				}
				
				function zoomToSections(results) {
					var extent = esri.graphicsExtent(results.features);
					if (extent) {
						//map.setExtent(extent, true); //argument 2 verifies the extent is completely visible
						map.centerAndZoom(extent.getCenter(),12);
					}
					/*	Creates a "table" of results inside var s, and puts var s into the "info" pane	
					var s = "";
					for (var i=0, il=results.features.length; i<il; i++) {
						var featureAttributes = results.features[i].attributes;
						for (att in featureAttributes) {
							s = s + "<b>" + att + ":</b>  " + featureAttributes[att] + "<br />";
						}
					}
					dojo.byId("info").innerHTML = s;
					*/
				}
				
				function zoomToResults(results) {
					var extent = esri.graphicsExtent(results.features);
					if (extent) {
						map.setExtent(extent, true); //argument 2 verifies the extent is completely visible
					}
					/*	Creates a "table" of results inside var s, and puts var s into the "info" pane	
					var s = "";
					for (var i=0, il=results.features.length; i<il; i++) {
						var featureAttributes = results.features[i].attributes;
						for (att in featureAttributes) {
							s = s + "<b>" + att + ":</b>  " + featureAttributes[att] + "<br />";
						}
					}
					dojo.byId("info").innerHTML = s;
					*/
				}
				
				function setBaseMap(selectedMap) {
					switch (selectedMap) {
						case "ESRI StreetMap":
							if (map.getLayer("basemapOverlay") == undefined) {
								map.removeLayer(map.getLayer("basemap"));
							} else {
								map.removeLayer(map.getLayer("basemap"));
								map.removeLayer(map.getLayer("basemapOverlay"));
							}
							
							var basemapLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer", {id:"basemap"});
							map.addLayer(basemapLayer);
							
							if (map.getLayer("ADHS") != undefined) {
								map.reorderLayer(map.getLayer("ADHS"),1);
								dojo.connect(map.getLayer("ADHS"), "onUpdate", querySectionInfoTips);
							}
							break;
						case "ESRI World Imagery":
							if (map.getLayer("basemapOverlay") == undefined) {
								map.removeLayer(map.getLayer("basemap"));
							} else {
								map.removeLayer(map.getLayer("basemap"));
								map.removeLayer(map.getLayer("basemapOverlay"));
							}
							
							var basemapLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer", {id:"basemap"});
							map.addLayer(basemapLayer);
							
							if (map.getLayer("ADHS") != undefined) {
								map.reorderLayer(map.getLayer("ADHS"),1);
								dojo.connect(map.getLayer("ADHS"), "onUpdate", querySectionInfoTips);
							}
							break;
						case "ESRI USA Topographic Map":
							if (map.getLayer("basemapOverlay") == undefined) {
								map.removeLayer(map.getLayer("basemap"));
							} else {
								map.removeLayer(map.getLayer("basemap"));
								map.removeLayer(map.getLayer("basemapOverlay"));
							}
							
							var basemapLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer", {id:"basemap"});
							map.addLayer(basemapLayer);
							
							if (map.getLayer("ADHS") != undefined) {
								map.reorderLayer(map.getLayer("ADHS"),1);
								dojo.connect(map.getLayer("ADHS"), "onUpdate", querySectionInfoTips);
							}
							break;
						case "ESRI World+Transportation":
							if (map.getLayer("basemapOverlay") == undefined) {
								map.removeLayer(map.getLayer("basemap"));
							} else {
								map.removeLayer(map.getLayer("basemap"));
								map.removeLayer(map.getLayer("basemapOverlay"));
							}
						
							var basemapLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer", {id:"basemap"});
							var basemapOverlayLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/Reference/World_Transportation/MapServer", {id:"basemapOverlay"});
							map.addLayer(basemapLayer);
							map.addLayer(basemapOverlayLayer);
							
							if (map.getLayer("ADHS") != undefined) {
								map.reorderLayer(map.getLayer("ADHS"),2);
								dojo.connect(map.getLayer("ADHS"), "onUpdate", querySectionInfoTips);
							}
							break;
					}
				}
				
				function setMapTheme(selectedTheme) {
					switch (selectedTheme) {
						case "None":
							map.removeLayer(map.getLayer("ADHS"));
							map.graphics.clear();
							if (dojo.byId('info').style.visibility == 'visible') {
								dojo.fadeOut({node : 'info', duration: 500, easing: dojo.fx.easing.easeOut, onEnd: function(){dojo.byId('info').style.visibility='hidden';}}).play();
							}
							break;
						case "ADHS":
							var arcmapLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://206.248.207.3/ArcGIS/rest/services/ADHSWMAS/MapServer", {id:"ADHS"});
							map.addLayer(arcmapLayer);
							
							if (map.getLayer("basemapOverlay") == undefined) {
								map.reorderLayer(map.getLayer("ADHS"),1);
								dojo.connect(map.getLayer("ADHS"), "onUpdate", querySectionInfoTips);
							} else {
								map.reorderLayer(map.getLayer("ADHS"),2);
								dojo.connect(map.getLayer("ADHS"), "onUpdate", querySectionInfoTips);
							}
							
							break;
					}
				}
				
				function create_completion_chart() {
				    var dc = dojox.charting;
					var chartTwo = new dc.Chart2D("completion_chart");
					chartTwo.addPlot("default", {
						type: "Pie",
						font: "normal normal 6.5pt Tahoma",
						fontColor: "black",
						labelOffset: -30,
						labelStyle: "auto",
						labels: true,
						fixed: false,
						ticks: true,
						radius: 150
					}).addSeries("Series A", [{
						y: 2442,
						text: "Complete",
						stroke: "black",
						color: "lightgreen"
					},
					{
						y: 143.4,
						text: "Stage<br>Construction",
						stroke: "black",
						color: "#DDCC64"
					},
					{
						y: 109.2,
						text: "Construction<br>Underway",
						stroke: "black",
						legend: "jdjdjd",
						color: "#EEDD82"
					},
					{
						y: 122.0,
						text: "Design/RoW",
						stroke: "black",
						color: "lightskyblue"
					},
					{
						y: 273.5,
						text: "Location<br>Study",
						stroke: "black",
						color: "lightpink"
					}]);
					var anim_a = new dc.action2d.MoveSlice(chartTwo, "default");
					var anim_b = new dc.action2d.Highlight(chartTwo, "default");
					var anim_c = new dc.action2d.Tooltip(chartTwo, "default");
					chartTwo.render();
					/*
					var legendTwo = new dojox.charting.widget.Legend({
						chart: chartTwo
					},
					"completion_legend");
					*/
				}
				
				function showGoogleMap() {
					var divContent1, divContent2, URL;

					divContent1 = "<iframe scrolling='no' style='width: 1280px; height: 720px;' src='"
					divContent2 = "'></iframe>"
					URL = "google.html?";
					URL += "lat=" + GlobalPoint.y + "&";
					URL += "long=" + GlobalPoint.x + "&";
					URL += "zoom=" + (map.getLevel());
					
					var fullContent = divContent1 + URL + divContent2;
					diag = new dijit.Dialog;
					diag.titleNode.innerHTML = 'Google Maps';
					diag.setContent(fullContent);
					diag.show();
				}
				
				function projectLatLong(point){
					var gsvc = new esri.tasks.GeometryService("http://www.tedis-wv.org/ArcGIS/rest/services/Geometry/GeometryServer");
					var symbol = new esri.symbol.SimpleMarkerSymbol().setStyle(esri.symbol.SimpleMarkerSymbol.STYLE_DIAMOND);
					var graphic = new esri.Graphic(point, symbol);
					var outSR = new esri.SpatialReference({
						wkid: 4326
					});
					
					point = gsvc.project([graphic], outSR, function(features){
						pt = features[0].geometry;
						GlobalPoint = pt;
					});
				}

			
				function showBingMap() {
					var divContent1, divContent2, URL;

					divContent1 = "<iframe scrolling='no' style='width: 1280px; height: 720px;' src='"
					divContent2 = "'></iframe>"
					URL = "bing.html?";
					URL += "lat=" + GlobalPoint.y + "&";
					URL += "long=" + GlobalPoint.x + "&";
					URL += "zoom=" + (map.getLevel());

					var fullContent = divContent1 + URL + divContent2;
					diag = new dijit.Dialog;
					diag.titleNode.innerHTML = 'Bing Map';
					diag.setContent(fullContent);
					diag.show();
				}
				
				function getElementHeight(Elem) {
					if(document.getElementById) {
						var elem = document.getElementById(Elem);
					} else if (document.all){
						var elem = document.all[Elem];
					}
					xPos = elem.offsetHeight;
					return xPos;
				}

				function getElementWidth(Elem) {
					if(document.getElementById) {
						var elem = document.getElementById(Elem);
					} else if (document.all){
						var elem = document.all[Elem];
					}
					xPos = elem.offsetWidth;
					return xPos;
				}
				
				function resizeInfo() {
					var newHeight1 = getElementHeight('mapDiv') - 42;
					if (newHeight1 > 512) newHeight1 = 512;
					var newHeight2 = newHeight1 - 30;
					
					dojo.byId('info').style.height = newHeight1 + "px";
					dojo.byId('infoTabContainer').style.height = newHeight2 + "px";
					
					var params = new Object();
					params.h = newHeight2;
					dijit.byId('infoTabContainer').resize( params );
				}
				
				/*
				* Gaussian rounding (aka Banker's rounding) is a method of statistically
				* unbiased rounding. It ensures against bias when rounding at x.5 by
				* rounding x.5 towards the nearest even number. Regular rounding has a
				* built-in upwards bias.
				*/ 
				function gaussianRound(x) {
					var absolute = Math.abs(x);
					var sign     = x == 0 ? 0 : (x < 0 ? -1 : 1);
					var floored  = Math.floor(absolute);
					if (absolute - floored != 0.5) {
						return Math.round(absolute) * sign;
					}
					if (floored % 2 == 1) {
						// Closest even is up.
						return Math.ceil(absolute) * sign;
					}
					// Closest even is down.
					return floored * sign;
				}
				
				function addCommas(nStr) {
					nStr += '';
					x = nStr.split('.');
					x1 = x[0];
					x2 = x.length > 1 ? '.' + x[1] : '';
					var rgx = /(\d+)(\d{3})/;
					while (rgx.test(x1)) {
						x1 = x1.replace(rgx, '$1' + ',' + '$2');
					}
					return x1 + x2;
				}
				
				function toggleVisi(obj) {
					var el = document.getElementById(obj);
					if ( el.style.visibility != 'hidden' ) {
						el.style.visibility = 'hidden';
					}
					else {
						el.style.visibility = 'visible';
					}
				}
