function doPopups() {
  if (!document.getElementsByTagName) return false;
  var links = document.getElementsByTagName("a");
  for (var i=0; i < links.length; i++) {
    if (links[i].className.match("popup")) {
      links[i].onclick = function() {
        openSampleWindow(this.href);
        return false;
      }
    }
  }
}
window.onload = doPopups;

var WindowObjectReference = null; // global variable
var strHeight = 420;
var strWidth = 600;

function openSampleWindow(strUrl) {
	if(WindowObjectReference == null || WindowObjectReference.closed) {
		WindowObjectReference = window.open(strUrl, "SampleWindow", "height="+strHeight+",width="+strWidth+",resizable=yes,scrollbars=yes,status=no");
	}  else {
		WindowObjectReference = window.open(strUrl, "SampleWindow", "height="+strHeight+",width="+strWidth+",resizable=yes,scrollbars=yes,status=no");
  		/* if the resource to load is different, then we load it in the already opened secondary window and then we bring such window back on top/in front of its parent window. */
		WindowObjectReference.focus();
	};
}