You've probably seen this movie before. Deep-pocketed investors swarm research labs in Silicon Valley and fledgling companies in generic office parks, searching for world-changing technologies and the promise of untold profits. Before long, the great Wall Street hype machine starts to crank into gear as a few highly buzzed stock offerings explode onto the market. Business magazines pronounce the sector as the Next Big Thing. And off in the distance, a few curmudgeonly killjoys start talking about a bubble eventually going bust.

Shades of the dot-com bubble-and-bust cycle are seen again on Wall Street, this time with a green tint. Over the past few years, the media blitz about the threat of global warming, combined with a superspike in oil prices, has enabled green-technology entrepreneurs to raise billions of dollars in venture capital. But stock investors, looking for opportunities in a down market, are pretty psyched up as well. A quick glance at the shares of First Solar, Wall Street's current favorite, is illustrative. The thin-film solar cell maker made headlines as the "Google of solar" with a share price to match. It hit $288 a share on July 16, up more than 900 percent since the start of 2007. Energy Conversion Devices, another thin-film player, has seen its shares jump more than 100 percent this year.

Fueling the fire. But whether companies are developing solar, wind, advanced biofuels, or any of a number of emerging clean-energy technologies, the combination of global economics, investor interest, and a forthcoming pro-green turn by Uncle Sam makes it hard to argue a long-run bear case against green stocks. Of course, that sort of superoptimism is itself a prerequisite for a bubble.

But, hey, plenty of money can be made before a bubble goes bust. And this one probably has a long way to go. "We're still in the very, very early stages of the game," says Brian Fan, senior research director at the Cleantech Group. "Is there a bubble? There isn't. If valuations in some publicly traded sectors are out of whack, I think it's a function of the fact there are too few opportunities for investors and there's too much demand and appetite for exposure to these technologies."

Just as investors in Chinese stocks like to point to market size as a compelling reason to snap up shares ("Hey, if XYZ Co. can capture just 1 percent of the market . . ."), so do green investors. Boosters tout most often the sheer magnitude of the energy market and the minimal penetration of any one green technology. Currently, a mere 1.5 percent of American electricity generation comes from renewable sources.

Over in Silicon Valley, stalwart venture capital funds like Kleiner Perkins Caufield & Byers and Khosla Ventures, headed by Sun Microsystems cofounder Vinod Khosla, are spreading huge bets around on a staggering variety of start-ups. In the second quarter alone, some $2 billion in venture cash flowed into the sector, according to the Cleantech Group, an all-time record, beating out a $1.8 billion influx in the third quarter of 2007. Watch the VC funds' spending for new investing ideas once markets improve and start-ups begin going public again in full force.

U.S. government support could soon be improving, too. Almost everyone agrees that the next administration will be kinder to green technology than the current one. John McCain has said he'd like to offer a $300 million prize to the inventor of a battery strong enough to power a car. Barack Obama has made investing in clean energy a core element of his economic plan. Both candidates also want to create a carbon emission cap-and-trade system, an almost seismic event for green-tech firms as companies would rush to meet new pollution regulations by adopting new technologies.

Make mine mini. So how should investors play the bubble? First, they need to understand that rather than one megabubble, a more likely scenario is that a bunch of minibubbles in various subsectors would constantly percolate, bubble, and pop.

That's certainly been the pattern so far. Ethanol makers, for instance, saw a huge jump after a massive round of venture funding in 2005. In 2006, Pacific Ethanol (backed by Microsoft's Bill Gates before his investment arm began selling last year) jumped from around $10 a share to $40 for a brief moment. It's trading under $2 today. Back in 2000, Ballard Power Systems, a fuel cell maker that embodies the first huge run-up in venture investing in the battery sector, surged to $120 a share on hopes it would win the race to power the auto sector. It trades at $4 today, having sold its automotive fuel cell business to Daimler and Ford earlier this year. Others, like VeraSun, have seen their shares slump for years.

Solar companies like SunPower and Suntech Power Holdings have nosedived more than 40 percent this year on concerns about subsidy cuts and the high cost of polysilicon used to make traditional solar cells. (First Solar's rise happened in part because it doesn't use the stuff to make its cells.) "Advanced biofuels are starting to recover," says Ted Sullivan, senior research analyst at Lux Research. "Solar is on its way down. The companies are still trading at 100 to 200 times [earnings per share]." Sullivan says the next miniboom will be in batteries and other storage technologies as demand grows for ways to hold all the energy produced using greener means.

In short, green is set to see some peaks and valleys. Still, the industry's big gains since 2004 mean near-term noise isn't worrying analysts who are still smitten with the sector's long-term prospects, even with this year's dip. "I don't think people appreciate how solar will be over the next few years and the role products will have worldwide in the energy infrastructure," says Michael Carboy, an analyst with Signal Hill. "The pullback in prices is more a reflection of a failure to understand the opportunity that the solar industry presents to the investment community over the next two years. Step two or three years out, and people will regret not owning solar stocks."

Wind power, the most established corner of the green sector, looks less volatile with most of the market in the hands of big players like General Electric, Siemens, and Spain's Gamesa. Emerging Energy Research, a consultancy, sees the wind industry growing at a 15 percent annual rate between 2007 and 2020. The Cleantech Index, a broad group of green stocks, swooned early this year but, unlike the rest of the market, managed to rebound. It's up a bit compared with a year ago.

So what could derail all this green optimism? First is the uncertain price of crude. This year's recent run to nearly $150 a barrel has been only a mild tail wind for green companies' shares. While the industry will endure even if oil prices fall back, the same can't be said for green stocks. And remember that investing in the oil industry this year would have netted you far better gains than most green investments. The iShares oil and gas exploration exchange-traded fund is up about 5 percent this year. Most green ETF's are in the red for 2008.