That's unfortunate! With a little time and care, the mane's and tails should come back beautifully.
What I would primarily suggest is to get the detangler called "cowboy magic" - this product does wonders and is the one I trust with my show horses.
When starting to separate and brush out the mane, make sure you are using a wider bristled brush and not a fine toothed comb. Begin by sectioning off very small bunches of the mane applying detangler, brushing, and repeating these steps over and over. Be very gentle on the tail as you don't want and over excessive amount of hair to fall out and make the tail look thin. This will take some time so be very patient! If the horse begins to get fussy give him a break to relax. Depending on the discipline and what your doing it might be easier to flip the mane and trim it just to get some extra hair off before you tackle brushing it out. (of course properly pulling and trimming it after)
Best of luck!