If you're confused about that versus which, don't feel bad. It's one of the most common topics people ask me about. I used to work as a technical writer, and I'd often edit documents in which people used the wrong word. More than once, I'd put in the right word, only to have clients change a perfectly fine that to a which and send it back to me. In fact, having a client try to overrule my correction of a which to a that was one of the things that pushed me over the edge and made me start the Grammar Girl podcast.
Here's the deal: some people will argue that the rules are more complex and flexible than this, but I like to make things as simple as possible, so I say that you use that before a restrictive clause and which before everything else.
Restrictive Clause--That
A restrictive clause is just part of a sentence that you can't get rid of because it specifically restricts some other part of the sentence. Here's an example:
Gems that sparkle often elicit forgiveness.
The words that sparkle restrict the kind of gems you're talking about. Without them, the meaning of the sentence would change. Without them, you'd be saying that all gems elicit forgiveness, not just the gems that sparkle. (And note that you don't need commas around the words that sparkle.)
Nonrestrictive Clause--Which
A nonrestrictive clause is something that can be left off without changing the meaning of the sentence. You can think of a nonrestrictive clause as simply additional information. Here's an example:
Diamonds, which are expensive, often elicit forgiveness.
Alas, in Grammar Girl's world, diamonds are always expensive, so leaving out the words which are expensive doesn't change the meaning of the sentence. (Also note that the phrase is surrounded by commas. Nonrestrictive clauses are usually surrounded by, or preceded by, commas.) Here's another example:
There was an earthquake in China, which is bad news.
Expendable--Which
If you leave off the clause that says which is bad news, it doesn't change the meaning of the rest of the sentence.
A quick and dirty tip (with apologies to Wiccans and Hermione Granger) is to remember that you can throw out the “whiches” and no harm will be done. You use which in nonrestrictive clauses, and if you eliminate a nonrestrictive clause, the meaning of the remaining part of the sentence will be the same as it was before.
Needed--That
On the other hand, if it would change the meaning to throw out the clause, you need a that. Do all cars use hybrid technology? No. So you would say,
"Cars that have hybrid technology get great gas mileage."
Is every leaf green? No. So you would say,
"Leaves that are green contain chlorophyll.
It would change the meaning to throw out the clause in those examples, so you need a that. (Also note that the that clause isn't surrounded by commas. Restrictive clauses usually aren't set off by commas.)
Remembering to use that with restrictive clauses and which with nonrestrictive clauses is the best method, but the quick and dirty tip of using which when you could throw out the clause will also get you to the right answer most of the time.