Jim Carrey is in talks to topline the Barry Sonnenfeld-directed “Lemony Snicket” for Paramount and Nickelodeon Films.

Pic is an adaptation of the Daniel Handler children’s book series “Lemony Snicket’s A Series of Unfortunate Events.”

Studio brass has high hopes that “Snicket” will be its ticket to a Harry Potteresque franchise. Pic is being produced by Scott Rudin, who teamed with Carrey on the Peter Weir-directed “The Truman Show.”

The wildly popular Snicket series has grown to eight books since Handler hatched the series in 1999. The saga revolves around a trio of orphans who are passed around to a series of quirky people. The first of those is the mysterious Count Olaf, who is counting on separating the children from their inheritance.

The series has the kind of kid-appropriate edge evident in J.K. Rowling’s “Potter” series, and that prompted the studio to bring in Sonnenfeld, who showed a flair for black comedy in the Rudin-produced “The Addam’s Family” and its sequel. The script has been written by Handler.

Sources said that Carrey has sparked to the Count role, and the talks going on right now are aimed at sorting out Carrey’s busy dance card. He’s filming the Tom Shadyac-directed comedy “Bruce Almighty” at Universal with Jennifer Aniston and Morgan Freeman, and Carrey expects to start work early next year on “Eternal Sunshine of the Spotless Mind,” a Focus-based film written by “Being John Malkovich” scribe Charlie Kaufman, directed by Michel Gondry.

“Snicket” would likely follow that film. Carrey is also poised to play Howard Hughes in a Castle Rock-based film that is being scripted and will be directed by “Insomnia” helmer Chris Nolan. Carrey’s repped by UTA and Gold-Miller.

ROOTING FOR THE UNDERDOG: Adam Rifkin has been set by Spyglass and Disney to get canine caped crusader “Underdog” off the ground as a live action feature.

Rifkin’s getting $725,000 against $1.2 million to write the script, which came off his recent work in transforming “Where’s Waldo” from an elusive character in crowd-filled picture books into a Paramount/Nickelodeon film.

Rifkin is such a fan of the original NBC Wally Cox-voiced cartoon that he knew the theme song word for word, demonstrating it in a rendition that was painful for the listener. But he’s keyed up on his plans to flesh out the simplistic cartoon concept into a smart pic.

“I thought it would be funny if a real dog in a superhero suit could be depicted doing martial arts in ‘Matrix’ fashion,” said Rifkin. “And it’s an opportunity to tip our hat to the great conventions of superhero movies of the past decades. It’s not a parody, it will create its own believable reality, but it will be self-referential to the ‘Spider-Mans’ and ‘Batmans.'”

He hopes the film will have the edge evident in his scripts for “Mousehunt” and “Small Soldiers.” “These movies work best when you give the children something, but offer their parents humor that goes over the kids’ heads,” he said. “I remember watching the Warner Bros. cartoons as a kid and I see them now and realized how much of the humor I didn’t understand back then.”

The pic’s being produced by Jay Polstein and Spyglass partners Roger Birnbaum and Gary Barber. Spyglass production prexy Jonathan Glickman is exec producing with Eric Ellenbogen and Bob Higgins from Classic Media. Overseeing “Underdog” is Spyglass veep Stephanie Striegel. Rifkin, whose directing effort “Night at the Golden Eagle” will be displayed at the New York Independent Film Festival, is repped by CAA.

SPENCER ON THE WING: Much of the media focus on “The West Wing” has concerned castmember contract negotiations. Emmy-nominated “Wing” star John Spencer feels that the focus will quickly go back to the episodes, which he said have taken the show to a new quality level. “We are dealing with something that hasn’t been dealt with openly in the world, the idea that the administration might have assassinated somebody, and we have to go to a world court over it,” Spencer said. “It is fiction which has to adhere to the parameters of the American government, and given all that has happened in the country over the past year, I have to say that Aaron Sorkin has responded with the best season of writing he has ever done.” Spencer said he has grown script spoiled, because David E. Kelley wrote his lines on “L.A. Law” and then he moved right along to Sorkin’s scripts. He feels there has been too much attention given to the negotiations he and his castmates had last year, and the salary dispute that led Rob Lowe to exit this season. He thinks that it gives the mistaken impression there is discord on the set. “We all get along incredibly well, and I’m still hoping that Rob is going to stay. I can remember during ‘L.A. Law’ when I attended the goodbye party for Jimmy Smits, Harry Hamlin and Susan Dey. Jimmy and Harry said their farewells, and then Susan got up, she said that a deal had just been made in the back room and that she’d be staying. All I know is we’ve signed through seven seasons, and because the president can only go two terms, eight would be the max unless they brought in a whole new cast and made a transition to a new White House administration. Whether it’s seven or eight, this will be my swan song to one-hour dramas, and that I will go back to the stage, do a few movies, and take a big dose of downtime.” While Spencer is now one of several “Wing” members to express hope that Lowe might change his mind and stay, the fact is there has been no movement toward a negotiation that would give him a pay hike. He’ll be out of there before the season’s over.