one way of doing it is
firstly put all your js in an external file and include it on all the pages of site that require it, so then you can chop and change the code once, and it reflect across the site.
<script src="YOUR SCRIPT.js"></script>
then i would write a standard function that takes the link as an argument.
var window = window.open('pictures','','scrollbars=no,menubar=no,height=800,width=840,resizable=yes,toolbar=no,lo cation=no,status=no');
var link = link
//yada yada rest of code
then when you want to call it
<a href="#" onlclick="popUp('/img.jpg')> my link </a>