gis-varna,
That code is over 2 years old... Are you sure you want to use it as a source for current development?
gis-varna,
You are going to have to check the visibleLayers property of each map service that is in the map, and use those results to set the identify parameters layerIds property. There are lots of different version of identify widgets out there in the forums and code gallery many by me and some by others that you can look at for code examples.