var pop = null;

function cppopdown() {
  if (pop && !pop.closed) pop.close();
}

function cppopup(obj,w,h) {
  var givenurl = (obj.getAttribute) ? obj.getAttribute('href') : obj.href;
  if (!givenurl) return true;
  w = (w) ? w += 20 : 150;  // 150px*150px is the default size
  h = (h) ? h += 25 : 150;
  var contenturl = givenurl.replace(/shop_content/,"popup_content")
  var url = contenturl.replace(/shop_image/,"popup_image")
  var args = 'width='+w+',height='+h+',resizable, scrollbars';
  cppopdown();
  pop = window.open(url,'',args);
  return (pop) ? false : true;
}

window.onunload = cppopdown;

