There's no doubt that Wayne Treacy ruthlessly attacked a teenage girl more than two years ago outside a middle school, brutally kicking and stomping her head so badly she suffered permanent brain injuries. But Treacy, now 17, says he was insane when he assaulted Josie Lou Ratley and should be acquitted of attempted first-degree murder.

If convicted at a trial that begins Monday, Treacy could get 50 years in prison. If not, he likely would still spend years in a state mental institution, possibly even as long as he would spend in prison, attorneys and legal experts say.

"They often have a difficult time getting out," said attorney Richard Rosenbaum, who has represented defendants claiming the insanity defense and is not involved in the Treacy case. He said few insanity defenses succeed because defendants not only must show a mental illness or defect but also must prove they didn't know right from wrong.

"That's usually the prong that trips up most of the people who raise insanity as a defense," Rosenbaum said. "It's fairly easy for the state to show someone knew right from wrong. They knew 'Thou shalt not kill."'

Coincidentally, the attack on Ratley happened several months after a group of students at the same school, Deerfield Beach Middle School, set a classmate on fire, nearly killing him. Three boys have been convicted of felonies in that case.

Treacy's defense claims he was suffering from post-traumatic stress disorder, rooted in his older brother's recent suicide, when he became enraged on March 17, 2010, by an exchange of text messages with Ratley, whom he did not know. In one of the texts, Ratley tells Treacy "now go visit your dead brother," leading Treacy to respond, "You're (expletive) dead! I swear to God, I'm going to kill you. Your (expletive) is cold, dead meat."

Yet Treacy threatened Ratley several times during their 45-minute text exchange before she mentioned the brother. The whole thing started because Treacy was trying to get in touch with another girl, Kayla Manson, whom he had been dating. Ratley sometimes let Manson use her phone to contact Treacy.

Ratley repeatedly referred to then-15-year-old Treacy as a "rapist" for dating Manson, who was then 13. Eventually Treacy texts back, "Why are you trying to get yourself killed? I will find you. I will mess you up, you will regret crossing me."

And, prosecutors say, Treacy calmly laid plans to do just that over the next few hours. Evidence shows that Treacy -- a gifted student who did not attend his high school that day -- did computer searches on ways to efficiently kill people barehanded, wrote up a short will and hinted to several friends about his violent plans.

"I'm going to jail for murder," Treacy said in one text to a friend, according to investigative records.

Most of the friends said they didn't take the threats seriously.

"He's never hurt anyone before and I wouldn't think he would ever hurt someone," said Monica Montero, who received several texts from Treacy that day.

Prosecutors say Treacy dressed in black, including martial arts fighting gloves and his brother's steel-toed boots to ensure maximum damage. He then rode his bicycle to the middle school and found Manson, asking her to take him to Ratley. Surveillance video shows Manson leading the much taller Treacy through a crowd of students at the school bus stop, a few moments after Ratley also passed by. The beating itself is not captured on camera.

Numerous witnesses say Treacy grabbed Ratley by the neck, knocked her to the ground and began stomping and kicking her. A teacher managed to knock Treacy away from the girl, who was by then lying unconscious in a pool of blood. The teacher, Walter Welsh, then hustled Treacy into the school office and waited for police and paramedics to respond.

Welsh said it was clear immediately the attack was planned. "He was on a mission," Welsh said.

Later in a videotaped police interview, Treacy claimed he blacked out during the attack and that he never intended to hit Ratley. Just before the investigator came into the interview room, however, Treacy quietly says, "I'm a monster. I'm a monster."

Ratley gradually recovered but still has mental problems that prosecutors say may prevent her from testifying. Ratley's mother has an unlisted telephone number and could not be reached for comment. Manson, the girl who pointed Ratley out, faces an August trial on charges of being Treacy's accomplice.

For Treacy's insanity defense to succeed, experts say it's crucial that jurors are convinced he had been suffering from post-traumatic stress disorder for some time after his brother's suicide. In pretrial hearings, a defense expert has testified Treacy likely was in period of detachment during which he didn't know what he was doing. Those periods can last for hours or days, the expert said.

In a taped jailhouse phone call with his mother, Treacy says he is angry at his brother because the suicide messed up his head.

"If it wasn't for (unclear), I'd be just as normal as I ever was and this would never have happened," Treacy says, according to a transcript.

The prosecution's job is easier, said Nova Southeastern University law professor Robert Jarvis.

"The state has to keep reminding the jury that the defendant is (an attempted) killer," he said. "In the end, I think the defense fails in this case because lots of people lose a loved one and still function without engaging in a crime and jurors know that."