Everybody is right basically...I do it Weedpackets way and simply write it out (using PHP):
$images = array('image1.jpg','image2.jpg','image3.jpg');
foreach ($images as $key => $image) {
$javascript .= "var image[$key] = '$image';\n";
}
echo "<script type='text/javascript'>'$javascript</script>";
To illustrate the concept...and yeah, you may need to run some htmlspecialchars and such on your outputs to make javascript happy.