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.
then i would write a standard function that takes the link as an argument.
<script src="YOUR SCRIPT.js"></script>
then when you want to call it
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
<a href="#" onlclick="popUp('/img.jpg')> my link </a>