MALIBU, Calif. - As Britney Spears was checking out of rehab for the second time in a week Wednesday, her estranged husband was making plans to go to court amid a custody dispute over their two children.

Kevin Federline and his lawyer were scheduled to appear at a downtown courthouse Thursday for an emergency hearing, Superior Court spokesman Allan Parachini told The Associated Press. It was not known what issue Federline planned to raise.

Federline and Spears have two sons, 5-month-old Jayden James and 17-month-old Sean Preston.

"Our best information is he will be here; she won't," said Parachini. "But anything is possible."

Federline filed papers seeking spousal support and sole custody of the children after Spears sought to end their two-year marriage last November. A temporary court order issued Feb. 1 granted the couple joint custody until the end of this month.

Parachini said Federline's lawyer would try to persuade a Superior Court commissioner that the matter is urgent enough to be handled on an expedited basis.

The move comes amid increasingly bizarre behavior by Spears, which culminated with her reportedly checking into and out of two rehab centers last week and shaving her head bald on Friday.

Spears, 25, left the Promises Malibu Treatment Center on Wednesday, according to The Insider TV news magazine, less than a day after arriving at the facility that specializes in treating drug and alcohol abuse.

Last week she reportedly sought treatment at a center in the Caribbean but also checked out after a day.

Popping in and out of rehab centers around the world is not a smart move for someone involved in a child custody battle with her estranged husband, said New York-based family law attorney Joshua Forman, who is not involved in Spears' case.

"That's ridiculous. Wherever you are and whatever your problem is, you go through the program the place offers and you do what they tell you to do," Forman told the AP. "Checking in and out for one day doesn't show the court anything."

OK! magazine reported it has learned Spears fled rehab because she was worried Federline would move to obtain permanent custody of the couple's children while she was undergoing several weeks of treatment.

Federline's agent, Allison Joyce, said the 28-year-old aspiring rapper and former backup dancer would have no comment.

Of late, Spears has engaged in increasingly strange behavior, showing up in public in skimpy outfits and sometimes minus her underwear.

Then came what the tabloids have called a meltdown weekend when she arrived at a Los Angeles hair salon on Friday, grabbed an electric razor and shaved her head bald. Afterward, she visited a tattoo parlor where she had a pair of red-and-pink lips inked onto her wrist. Then she went out clubbing with friends before entering rehab at Promises on Tuesday.

After leaving Promises on Wednesday, Spears attempted to keep a low profile but the celebrity Web site TMZ.com posted video of her wearing a wig and leaving what it said was a lawyer's office.

Her agent, Jason Trawick, referred inquiries to her manager, Larry Rudolph, who referred them to Gina Orr, the publicist at Jive Records, Spears' label. Orr did not respond to e-mail and phone messages, and Spears' Web site, where the singer once posted messages directly to fans, was all but blank on Wednesday. A message on its home page simply stated: "Stay tuned! Britney's new Web site is in the works."

Whether her recent behavior will damage her recording career is hard to say, said Vibe magazine music editor Jon Caramanica, although he suggested a way to minimize damage would be to come forward quickly and candidly discuss what she is going through.

"The thing worth noting is that the reason this is such a big deal is that many people really cared about Britney to begin with and that shouldn't be taken lightly," he said.

Spears, whose 1999 debut album ... Baby One More Time, sold more than 13 million copies, hasn't released a new album since 2003. Before her troubles began she had promised one this year, and Caramanica suggested that might also be a good place to address what she's going through.

"I think the best thing she could do is make an album that engages with this subject matter in some way," he said. "Not only to have a good album but to have an album that's a declaration of emotional health."