There are so many things that “Ted” gets right that the things it gets wrong are baffling. The impertinently vulgar live-action directorial debut from “Family Guy” creator Seth MacFarlane cleverly subverts a lot of movie tropes, suggesting ingenuity and self-awareness. But it also runs a good 20 minutes longer than it should and includes dramatic scenes with no attempt at humor — suggesting a curious lack of insight into what the audience for a movie about a raunchy talking teddy bear is looking for.

The premise is that when John Bennett was a little boy, he wished that his beloved teddy bear could talk to him and be his best friend forever, whereupon some Christmas magic made this come to pass. (The holiday-themed prologue, complete with jingly music and a Patrick Stewart narration, is perfect.) That was in 1985. Now John (played by Mark Wahlberg) is 35 years old, and Ted (a CGI creation voiced by MacFarlane) is indeed still his best friend and constant companion. Ted’s personality has developed — I hesitate to say “matured” — at approximately the same rate as John’s, so they share similar interests, which mostly include smoking weed and watching TV.

One of the film’s best decisions is to skip the Calvin & Hobbes route and let everyone, not just John, hear Ted when he speaks. Ted is known to be a magical living stuffed animal. This earned him notoriety back in the ’80s that still flares up occasionally, though most people are blasé about it now: Oh, look, it’s that magical living stuffed animal. But then sometimes you get weirdos like Donny (Giovanni Ribisi), who wants to buy Ted as a companion for his doofy son. The very idea is offensive, of course. John doesn’t “own” Ted. He’s his pal.

The story’s conflict comes in the sexy form of Lori (Mila Kunis), John’s cool and understanding girlfriend of four years. She gets along with Ted well enough, the way most cool and understanding girlfriends get along with their boyfriends’ irresponsible buddies. But maybe it’s time for Ted to get a job and move into his own apartment, you know? Maybe Ted is keeping John from growing up.

“Ted” basically follows a traditional plot, the one where a dude feels like he has to choose between his best friend and his girlfriend, or between staying immature and growing up. MacFarlane, co-writing the screenplay with “Family Guy” scribes Alec Sulkin and Wellesley Wild, acknowledges the formula to the point of parody. A crucial moment for John comes when he must choose between accompanying Lori to an important social engagement and experiencing something with Ted that “is the symbol of our friendship” — a nice instance of saying, in so many words, what most movies would pussyfoot around. It’s an attitude common on “Family Guy”: “Eh, screw it, let’s just come out and say exactly what we’re doing.”

It will come as no surprise to those familiar with MacFarlane’s animation empire that the jokes in “Ted” are scabrous, lewd, racist, and insensitive, and that Ted sounds a lot like Peter Griffin. (The movie acknowledges that, and thus employs another regular “Family Guy” device: “It’s OK to be lazy as long as we make it clear that we know we’re being lazy.”) The dialogue includes not one but two 9/11 references, as well as the customary assortment of illness-related jokes. (“As one gentleman to another, I really hope you get Lou Gehrig’s disease,” says John to Lori’s smarmy boss, played by Joel McHale.) We get a few hit-and-run celebrity slams that are mean and irrelevant and cruelly funny. Some jokes are better than others, but the success rate is generally high.

In fact, this would be one of the year’s best comedies were it not for two significant errors in judgment. One is that it’s 106 minutes long, and by the end it drags like a … like a big draggy thing. (Eh, screw it, I don’t feel like coming up with a joke.) The other is that it places a strange degree of emphasis on the emotions behind John and Ted’s friendship and John and Lori’s relationship. A comedy, even a raucous one like this, doesn’t need to be ha-ha funny every single minute. But there are entire scenes near the end of “Ted” with no jokes at all, played totally straight. This is especially deadly when the story is starting to drag like a draggy thing anyway. Just get back to the jokes about hookers pooping on the carpet!

B- (1 hr., 46 min.; R, pervasive harsh profanity and vulgar dialogue, brief nudity, brief strong sexuality.)

Reprinted from Movies.com.