Generally, money contributed to a corporation is considered additional paid-in capital. You can take that capital until your basis in your stock becomes zero, without any taxable effect. If you go over zero, then you have a capital gain. For instance, let's say the basis of your stock is $100, through the years you have had earnings, that have not been distributed in the amount of $20,000, then you put $30,000 into the business, the most you could take out of your Corporation without paying any taxes would be $30,000.
It's a little complicated, but I hope this helps
Craig W. Smalley, E.A.
Admitted To Practice Before The Internal Revenue Service