
794 A.2d 211 (2002)
349 N.J. Super. 569
In the Matter of the COMMITMENT OF P.C.
Superior Court of New Jersey, Appellate Division.
Argued March 6, 2002.
Decided April 8, 2002.
Joan D. Van Pelt, Assistant Deputy Public Defender, argued the cause for appellant *212 P.C. (Peter A. Garcia, Acting Public Defender, attorney; Ms. Van Pelt, on the brief).
Mary Beth Wood, Deputy Attorney General, argued the cause for respondent State of New Jersey (Peter C. Harvey, Acting Attorney General, attorney; Nancy Kaplen, Assistant Attorney General, of counsel; Ms. Wood, on the brief).
Before Judges KING, WECKER and WINKELSTEIN.
The opinion of the court was delivered by KING, P.J.A.D.
The issue in this case is the power of the county prosecutor to plea bargain away the Attorney General's right to seek civil commitment under the Sexually Violent Predators Act (SVPA), N.J.S.A. 30:4-27.24 to -27.38. We conclude that the county prosecutor has no such power. A plea agreement by a county prosecutor which operates as an impediment to a valid civil commitment of a sexual predator is void as against public policy.

I
Appellant's history of sexually offensive behavior with young males goes back over twenty years. As a juvenile at age 17 he was arrested in Philadelphia in June 1981 and charged "with criminal solicitation to commit involuntary deviate intercourse." 18 Pa.C.S.A. § 3123. Pursuant to a plea agreement, he received a term of probation. He was next arrested at age 23 in August 1987, also in the Commonwealth of Pennsylvania. He attempted to assault a boy, age 15. The official records state that he attempted to coerce fellatio in a movie theater. He pled guilty to a count of corruption of a minor, 18 Pa.C.S.A. § 6301, and received three years intensive probation.
In September 1987 appellant was again arrested in Philadelphia for a sexually violent offense involving minors. In that matter he attempted to sexually assault two boys, ages 13 and 11. He was charged with two counts of corrupting a minor and two counts of soliciting involuntary deviate sexual intercourse, 18 Pa.C.S.A. § 6301 and § 3123, respectively. He pled guilty to all counts. In November 1987 he received an 11½ to 23 month prison term and three years probation thereafter.
In February 1989, at age 25, appellant was again arrested in Pennsylvania for the sexual assault of a boy, age 15. In that case the victim said appellant grabbed him by the neck and told him he was taking him to the railroad tracks to force him to submit to oral sex. Appellant was apprehended quickly and charged with attempted involuntary deviate sexual intercourse, corruption of a minor, and assault. Upon conviction in November 1989, he was sentenced to a ten-year prison term with a four-year mandatory minimum. In February 1999 he was released from prison at the expiration of his maximum term. He then relocated to Cumberland County, New Jersey.
On March 12, 1999 appellant, at age 35, was arrested in Cumberland County and charged with two counts of "endangering the welfare of a child." N.J.S.A. 2C:24-4b(4)(a) and (b). Personnel of the Vineland Public Library reported to police that he was using the library's public access internet computers to view child pornography, despite earlier warnings. The police observed appellant at a library terminal accessing many pornographic web sites. These sites included "BOYLINKS," "North American Man Boy Love Association" (NAMBLA), which showed young male nude subjects, and sites labeled "masturbation." He was observed downloading *213 graphic images to a floppy disc which he kept. On March 3, 1999 the police searched his residence with a warrant and found two discs with photographic images of nude, underage boys. On November 16, 1999 defendant pled guilty to one count of endangering the welfare of children, N.J.S.A. 2C:24-4(b)(4)(b), a fourth-degree offense.
On February 18, 2000 appellant was evaluated at the Adult Diagnostic and Treatment Center (ADTC), where he readily admitted, "I do actually like guys who are underage." He also made several statements that demonstrated his deviant sexual arousal, including "[s]exual activity with children can help the child learn about sex," "[s]ociety makes a much bigger deal out of sexual activity with children than it really is," and "I think the main thing wrong with sexual activity with children is that it is against the law." The ADTC evaluator said appellant "display[ed] no discernible empathy for children who are victimized by sexual assaults. He also display[ed] no discernible remorse for his deviant sexual behaviors." The evaluator concluded that P.C.'s history, and the information elicited during the evaluation, indicated his most recent offense represented a repetitive and compulsive pattern of behavior. He was deemed eligible for sentencing to ADTC under the sex offender laws. See N.J.S.A. 2C:47-3. However, he advised the ADTC evaluator that he was unwilling to participate in sex offender treatment at ADTC. As a consequence, on April 14, 2000 he was sentenced to an eighteen-month prison term in general population.
Appellant was scheduled for release from prison on March 1, 2001 upon expiration of his maximum sentence. On February 27, 2001 the Attorney General filed a petition in the Superior Court, Burlington County, seeking his civil commitment pursuant to the SVPA. The State's petition for commitment was supported by the certificates of two psychiatrists. Both said that involuntary civil commitment was necessary because appellant suffered from a mental abnormality or personality disorder which made him likely to engage in acts of sexual violence if not confined in a secure facility.
On February 27, 2001 Judge Schlosser found probable cause to believe that appellant was a sexually violent predator. He issued a temporary commitment order authorizing appellant's transfer to the Special Treatment Unit (STU or NRU) at Kearny, Hudson County. On March 19, 2001 appellant filed a motion before Judge Freedman, specially assigned to hear SVPA matters, to dismiss the State's petition and the temporary commitment order because the 1999 plea agreement leading to the child endangering conviction prohibited application of the SVPA to appellant. The judge denied the motion to dismiss. We granted appellant's motion for leave to appeal Judge Freedman's denial of that motion because of the important issue presented. R. 2:2-3(b); R. 2:2-4.

