It’s always a surprise when you go into a movie theatre expecting one thing, and wind up with a completely different kind of experience. Usually that surprise is an unpleasant one, when a movie starring a superstar turns out to be a complete dud – for instance, 2003’s utter disaster “Hollywood Homicide” with Harrison Ford, a movie so bad that its writers and director never made another film.


—–

Far more rare is the case that a film can look atrocious and downright distasteful in its ad campaign and then turn out to be an outright winner. Yet thankfully that’s the case with the new dramedy “The Switch,” in which Jennifer Aniston plays Kassie, a woman who opts for artificial insemination when she can’t find Mr. Right while facing 40. Her best friend Wally (Jason Bateman) offers to be the sperm supplier, but she has him stuck in the “friend zone” and worries he’ll pass on his neuroses to boot.

The TV commercials for “The Switch” cut to the chase with a stomach-churning scene in which Wally (Jason Bateman) drunkenly sniffs, stares at, plays with and then spills the container of sperm that Kassie is hoping to use for the procedure. Realizing that she has an apartment filled with people attending her “pregnancy party,” and that he can’t face up to admitting he’s ruined her big night, he unzips his pants and takes care of replenishing the supply himself.

So far, so icky. And yet, a better movie is already lurking around the edges as there’s witty banter between the two stars, who are in top form throughout the film, and a thoughtful opening narration over images of New Yorkers rushing right past each others’ lives. That clever writing is courtesy of Allan Loeb, who is widely considered the hottest screenwriter in Hollywood these days due to the fact he has a whopping 12 screenplays in production.

The movie pulls a switch of its own after taking a seven-year leap in time. Kassie decided to move back home to Minnesota while pregnant because she felt it would be too hard to raise a child in New York City. But now her son is six, she’s gotten a great job offer back in the Big Apple, and she’s suddenly ready to re-enter Wally’s life.

Wally’s still single and a neurotic mess, but he sees that her son Sebastian (Thomas Robinson, a real find) looks and acts just like himself even as Kassie’s in oblivious denial. And as she relies on Wally to babysit for Sebastian while she delves into a new relationship with the guy she thought was the donor (Patrick Wilson), Wally comes to realize it’s time to grow up and fight for the important things in life.

“The Switch” is directed by the team of Josh Gordon and Will Speck, who previously did the Will Ferrell figure-skating farce “Blades of Glory.” They pull a 180 in this film once the slapsticky first 20 minutes go by, turning out a film that knows when to be funny but more importantly, knows when to be serious without turning sappy. It’s almost as good as the highly regarded 2002 film “About a Boy,” in which Hugh Grant played a middle-aged man-child forced to mature when a lonely teenage boy and his mother enter his life.

Gordon and Speck also make vibrant use of a sharp supporting cast including Jeff Goldblum and Juliette Lewis, as well as the film’s many New York City locations, fully ingraining the city into the film’s atmosphere without relying on overused tourist traps like the Statue of Liberty or the Empire State Building. And the sharp score by Alex Wurman is complemented by an array of thoughtful indie-rock songs.

For those wondering how the film handles the moral issues of artificial insemination and single motherhood, “The Switch” starts out with Kassie happy and determined to get pregnant, saying that a man isn’t necessary to raise a child. But as the film goes on, it uses a couple of quietly powerful and moving sequences to show the enormous emotional impact the lack of a father and the opportunity to bond with a father figure can have on a child. This is one film that handles thorny lifestyle issues in a directly positive way.

Put it all together, and “The Switch” is the best kind of cinematic surprise: a film that is far better than expected and even better than it had to be.