      var identifyTask, identifyParams, symbol;
      var layer2results, layer3results, layer4results, layer5results, layer6results;	 

	  function initFunctionality(map) {
        
		dojo.disconnect(objectconnections[0]);
		dojo.disconnect(objectconnections[1]);
		dojo.disconnect(objectconnections[2]);
		dojo.disconnect(objectconnections[3]);
		
		objectconnections[1] = dojo.connect(map, "onClick", doIdentify);
 
        identifyTask = new esri.tasks.IdentifyTask("http://74.93.16.209:443/Arcserver/rest/services/Southington/Admin_V/MapServer");
 
 
        identifyParams = new esri.tasks.IdentifyParameters();
        identifyParams.tolerance = 3;
        identifyParams.returnGeometry = true;
        identifyParams.layerIds = [22,15,24,20,28];
        identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_ALL;
 
        map.infoWindow.resize(415, 265);
        map.infoWindow.setContent(dijit.byId("tabs").domNode);
        map.infoWindow.setTitle("Storm Sewer Information");
		
        symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255,0,0]), 2), new dojo.Color([255,255,0,0.5]));
      }
 
      function doIdentify(evt) {
        map.graphics.clear();
        identifyParams.geometry = evt.mapPoint;
        identifyParams.mapExtent = map.extent;
        identifyTask.execute(identifyParams, function(idResults) { addToMap(idResults, evt); });
      }
 
      function addToMap(idResults, evt) {
        layer2results = {displayFieldName:null,features:[]};
        layer3results = {displayFieldName:null,features:[]};
        layer4results = {displayFieldName:null,features:[]};
		layer5results = {displayFieldName:null,features:[]};
		layer6results = {displayFieldName:null,features:[]};
 
        for (var i=0, il=idResults.length; i<il; i++) {

          var idResult = idResults[i];

          if (idResult.layerId === 22) {

            if (!layer2results.displayFieldName) {layer2results.displayFieldName = idResult.displayFieldName};

            layer2results.features.push(idResult.feature);

          } else if (idResult.layerId === 15) {

            if (!layer3results.displayFieldName) {layer3results.displayFieldName = idResult.displayFieldName};

            layer3results.features.push(idResult.feature);

          } else if (idResult.layerId === 24) {

            if (!layer4results.displayFieldName) {layer4results.displayFieldName = idResult.displayFieldName};

            layer4results.features.push(idResult.feature);
			
		  } else if (idResult.layerId === 20) {

            if (!layer5results.displayFieldName) {layer5results.displayFieldName = idResult.displayFieldName};

            layer5results.features.push(idResult.feature);
		  
		  } else if (idResult.layerId === 28) {

            if (!layer6results.displayFieldName) {layer6results.displayFieldName = idResult.displayFieldName};

            layer6results.features.push(idResult.feature);

          }

        }

        dijit.byId("layer2Tab").setContent(layerTabContent(layer2results,"layer2results"));

        dijit.byId("layer3Tab").setContent(layerTabContent(layer3results,"layer3results"));

        dijit.byId("layer4Tab").setContent(layerTabContent(layer4results,"layer4results"));

		dijit.byId("layer5Tab").setContent(layerTabContent(layer5results,"layer5results"));
		
		dijit.byId("layer6Tab").setContent(layerTabContent(layer6results,"layer6results"));


        map.infoWindow.show(evt.screenPoint, map.getInfoWindowAnchor(evt.screenPoint));

      }

      function layerTabContent(layerResults, layerName) {

        var content = "";
		
		switch (layerName) {

          case "layer2results":
			  
            for (var i=0, il=layerResults.features.length; i<il; i++) {
			
			  content+="<table>";
			  content+="<tr><td><a href=\"http://74.93.16.209/webdata/southington/Outfall_Photos/"+layerResults.features[i].attributes['NearPhoto']+"\" class=\"highslide\" onclick=\"return hs.expand(this)\">";
			  content+="<IMG height='108' width='133' src='http://74.93.16.209/webdata/southington/Outfall_Photos/"+layerResults.features[i].attributes['NearPhoto']+"' </IMG></td></a>";
			  content+="<td><b>OF ID: </b>"+layerResults.features[i].attributes['OF_ID']+"";
			  content+="<br /><b>Street: </b>"+layerResults.features[i].attributes['STREETNAME']+"";
			  content+="<br /><b>Date Recorded: </b>"+layerResults.features[i].attributes['DATE_REC']+"";
			  content+="<br /><b>Owner: </b>"+layerResults.features[i].attributes['OWNER_CODE']+"";
			  content+="<br /><b>Material: </b>"+layerResults.features[i].attributes['Material']+"";
			  content+="<br /><b>Height: </b>"+layerResults.features[i].attributes['Height']+"";
			  content+="<br /><b>Width: </b>"+layerResults.features[i].attributes['Width']+"";
			  content+="<br /><b>Shape: </b>"+layerResults.features[i].attributes['OF_SHAPE']+"</td></tr></table>";
			  content+="<b>Comments : </b>"+layerResults.features[i].attributes['Descript']+"";
			  content+="<br /><br /><a href=http://74.93.16.209/webdata/southington/outfall_PDF/Location_Maps/Outfall_" + layerResults.features[i].attributes['OF_ID'] + ".pdf TARGET='_blank' >Location Map</a>";
			  content+="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=http://www.southingtongis.com/public_works/Outfall_Card.asp?ID=" + layerResults.features[i].attributes['OF_ID'] + " TARGET='_blank' >Outfall Photo Page</a><br /><br />";
		  }
		
            content+="</tr>";
            break;
          case "layer3results":

            for (var i=0, il=layerResults.features.length; i<il; i++) {

			  content+="<b>CB ID: </b>"+layerResults.features[i].attributes['CB_ID']+"&nbsp;&nbsp;&nbsp;&nbsp;<b>Streetname : </b>"+layerResults.features[i].attributes['STREETNAME']+"";
              content+="<br /><br /><b>Owner : </b>"+layerResults.features[i].attributes['OWNER_CODE']+"&nbsp;&nbsp;&nbsp;&nbsp;<b>Type : </b>"+layerResults.features[i].attributes['BLOCKNAME_']+"";
			  content+="<br /><br /><b>Date Installed : </b>"+layerResults.features[i].attributes['DATEINSTAL']+"&nbsp;&nbsp;&nbsp;&nbsp;<b>GPS Date : </b>"+layerResults.features[i].attributes['FIELD_DATE']+"<br /><br /><hr></hr><br />";
			  
            }
            content+="</tr>";
            break;
          case "layer4results":

            for (var i=0, il=layerResults.features.length; i<il; i++) {

			  
				content+="<table>";
				content+="<tr><td><a href=\"http://74.93.16.209/webdata/southington/Outfall_Photos/"+layerResults.features[i].attributes['NearPhoto']+".jpg\" class=\"highslide\" onclick=\"return hs.expand(this)\">";
				content+="<IMG height='99' width='121' src='http://74.93.16.209/webdata/southington/Outfall_Photos/"+layerResults.features[i].attributes['NearPhoto']+".jpg' </IMG></td></a>";
				content+="<td><b>DP ID: </b>"+layerResults.features[i].attributes['DP_NUM']+"";
				content+="<br /><br /><b>Street: </b>"+layerResults.features[i].attributes['STREETNAME']+"";
				content+="<br /><br /><b>Date Recorded: </b>"+layerResults.features[i].attributes['DATE_REC']+"";
				content+="<br /><br /><b>Owner: </b>"+layerResults.features[i].attributes['OWNER_CODE']+"</td></tr></table>";
				content+="<b>Comments : </b>"+layerResults.features[i].attributes['Directions']+"";
				content+="<br /><br /><a href=javascript:showDPVideo('"+  layerResults.features[i].attributes['FilmID'] + "')>Location Video </a>";
				content+="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=http://www.southingtongis.com/public_works/detention_card.asp?ID=" + layerResults.features[i].attributes['DP_NUM'] + " TARGET='_blank' >Detail Photo Page</a>";
			}

            break;
	      case "layer5results":

            for (var i=0, il=layerResults.features.length; i<il; i++) {

			  content+="<b>STM MH ID: </b>"+layerResults.features[i].attributes['STMMH_ID']+"&nbsp;&nbsp;&nbsp;&nbsp;<b>Streetname : </b>"+layerResults.features[i].attributes['STREETNAME']+"";
              content+="<br /><br /><b>Owner : </b>"+layerResults.features[i].attributes['OWNER_CODE']+"&nbsp;&nbsp;&nbsp;&nbsp;<b>Date Installed: </b>"+layerResults.features[i].attributes['DATEINSTAL']+"";
			  content+="<br /><br /><b>GPS Date : </b>"+layerResults.features[i].attributes['GPS_DATE']+"&nbsp;&nbsp;&nbsp;&nbsp;<b>Access: </b>"+layerResults.features[i].attributes['ACCESS']+"<br /><br /><hr></hr><br />";
			  
            }
            content+="</tr>";
            break;
          case "layer6results":

            for (var i=0, il=layerResults.features.length; i<il; i++) {

			  content+="<b>ID: </b>"+layerResults.features[i].attributes['ID']+"&nbsp;&nbsp;&nbsp;&nbsp;<b>Streetname : </b>"+layerResults.features[i].attributes['STREETNAME']+"";
              content+="<br/><br/><b>Owner : </b>"+layerResults.features[i].attributes['OWNER_CODE']+"&nbsp;&nbsp;&nbsp;&nbsp;<b>Year Built: </b>"+layerResults.features[i].attributes['YEARblt']+"";
			  content+="<br/><br /><b>Pipe Size : </b>"+layerResults.features[i].attributes['LINEDIAMET']+"&nbsp;&nbsp;&nbsp;<b>Make: </b>"+layerResults.features[i].attributes['MATERIAL_C']+"&nbsp;&nbsp;&nbsp;<b>Length: </b>"+layerResults.features[i].attributes['LINELENGTH']+"";
			  content+="<br/><br /><b>Invert In : </b>"+layerResults.features[i].attributes['INVERT_IN']+"&nbsp;&nbsp;&nbsp;<b>Invert Out: </b>"+layerResults.features[i].attributes['INVERT_OUT']+"";
			  content+="<br/><br /><b>Slope : </b>"+layerResults.features[i].attributes['SLOPE']+"<br /><br /><hr></hr><br />";
        
			}
            content+="</tr>";
            break;
        }
        return content;
      }
 
      function showFeature_pw(feature) {
        map.graphics.clear();
        feature.setSymbol(symbol);
        map.graphics.add(feature);
      }
	  
	  function showDPVideo(dpid) {
	  
	    var reportURL = "http://www.southingtongis.com/public_works/detention_video.asp?ID=" + dpid;
  	 	dojo.byId("DPVideoPage").src = reportURL;
        dijit.byId("DPVideo").show();
			
        }