Click Function Fires Twice With Alert

Click Function Fires Twice With Alert

I have defined a function that I attach to a field using the .click() function. My function checks a value and then either displays a hidden div or pops an alert box. Displaying the hidden div works fine, but for some reason the alert box pops twice. I'm guessing it has something to do with clicking the "OK" on the alert -- somehow it fires the click() event on the field a second time?

I've gotten around it by putting the following code at the beginning of my function:

            if (typeof(event) != "undefined") {
                // rest of code here
            }

but this seems kind of hokey. Is there a better way to handle this? Thanks very much for any help!