Google Maps Integration

Okay, I need some ideas here. I have the following script, which searches my database after a user enters a location. It returns the results on a google map with markers sorted by distance, etc.

The problem I'm having is in trying to get it to work in my CS Cart application. The script is basically for a static html page, and the stuff does most of the controlling and contains the functions, but I don't know how to get it to work on a page in my CS Cart install. Any help would be greatly appreciated.

Here is the script: