function createPopupOpener(width,height,name,attribs) {
  var attrs="";
  if (attribs) {
    attrs = "," + attribs.split(/-/).join("=yes,") + "=yes";
  }
  return function() {
    win = window.open(this.href, name, "top=40,left=40,width="+width+",height="+height+attrs);
    win.focus
    // this is defined elsewhere in the scope of the page calling this js
    // so as to be able to test the status of this window
    popup_window = win
    return false;
  } 
}

function doPopups() {
  if (!document.getElementsByTagName) return false;
  var links=document.getElementsByTagName("a");
  linkRE = new RegExp(/popup(?:(\d+)x(\d+))?(?:-([^-]*))?(?:-([^ ]*))?/);
  for (var i=0; i < links.length; i++) {   
    if (match = linkRE.exec(links[i].className)) {
      var width  = match[1] ? isNaN(match[1]) ? 500 : match[1] : 500
      var height = match[2] ? isNaN(match[2]) ? 625 : match[2] : 625
      var f = createPopupOpener(width,height,match[3],match[4])
      links[i].onclick=f
      links[i].disabled=false
    } 
  } 
} 

oldUnload = window.onload;
window.onload=doPopups;
oldUnload();

// You open the popup by assigning class="popup" to the anchor tag 
// like this:  <a href="http://www.gullbuy.com" class="popup">Search 
// By Name</a></li>
//
// To specify a different size, specify widthxheight after the word popup, e.g.
// class="popup300x200" will open up a popup window with a width of 300 pixels
// and a height of 200 pixels.

