I am using an identify task to display attributes for multiple layers within the same ArcGIS dynamic map service. I am wondering what would be the best way of going about showing only an info window for the visible layers when clicked. Right now, all layers appear in the info window, with an arrow which allows the user to scroll through. This would be fine, however, the initial info window shows attributes for the top most layer whether it is visible or not. I only want the visible layers to appear here. I can do this with if statements, however, I would have to modify the code each time a layer is added to the map service, which I am trying to avoid. Would I need to loop through each layer to determine the visibility, and only return results for those layers that are visible? If so, could someone provide me with an example for a way to accomplish this without a bunch of if statements? I have tried using the LAYER_OPTION_VISIBLE parameter, however, it does not return find any layers. Thanks in advance.