Our organization wants to have a popup that appears when you go to our site asking about filling out a survey. When it appears, the user is given the option to continue to the survey, be asked to fill it out later or never ask again. I plan on using cookies to keep track of their choice.

I know how to do this on a regular php site, however I'm unsure of the proper way to do this in Drupal. I tried adding the following to my index page, but it didn't work:

if (!isset($_COOKIE['name_of_cookie']) || $_COOKIE['name_of_cookie'] == "asklater") {
  ?>
  <script language="javascript">
  openWin("popup.php", "500", "400"); // openWin is my own js function
  </script>
  <?php
}

Is there a better way to do this in Drupal? I'd prefer not to install a module as this is only a short term project.