I look for a script for detect the possibilite of the navigator for the SSL.
Think.
Don't you know what port(s) your regular pages are on, and which port SSL is on? You can then just say:
if ($SERVER_PORT == 443) // or whatever port is used for SSL
Or just see if $HTTPS==on...