in reply to Javascript and Perl
This:
$JSCRIPT=<<END; [download]
...probably ought to be this:
$JSCRIPT=<<'END'; [download]
That way Perl won't try to interpolate variables (such as $") that are in the JS code.
I also suggest you use strict and use warnings.