I'm kind of an idiot, please help

I am still learning action script so please bare with me if my question is extremely easy to fix, but below is a code that I’m trying to use for a button, and below that is the error I keep getting when I check it. Can anyone explain to me what I’m forgetting to put in here and why?

AS


on (release) {
}
function(){
if (_root.currMovie == undefined) {
_root.currMovie = “contact”;
this._parent.container.loadMovie(“contact.swf”);
} else if (_root.currMovie != “contact”) {
if (this._parent.container._currentframe >= this._parent.container.midframe) {
_root.currMovie = “contact”;
this._parent.container.play();
}
}
}

Error Message


Error Symbol=text_stock, layer=text, frame=1:Line 3: Statement must appear within on handler
function(){

Total ActionScript Errors: 1 Reported Errors: 1

Please help. Thank you, S