//IDENTIFY FUNCTIONS
function executeIdentifyTask(evt)
{
			map.graphics.clear();
			identifyParams.geometry = evt.mapPoint;
			identifyParams.mapExtent = map.extent;
			identifyTask.execute(identifyParams, function(idResults) { addIdentifyToMap(idResults, evt); });
	
}



 function addIdentifyToMap(idResults, evt) {
 		var highlightSymbol = 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]));
				
        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 === 2) {
            var parcel = idResult.feature;
            parcel.setSymbol(highlightSymbol);
            map.graphics.add(parcel);
            if (!layer2results.displayFieldName) {layer2results.displayFieldName = idResult.displayFieldName};
            layer2results.features.push(idResult.feature);
          } else if (idResult.layerId === 3) {
		
            if (!layer3results.displayFieldName) {layer3results.displayFieldName = idResult.displayFieldName};
            layer3results.features.push(idResult.feature);
          } else if (idResult.layerId === 4) {
		 
            if (!layer4results.displayFieldName) {layer4results.displayFieldName = idResult.displayFieldName};
            layer4results.features.push(idResult.feature);
          }
        }
		
		var content = "<table border='0' width='350'><tr><td><strong>Owner Name:</strong><br></td></tr>";
		content = content + layerTabContent(layer2results,"layer2results");
		//content = content +"<br>";
		content = content + layerTabContent(layer3results,"layer3results");
		//content = content + "<br>";
		content = content + layerTabContent(layer4results,"layer4results");
		 content+="</table>";
		
		if(idResults.length > 0)
		{	
			//var copy = map.infoWindow;
			var tabs = dijit.byId("tabs");
			map.infoWindow.setContent(content);
			//map.infoWindow.style.bgcolor='#FFFFFF';
			map.infoWindow.setTitle("Identify Results");
			map.infoWindow.resize(300,140);
			map.infoWindow.show(evt.screenPoint, map.getInfoWindowAnchor(evt.screenPoint));
		}
		else
		{
			alert("No results");
		}
        
      }
      
    

      function layerTabContent(layerResults, layerName) {
		var content = "";
        switch (layerName) {
         
		  case "layer2results":
			for (var i=0, il=layerResults.features.length; i<il; i++) {
             content+="<tr><td class='style3'>"+layerResults.features[i].attributes['OwnerName']+"</td>";
            }
            content+="</tr>";
            break;
          
          case "layer3results":
          if(layerResults.features.length < 1)
            {
				content+="<tr><td class='style3'>No Voting District</td></tr>";
            }
            else
			{
				content += "";
            }
			
			for (var i=0, il=layerResults.features.length; i<il; i++) {
              content+="<tr><td class='style3'><a href='"+layerResults.features[i].attributes['URL']+"' target='commissioner_reportpanel' onclick=dijit.byId('showcommissioner').show();     >"+layerResults.features[i].attributes['WEBLABEL']+"</a></td>"; 
            }
            content+="</tr>";
            break;
          
          case "layer4results":
            if(layerResults.features.length < 1)
            {
				content+="<tr><td class='style3'>No Working District</td></tr>";
            }
            else
			{
				content += "";
            }
			for (var i=0, il=layerResults.features.length; i<il; i++) {
              content+="<tr><td class='style3'><a href='"+layerResults.features[i].attributes['URL']+"' target='commissioner_reportpanel' onclick=dijit.byId('showcommissioner').show(); >"+layerResults.features[i].attributes['WEBLABEL']+"</a></td>";
            }
           content+="</tr>";
            break;
        
		}
	
        return content;
		
      }
     
      	function showParcelReport(id) {
		    //the synchronous call to a GP service automatically sends all messages and results to a pre-defined function.
  			var reportURL = "+layerResults.features[i].attributes['URL']+";
  			dojo.byId("parcelReportFrame").src = window.open(reportURL);
            //dijit.byId("full_parcel_report").show();
			
        }

      function showIdentifyFeature(feature) {
	    map.graphics.clear();
		var copy = feature;
		var highlightSymbol;
		 switch (feature.geometry.type) {
          case "point":
				highlightSymbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_CIRCLE, 5, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255,0,0]), 1), new dojo.Color([255,0,0]));
				break;
			case "polyline":
				highlightSymbol = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255,0,0]), 3);
				break;
			case "polygon":
				highlightSymbol = 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]));
				break;
        }	
			
        feature.setSymbol(highlightSymbol);
        map.graphics.add(feature);
      }

//END IDENTIFY TASK FUNCTIONS