      var identifyTask, identifyParams, symbol;
      var layer2results, layer3results, layer4results;	 
	 
	  function init_sanitary(){
	  
	  initFunctionality2(map,tb)
	  }
	  
	  function initFunctionality2(map) {
        
		dojo.disconnect(objectconnections[0]);
		dojo.disconnect(objectconnections[1]);
		dojo.disconnect(objectconnections[2]);
		dojo.disconnect(objectconnections[3]);
		navToolbar.deactivate()
		
		objectconnections[1] = dojo.connect(map, "onClick", doIdentify2);
 
        identifyTask = new esri.tasks.IdentifyTask("http://74.93.16.209:443/Arcserver/rest/services/Southington/South_Admin_X/MapServer");
 
 
        identifyParams = new esri.tasks.IdentifyParameters();
        identifyParams.tolerance = 3;
        identifyParams.returnGeometry = true;
        identifyParams.layerIds = [7,8,9];
        identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_ALL;
 
        map.infoWindow.resize(415, 200);
        map.infoWindow.setContent(dijit.byId("tabs2").domNode);
        map.infoWindow.setTitle("Sanitary 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 doIdentify2(evt) {
        map.graphics.clear();
        identifyParams.geometry = evt.mapPoint;
        identifyParams.mapExtent = map.extent;
        identifyTask.execute(identifyParams, function(idResults) { addToMap2(idResults, evt); });
      }
 
      function addToMap2(idResults, evt) {
        layer2results = {displayFieldName:null,features:[]};
        layer3results = {displayFieldName:null,features:[]};
        layer4results = {displayFieldName:null,features:[]};
 
        for (var i=0, il=idResults.length; i<il; i++) {

          var idResult = idResults[i];

          if (idResult.layerId === 7) {

            if (!layer2results.displayFieldName) {layer2results.displayFieldName = idResult.displayFieldName};

            layer2results.features.push(idResult.feature);

          } else if (idResult.layerId === 8) {

            if (!layer3results.displayFieldName) {layer3results.displayFieldName = idResult.displayFieldName};

            layer3results.features.push(idResult.feature);

          } else if (idResult.layerId === 9) {

            if (!layer4results.displayFieldName) {layer4results.displayFieldName = idResult.displayFieldName};

            layer4results.features.push(idResult.feature);

          }

        }

        dijit.byId("layer4Tab2").setContent(layerTabContent2(layer4results,"layer4results"));
		
		dijit.byId("layer2Tab2").setContent(layerTabContent2(layer2results,"layer2results"));

        dijit.byId("layer3Tab2").setContent(layerTabContent2(layer3results,"layer3results"));

        
        map.infoWindow.show(evt.screenPoint, map.getInfoWindowAnchor(evt.screenPoint));

      }

      function layerTabContent2(layerResults, layerName) {

        var content = "";
		

		switch (layerName) {
			
			 case "layer4results":

            for (var i=0, il=layerResults.features.length; i<il; i++) {
			
				var HSCODE1 = "\"return hs.htmlExpand(this, { objectType: 'ajax'} )\""
				
				var string_pass = layerResults.features[i].attributes['Video_Link']
				string_replace2 = string_pass.replace("\\", "$")
							 			 
			 content+="<b>ID: </b>"+layerResults.features[i].attributes['ID']+"&nbsp;&nbsp;&nbsp;&nbsp;<b>Streetname : </b>"+layerResults.features[i].attributes['STREETNAME']+"</br>";
             content+="<b>Owner : </b>"+layerResults.features[i].attributes['OWNER_CODE']+"&nbsp;&nbsp;&nbsp;&nbsp;<b>Year Built: </b>"+layerResults.features[i].attributes['YEARblt']+"</br>";
			 content+="<b>Pipe Size : </b>"+layerResults.features[i].attributes['LINEDIAMETER_CODE']+"&nbsp;&nbsp;&nbsp;<b>Make: </b>"+layerResults.features[i].attributes['MATERIAL_CODE']+"&nbsp;&nbsp;&nbsp;<b>Length: </b>"+layerResults.features[i].attributes['LINELENGTH']+"</br>";
			 content+="<b>Invert In : </b>"+layerResults.features[i].attributes['INVERT_IN']+"&nbsp;&nbsp;&nbsp;<b>Invert Out: </b>"+layerResults.features[i].attributes['INVERT_OUT']+"</br>";
			 content+="<b>Slope : </b>"+layerResults.features[i].attributes['SLOPE']+"&nbsp;&nbsp;&nbsp;<b>SHEETID: </b>"+layerResults.features[i].attributes['Laserfiche_ID']+"</br>";
			 content+="<br><a href=javascript:showSanitaryVideo('"+ string_replace2  + "')>View Sanitary Pipe Video</a>&nbsp;&nbsp;&nbsp<a href=javascript:showScanName('"+ layerResults.features[i].attributes['Laserfiche_ID']  + "')>View Scan Documents</a>";
             }
            content+="</tr></table>";
            break;
		
          case "layer2results":

            for (var i=0, il=layerResults.features.length; i<il; i++) {

			  content+="<b>Manhole ID: </b>"+layerResults.features[i].attributes['ID']+"&nbsp;&nbsp;&nbsp;&nbsp;<b>Streetname : </b>"+layerResults.features[i].attributes['STREETNAME']+"</br>";
              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']+"</br>";
			  content+="<br /><b>Top Elevation : </b>"+layerResults.features[i].attributes['TOPELEV']+"</br>";
			  content+="<br /><b>Comment : </b>"+layerResults.features[i].attributes['FILECOMMEN']+"</br>";
            }
		
            content+="</tr>";
            break;
          case "layer3results":

            for (var i=0, il=layerResults.features.length; i<il; i++) {

			  content+="<b>Structure ID: </b>"+layerResults.features[i].attributes['ID']+"&nbsp;&nbsp;&nbsp;&nbsp;<b>Streetname : </b>"+layerResults.features[i].attributes['STREETNAME']+"</br>";
              content+="<br /><br /><b>Owner : </b>"+layerResults.features[i].attributes['OWNER_CODE']+"&nbsp;&nbsp;&nbsp;&nbsp;<b>Date Installed: </b>"+layerResults.features[i].attributes['DATEINSTALLED']+"</br>";
			  content+="<br /><b>Structure Type : </b>"+layerResults.features[i].attributes['BLOCKNAME']+"</br>";
			  content+="<br /><b>Comment : </b>"+layerResults.features[i].attributes['FILECOMMENT']+"</br>";
			  
            }
            content+="</tr>";
            break;

        }
        return content;
      }
 
      function showFeature_pw2(feature) {
        map.graphics.clear();
        feature.setSymbol(symbol);
        map.graphics.add(feature);
      }
	  
	  function showSanitaryVideo(SanID) {
	  
	    var reportURL = "http://www.southingtongis.com/flowplayer/index.asp?ID=" + SanID;
		dojo.byId("SanitaryVideoPage").src = reportURL;
        dijit.byId("SanitaryVideo").show();
			
        }
