Close your eyes and imagine, for a moment, that you're in Las Vegas.

You're at the blackjack table. All is well, but your luck has turns, and now you're running out of money. But you still believe you're going to hit it big, so you borrow $100 from your buddy.

You ante up, the dealer gives you a card and as Lady Luck would have it, you've bust. You lost,the dealer won and you shake your head in disgust. Not only did you lose all of your own money, but you lost your friend's too.

Basically, you borrowed on margin and lost.

Buying a stock on margin is much akin to gambling in Vegas. The biggest difference is that gamblers with margin accounts generally wear suits and don't have burlesque girls offering them cocktails all day.

On "Mad Money" last week, Jim Cramer railed against margin investors, suggesting that the practice creates artificial demand. He said that the single most important indicator of the market is how much margin debt is in play -- a high level is bad, while a low level is good.

Cramer's warnings about margin debt prompted many reader emails asking for more information about this risky bet and its effect on the market. Booyah Breakdown is here to explain the gamble.

Understand the Casino

First, let's tackle the practice of how margin buying works.

To buy a stock on margin, an investor needs to ante up a minimum of $2,000 to establish a margin account, though some brokerages may require more.

The general margin rules say you can only borrow up to 50% of the stock's purchase price. But the actual amount you can borrow from your broker will depend on the balance in your account. The more you deposit, the more you can borrow.

To watch Tracy Byrnes' video take of this column, click here

This game isn't free, though. You'll owe interest on the money you borrow. The more debt you have, the bigger your interest payments. So, buying on margin is best with short-term investments.

Investors, if they know how to play the game, like buying on margin because it can help them buy shares they couldn't otherwise afford, says Randy Frederick, director of derivatives at Charles Schwab.

It's like buying a house. Hardly anyone pays cash for a house these days. So youget a loan, move in and hope that when you're ready to sell, your house appreciated enough to exceed those interest payments and leave you with a profit.

It's the same idea for stocks -- but riskier. Let's say you bought $30,000 worth of securities using $15,000 of margin debt and $15,000 of your own personal cash.

Your stock is trading at $50, and you think it's going to take off. With your $15,000 in cash,you could buy 300 shares (300 x $50 = $15,000). But since you've got a margin account to tap, youcan actually buy 600 shares (600 x $50 = $30,000).

Let's say that, finally, Lady Luck is on your side and the stock jumps 50% to $75.

Now your investment is worth $45,000 (600 shares at $75). So you decide to take the money offthe table and run. Good idea. First you need to repay the $15,000 you borrowed from your broker(plus interest and commissions, of course). Now you're left with approximately $30,000. Subtractyour initial $15,000 investment, and you've got yourself a $15,000 profit. So you made a 100%profit, even though the stock only went up 50% because you were able to borrow some money andcapitalize on the run-up.

But there's a reason the slogan says "what happens in Vegas stays in Vegas." Thingsdon't always look so pretty at 3:00 a.m.

Let's, instead, say Lady Luck decides to leave town, and your stock falls from $50 to $25. Nowyour investment is only worth $15,000 (600 shares at $25). Whoa. That's exactly how much you oweyour broker.

So what do you do? If you believe the stock will come back and decide to ride it out, yourbroker may call and ask you to put more money in your margin account. That's the dreaded "margincall" or "maintenance call."

Of course, if you don't have the money, you'll be forced to sell the stock and settle up with the broker -- interest and commissions as well. So in our example, not only did you lose your initial cash investment, you're down even more because of interest and commissions too.

Super ugly.

Keep in mind, if that stock fell in a regular nonmargin account, you'd just havea paper loss and would be able to wait it out without having to dip further into your pocket.

The House Always Wins

The NYSE reports outstanding margin debt on a monthly basis in a

section of its Web site. Cramer noted that margin debt is at high levels right now. You can see for yourself by clicking on the "January 1992 - April 2006" link on the site. A file will upload with a chart of the monthly numbers.

You'll see that at the end of April, current margin debt was around $240 billion, the highest it's been in years. It's about $50 billion up from the same time last year alone. Even more interesting, the April levels match those of January 2000 -- just two months before the good ol' tech bubble burst.

So, what does that tell you?

On the one hand, it tells you that consumer sentiment is pretty positive, says Frederick. Ifinvestors are comfortable with the current market conditions, they're willing to take on more debt because they believe their stocks will rise, and they'll easily be able to cover the loans. Thatwas the exact sentiment back in January 2000. Folks were taking chances on stocks that didn't even have income because they had profited from other start-ups with their eyes closed.

But high margin levels can lead to big problems, as Cramer noted.

If the market starts to fall, even a little, there may be some margin calls and that can cause a chain reaction, notes Jake Bernstein, founder of trade-futures.com and author of

Momentum Stock Selection: Using the Momentum Method for MaximumProfits

.

Here's how. Let's say the market starts to slump, and your stock's price drops a bit. Yourbroker may want more money in your margin account to ensure you can cover your loan. If you don't have the money, you'll be forced to sell. With your shares back in the market, the stock price will fall a bit more. That's Economics 101: When the supply of something goes up(i.e. more shares in the marketplace), the demand, and therefore the price, goes down.

But putting your shares back in the market sets off the chain reaction. As the pricegoes down, other people will get margin calls. And if they can't cover their loans, they'll beforced to sell their shares too. That means even more shares in the market. The market ends upflooded with tons of shares, and the price keeps coming down. Avalanche.

And it's at this point the pros may step in. This forced liquidation becomes a buyingopportunity for them because they know the only reason the price of the stock has fallen isthat too many people took out loans they couldn't cover, notes Bernstein. The market just hit a blip. It happens all the time. There may not have been anything fundamentally wrong with the stock in the first place. The problem was that investors had overextended themselves. That's bait for the sharks.

"We saw this happen back in early May," notes Frank Fernandez, the chief economist atthe Securities Industry Association. The emerging markets fell and that decline affected thecommodities market, which then worked its way over to the stock side. Then came the margin calls. But, again, those calls had nothing to do with the fundamentals of the actual stocks.

So with margin levels high these days, there's reason for concern. Not because companies'fundamentals are ugly, but because if people get scared about something -- the Fed raising rates,developments in the Iraq war -- they'll want to sell and get out of the market. That'll cause prices to dip and the margin calls will begin. Bring on the avalanche.

So you decide if trading on margin is for you. I, for one, don't have the stomach for it. Icry every time I lose $10 in the slot machine because I could've gotten a manicure with thatmoney.

TheStreet.com has a revenue-sharing relationship with Amazon.com under which it receives a portion of the revenue from Amazon purchases by customers directed there from TheStreet.com.

Tracy Byrnes is an award-winning writer specializing in tax and accounting issues. As a freelancer, she has written columns for wsj.com and the New York Post and her work has appeared in SmartMoney and on CBS MarketWatch. Prior to freelancing, she spent four years as a senior writer for TheStreet.com. Before that, she was an accountant with Ernst & Young. She has a B.A. in English and economics from Lehigh University and an M.B.A. in accounting from Rutgers University. Byrnes appreciates your feedback;

click here

to send her an email.