Here is a link to IRS.gov. On this page are some further links to information about hobby and business.
The 3 out of 5 year "rule" you are referring to, is that if in 3 years out of 5, the activity shows a profit, there is a presumption the activity is engaged in for profit. (for horses it is a 7 year window). That would allow the activity to be treated as a business, and losses from that business would be allowed to offset other income, generate a net operating loss, etc.
26 USC Section 183 is the governing law as to whether an activity is engaged in for profit.