call to undefined fucntion error
It means what it says: There is no file included in the current page request that contains the definition for a function called modalframe_close_dialog().

A quick Google search shows that this function is part of the ModalFrame API module, for which there is only a Drupal 6 release (not Drupal 7). I guess you've copied this code from a Drupal 6 site without changing it?

The comments on the ModalFrame API module page say: 


  It seems this feature is being included in Drupal core itself. So, probably there will be no stable release of this module for Drupal 7 because it will be already there


My best guess is that the Drupal 7 equivalent of this function is overlay_close_dialog(), but I can't comment as to whether that will work as in a drop-in replacement for you current code.

It might be worth reading the Initial D7UX admin overlay thread, it's basically the discussion about moving ModalFrame API into core.