Most investors fear or simply ignore companies in bankruptcy. And that's what makes them like Disneyland for many value investors. They know there are many ways to take advantage of the irrational behavior of the fearful and make money.

Here's why bankrupt companies are undervalued in the first place. Imagine that Billy, a casual retail investor, is looking for a mutual fund to throw some of his cash into. He might check out its Morningstar rating to see whether it has a four- or five-star rating. He then might glance at a listing of the fund's latest quarterly holdings to see what the fund manager likes to invest in. He might be perfectly comfortable with the names he recognizes -- unless he sees a company like Enron or Adelphia. Then he'll think to himself: "Didn't that company go bankrupt?" Billy doesn't like funds whose stock picks go bankrupt. Better take a pass.

Even after companies emerge from bankruptcy, the stigma of having gone through the process, the lack of "clean" financial statements, and the general deficiency of positive publicity all contribute to undervaluation.

What not to invest in
This isn't to say that all companies in or emerging from bankruptcy are undervalued. After all, there are usually very good reasons why companies fall into bankruptcy in the first place. While bankruptcy can help a company out of a difficult situation, it can't change business economics in the long term.

For instance, some companies may not have a competitive advantage or moat because they're in a commodity industry. Perhaps their whole business was based on accounting fraud, as Enron's was. Or perhaps the nature of their business is one big black box, and the tangled web of bankruptcy is just far too daunting to unravel.

I've gotten my hands dirty investing in subprime-mortgage lenders before, but I'm way too intimidated to touch New Century, given the enormous leverage and lack of information. I'll leave that one for someone smarter than I. To summarize, I don't advise investing in bad businesses or instances where there are too many unknowns -- especially if management or the accounting cannot be trusted.

When not to invest
I also generally don't advise investing in companies that are currently in bankruptcy, unless you have a lot of experience with the legal and accounting nuances involved. Although sometimes the juiciest returns come from investing in the debt of bankrupt companies, I don't have the knowledge or experience to dive in until the company has managed to get at least far enough to emerge from bankruptcy.

Hate the capital structure, not the company
Every now and then, a perfectly good company with a decent economic moat will go into bankruptcy because of a bad capital structure or even a confluence of unfortunate events. Oftentimes, investors confuse bad companies with bad capital structures.

When a company files for bankruptcy, the stockholders usually lose everything, and debtholders fight to split up rest of the pie. Oftentimes, junior debtholders agree to take new equity in exchange for their old debt, a move that lowers the company's overall debt level. If during this long process interest rates have fallen, the company may also be able to refinance at substantially lower rates.

Meanwhile, a judge oversees this whole process and tries to make sure that the process is fair to everyone involved -- and, more importantly, that the company can survive once it emerges from bankruptcy. Thus, the company often emerges with a much more rational capital structure. Often, the company is then like a coiled spring, because with a better capital structure it can afford to do things it couldn't before, such as advertise, upgrade plants, and boost employee morale.

Special situations
Sometimes, companies have no choice but to declare bankruptcy to protect themselves from outstanding legal claims. Litigation forced entire industries to declare bankruptcy to stave off asbestos lawsuits, for example. However, many of those companies were able to resolve the litigation, put those claims behind them forever, and, upon emerging from bankruptcy, find themselves ready to take off.

If you're looking at bankrupt companies, I believe you should look for those that have perfectly decent businesses that either need to fix their capital structure or resolve uncertain situations. Some companies that have recently emerged from bankruptcy whose share prices have rocketed higher are Armstrong Worldwide (NYSE:AWI), Winn-Dixie (NASDAQ:WINN), and Kaiser Aluminum (NASDAQ:KALU). Some other similar situations where the share prices have yet to take off and could offer value include Owens Corning (NYSE:OC) and USG (NYSE:USG). Happy hunting.

Related Foolishness:

USG is an Inside Value recommendation. Try any one of our investing services free for 30 days.

Fool contributor Emil Lee is an analyst and a disciple of value investing. He doesn't own shares in any of the companies mentioned above. Emil appreciates your comments, concerns, and complaints. The Motley Fool has a disclosure policy.