Have a read through this article:
Adding Scripts Properly to WordPress Part 2 – JavaScript Localization
What you are doing here is passing your PHP values to the WordPress JS localization system. This then allows your JS code to get access to those variables you have passed.