II
Appellant has been a Pennsylvania resident most of his life. All of his criminal offenses, except the most recent 1999 crime in Cumberland County, were committed in the Commonwealth. The predicate offense under the SVPA was committed in Pennsylvania in 1989 against a victim, age 15.
In seeking civil commitment, the Attorney General is required to prove, by clear and convincing evidence, that the individual is a sexually violent predator in need of civil commitment. N.J.S.A. 30:4-27.32(a). The term "sexually violent predator" is defined as *214 a person who has been convicted, adjudicated delinquent or found not guilty by reason of insanity for the commission of a sexually violent offense, or has been charged with a sexually violent offense but found to be incompetent to stand trial, and suffers from a mental abnormality or personality disorder that makes the person likely to engage in acts of sexual violence if not confined in a secure facility for control, care and treatment.
[N.J.S.A. 30:4-27.26.]
A "sexually violent offense" is defined by the statute to include a list of enumerated criminal offenses and provides that a sexually violent offense includes a "criminal offense with substantially the same elements as any [enumerated offense], entered or imposed under the laws of the United States, this State or another state." Ibid. [Emphasis added.]
In this case, the State based its petition for civil commitment on appellant's lengthy history of sexually violent behavior. The specific predicate offense described in the State's petition for commitment was the 1989 Pennsylvania conviction for, among other crimes, attempted involuntary deviate sexual intercourse, in violation of 18 Pa.C.S.A. § 3123. The offense of involuntary deviate sexual intercourse is defined by the Commonwealth as a first-degree felony in which the defendant,
engages in deviate sexual intercourse with a complainant ... (7) who is less than 16 years of age and the person is four or more years older than the complainant and the complainant and person are not married to each other.
[18 Pa.C.S.A. § 3123(a).]
Sodomy, which is defined as "carnally knowing in any manner any animal or bird, or any male or female by the anus or by or with the mouth," is considered deviate sexual intercourse. Ibid.; 18 Pa.C.S.A. § 4501. The offense of involuntary deviate sexual intercourse is substantially the equivalent of the New Jersey offense of attempted sexual assault, N.J.S.A. 2C:14-2. Appellant's 1989 conviction in Pennsylvania for the offense of attempted involuntary deviate sexual intercourse was therefore an enumerated sexually violent offense pursuant to the SVPA and was used properly by the State to satisfy the first element, a predicate offense, necessary for appellant's commitment.
In November 1999 when appellant pled guilty to one count of fourth-degree endangering, the judge stated at the commencement of the proceeding:
I think it's also fair to note for the record that the three of us have just spen[t] a fair amount of time in chambers with the new Involuntary Commitment Act [effective date of SVPA was August 12, 1999]. And I am sure that Mr. Shapiro will cover it during the plea and the stipulations that have [been] agreed to, but the record should reflect that the three of [us] have had an opportunityan extensive opportunity to confer in chambers with respect to the applicability of that act and how it applies to this particular case.
The stipulations contained in the plea agreement were set out on the record by defense counsel, Mr. Shapiro, as follows:
It is stipulated that the New Jersey Sexually Violent Predator Act does not apply to this defendant. It is stipulated that the State has no report or information that defendant suffers from mental illness.
The assistant prosecutor represented to the judge that the stipulations were accurate and the plea was accepted by the judge.
Sentence was imposed on April 14, 2000. At the time of sentencing, the State and *215 the judge had a full presentence investigation and a report from the Adult Diagnostic and Treatment Center. Although the State was concerned that appellant might reoffend, there is nothing in the record to suggest that the reports prepared for sentencing gave the State information in addition to that known at the time the plea agreement was entered into. Nor was there an application by the State to withdraw from the stipulation that appellant was exempted by the plea agreement from a complaint for civil commitment under the SVPA. The judge, while expressing concern over appellant's background, did not exercise his power to reject the plea which stipulated that the appellant would not be committed as a sexually violent predator. In fact, the judge stated, "I find that the plea bargain is appropriate under the circumstances and intend to follow it." The sentence of 18 months imprisonment was imposed.
In addressing the appellant's motion to dismiss the SVPA commitment, Judge Freedman correctly observed, "the question is was there actually a valid bargain made[?]" The judge stated in pertinent part:
THE COURT: ... And I don't believeI think the contract that you calltalk about, if there was one, it was void, ab initio, so to speak, because the attorneythethe Prosecutor of Cumberland County has actually no authority or jurisdiction under the SVP statute. The SVP statute is a civil commitment statute. It is [N.J.S.A.] 30:4-27.4, and following, it clearly gives to the Attorney General all the authority to bring petitions under the statute.
*****
... And as I look at the statute, the Prosecutor of Cumberland County doesn't have the authority to make this deal. I don't think the Attorney General of New Jersey has the authority to make this deal.
So that even if the Attorney General had [knowledge] of this plea and even if he went along with it, I still think the plea bargain would be void as against the public policy of the State, because the purpose of this statute that we're dealing with is to protect the public from sexually violent individuals and at the same time, provide treatment for those individuals.
It's not a punitive statute. It's a protection of the public and a treatment statute. The Attorney General has certain responsibilitieswhen casesindividuals, who are either in prison or in a mental hospital, the people who are in charge of them have a certain responsibility to refer cases to the Attorney General under this statute. The Attorney General then has certain responsibilities with regard to bringing petitions and to take a position that someone is not subject to the act in a criminal proceeding, that has nothing to do with the SVP statute.
*****
The bill was designed to provide for civil commitment, involuntarily, for such predators who have been convicted of an offense and who suffer an abnormality of personality so it makes the person likely to engage in acts of sexual malice [when] not confined in a secure facility for controlled care and treatment, which is a statement, the committee statements attached to the [N.J.S.A.] 30:4-27.24, in that section.
*****
And I think any reasonable person, looking at these documents, would findI think you would probably have to have a hearing if you really wanted to get into thewhatwhat everybody actually intended. But it appears pretty *216 clear to me that what they intended was that this particular statute, this particular incident, is not going to result in a petition being filed. It's not going to be the subject of a petition. And it's not the subject of a petition.
This petition is based on prior conduct, prior criminal acts, which come within the purview of the SVP statute and does not include this particular statute [N.J.S.A. 2C:24-4b(4)(a) and (b)], which is what, I think, the intention of the parties was. The fact that this brought [P.C.] to the attention of the authorities, [what] I think is, he knew when he was pleading that he was going to prison.
He knew that he was going to come under the scrutiny of corrections officials. So he definitely knew that, and that's what got him referred to the [Attorney General], his conduct in the prison and his statements, his prior record, and the fact that he was found to be a repetitive sex offender is what got him referred.
As we have noted, we agree with Judge Freedman that the county prosecutor had no power to enter into a plea agreement eviscerating the SVPA. We need not reach the issue of the Attorney General's power to enter into such an agreement. We suspect that only the rare and unusual case would prompt the Attorney General to consider such a plea bargain. Interestingly, the SVPA only mentions the county prosecutor once. In N.J.S.A. 30:4-27.26 when defining "agency with jurisdiction" the SVPA states: "`Attorney General' means the Attorney General or a county prosecutor to whom the Attorney General has delegated authority under this act." No delegation of authority to the county prosecutor's office occurred in the case before us.

III
The SVPA specifically authorizes the Attorney General to initiate proceedings seeking the civil commitment of an inmate scheduled to be released after serving a term of incarceration. N.J.S.A. 30:4-27.28(c); N.J.S.A. 30:4-27-29(b); see also N.J.S.A. 30:4-82.4. We conclude that neither a county prosecutor nor a defendant may by plea agreement frustrate the Attorney General's authority to protect the public from sexually violent predators.
The portion of the plea agreement in November 1999 seeking to exempt appellant from operation of the recently-effective SVPA is contrary to New Jersey law and public policy. It is unenforceable. While courts generally defer to the reasonableness of negotiated criminal dispositions, see State v. Spinks, 66 N.J. 568, 573, 334 A.2d 23 (1975), "there can be no plea bargain to an illegal sentence." State v. Nemeth, 214 N.J.Super. 324, 327, 519 A.2d 367 (App.Div.1986).
Judge Havey summarized the controlling principles in State v. Marsh, 290 N.J.Super. 663, 667, 676 A.2d 603 (App. Div.1996), where defendant sought refuge in an agreement with a municipal detective that called for the dismissal of a DWI charge if he cooperated in an unrelated drug investigation.
Defendant's "agreement" to cooperate with the detective may be analyzed and enforced under contract principles. See State v. Riley, 242 N.J.Super. 113, 118, 576 A.2d 39 (App.Div.1990). One such firmly held principle is that courts will refuse to enforce contracts that are in violation of a state law or public policy. Vasquez v. Glassboro Serv. Ass'n, Inc., 83 N.J. 86, 98, 415 A.2d 1156 (1980); Saxon Constr. & Management Corp. v. Masterclean of North Carolina, Inc., 273 N.J.Super. 231, 236, 641 A.2d 1056 *217 (App.Div.), certif. denied, 137 N.J. 314, 645 A.2d 142 (1994). Not only was the detective's promise here beyond his authority to make, it ultimately could not legally have been carried out by the municipal prosecutor when defendant's drunken driving charge ultimately reached the municipal court. The promise clearly violated Guideline 4, and undermined its purpose of preserving public confidence that a meritorious DWI offense will not be bargained away. A prosecutor cannot offer a "plea bargain which may not be legally implemented." State v. Baker, 270 N.J.Super. 55, 70, 636 A.2d 553 (App.Div.), certif. denied, 136 N.J. 297, 642 A.2d 1005, aff'd, 138 N.J. 89, 648 A.2d 1127 (1994).
[Id. at 667, 676 A.2d 603.]
The possibility that a civil commitment under the SVPA might be warranted at the end of a prison sentence is not usually a predictable issue before a sentencing court.
The authority of the State to civilly commit citizens is an exercise of its police power to protect the citizenry and its parens patriae authority to act on behalf of those unable to act in their own best interest. In re D.C., 146 N.J. 31, 47, 679 A.2d 634 (1996), (citing In re the Commitment of S.L., 94 N.J. 128, 136, 462 A.2d 1252 (1983)). The United States Supreme Court has consistently upheld the constitutionality of statutes providing for the involuntary civil commitment of those individuals who pose a danger to the public health and safety because of their behavior. Both Kansas v. Hendricks, 521 U.S. 346, 357, 117 S.Ct. 2072, 2079-80, 138 L.Ed.2d 501 (1997), and Seling v. Young, 531 U.S. 250, 261, 121 S.Ct. 727, 734, 148 L.Ed.2d 734 (2001), found no constitutional bar to the civil confinement of sexually violent predators mental conditions because the states have an interest in protecting the public from dangerous individuals with both treatable and untreatable conditions. In enacting the SVPA, the Legislature specifically recognized the need to protect society from sexually violent predators. N.J.S.A. 30:4-27.25. The State's interest in so protecting society is legitimate and substantial. Kansas v. Crane, 534 U.S. 407, ___, 122 S.Ct. 867, 868, 151 L.Ed.2d 856, 860 (2002); Doe v. Poritz, 142 N.J. 1, 90, 662 A.2d 367 (1995).
Appellant's reliance on Gallo Asphalt Co. v. Sagner, 71 N.J. 405, 365 A.2d 932 (1976), is unpersuasive. The Gallo Asphalt case involved a challenge to a debarment order which precluded Gallo Asphalt from bidding on public projects after a conviction for conspiring to rig bidding. Id. at 408, 365 A.2d 932. Gallo Asphalt had entered into a plea agreement which specifically exempted the use of its guilty plea as evidence of guilt in any future civil proceeding, pursuant to the express provisions of R. 3:9-2. The Supreme Court held that the guilty plea, which played a decisive role in the decision to issue the debarment order, should not have been used as evidence of guilt in the debarment proceeding. Id. at 412, 365 A.2d 932. There is no such exemption available to appellant in the SVPA. Also, unlike the plea agreement in issue here, the Gallo Asphalt plea agreement did not attempt to usurp the statutory authority specifically delegated to the Attorney General.
The 1999 New Jersey conviction for endangering the welfare of children was not offered in the SVPA proceeding to establish appellant's eligibility for commitment. That offense obviously did not play a critical role in the Attorney General's determination to seek his commitment as a sexually violent predator. The 1999 fourth-degree conviction was not the predicate offense upon which the State based its petition for commitment. The *218 1999 conviction was simply the last in a list of convictions for sexual offenses; the other offenses were all sexual assaults against young males. The appellant's current mental condition establishes the necessity for commitment, not his fourth-degree conviction in 1999.
Nor does appellant's reliance on State v. Zanelli, 212 Wis.2d 358, 569 N.W.2d 301 (Ct.App.), review denied, 215 Wis.2d 423, 576 N.W.2d 279 (1997), support his claim that a defendant can bargain for a waiver of the Attorney General's statutory authority to seek civil commitment when necessary. In Zanelli, the Wisconsin court determined that the possibility of SVP commitment in the future was "merely a collateral consequence of a guilty plea" because the chance of commitment had "no definite, immediate or largely automatic effect on the range of the pleader's punishment." Id. at 305. The Zanelli court also properly noted that any future SVP proceeding would depend on the defendant's condition at the time the commitment application is made and on the evidence presented at that time on the defendant's mental condition. Ibid. Zanelli does not stand for the proposition that a defendant can bargain for a condition which is contrary to state law and public policy. Accord, In re Commitment of Connelly, 223 Wis.2d 265, 588 N.W.2d 927 (Wis.App. 1998). Indeed, we find no authority anywhere to support appellant's contention. Only a few cases seem to peripherally touch on the point. In Collie v. State, 710 So.2d 1000, 1008 (Fla.Dist.Ct.App.), rev. denied, 722 So.2d 192 (Fla.), cert. denied, 525 U.S. 1058, 119 S.Ct. 624, 142 L.Ed.2d 563 (1998), a proceeding to designate defendant as a sexual predator did not violate a plea bargain because such a designation was a collateral consequence of a guilty plea and did not enhance the punishment. In Sears v. State, 801 So.2d 1018, 1018-20 (Fla.Dist.Ct.App.2001), a plea agreement included conditions that the state would waive a sexual predator designation and that defendant would submit to sex offender counseling. The latter contention was held enforceable; the waiver of sexual predator classification was never drawn in dispute on the appeal.
The pertinent authorities all seem to agree that a plea agreement for an illegal sentence in unenforceable. State v. Manzie, 335 N.J.Super. 267, 278, 762 A.2d 276 (App.Div.2000), affirmed, 168 N.J. 113, 773 A.2d 659 (2001); State v. Nemeth, 214 N.J.Super. at 327, 519 A.2d 367. One of the goals of the SVPA is to protect the public by providing treatment and security for convicted sex offenders who are likely to reoffend because of a current mental abnormality or personality disorder which predisposes them to commit acts of sexual violence. In re the Commitment of M.G. and D.C., 331 N.J.Super. 365, 375, 751 A.2d 1101 (App. Div.2000). The focus of the SVPA is on the subject's current mental condition and the present danger to the public, not on punishment. Id. at 372, 373, 751 A.2d 1101. See also In re Registrant J.M., 167 N.J. 490, 501, 772 A.2d 349 (2001) (Megan's Law case emphasizing that the focus on prior offenses in the Registrant Risk Assessment Scale (RRAS) is not due to any attempt at punishment but rather was an attempt to better protect society from those likely to reoffend). The conduct triggering the State's petition is not only a prior conviction for a sexually violent offense but the current mental condition of the individual. Kansas v. Hendricks, 521 U.S. at 362, 117 S.Ct. at 2082, 138 L.Ed.2d at 515. The statement on appellant's 1999 plea form, that the State did not have a report that he suffered from a mental illness, was irrelevant to whether P.C. in February 2001 suffered from a mental abnormality *219 or personality disorder which made him likely to engage in acts of sexual violence in the future if not confined for custody, care and treatment.
Certainly, the 1999 plea agreement and the 18-month sentence on the fourth-degree offense alerted the authorities to appellant's presence in the State of New Jersey and his potential menace to our citizens when released from prison. However, his commitability in 2001, or now in 2002, under the SVPA may not be altered by the November 1999 plea agreement. The present danger, not past negotiations, must control in this circumstance.
Affirmed.
