var popCouponWin = false;

function downloadCoupon(couponImgURL, couponShopName){
  var d_winLeft = 20  // default, pixels from screen left to window left
  var d_winTop = 20   // default, pixels from screen top to window top
  var winWidth = 560;
  var winHeight = 350;
  var couponWinTitle = "Paris Eiffel Tower News: " + couponShopName + " ~ Discount Coupon";
  winName = "popCouponWin";
  winFeatures = "" ;
	
  winFeatures += getLocation(winWidth, winHeight, "cen", "cen");
  if (popCouponWin) popCouponWin.close();
  popCouponWin = openPopCouponWin(couponImgURL, couponWinTitle, winName, winWidth, winHeight);
  /*popCouponWin = window.open(couponImgURL, winName, "width=" + winWidth 
           + ",height=" + winHeight + winFeatures)*/
  //popCouponWin.focus();
}

function openPopCouponWin(couponImgURL, couponWinTitle, imgWinName, windowWidth, windowHeight){
  var winFeatures = "toolbar=no,scrollbars=no,resizable=no,width=" 
    + windowWidth + ",height=" + windowHeight
  coupon = couponImgURL;
  couponTitle = couponWinTitle; 
  return window.open("coupons/popCoupon.htm", imgWinName, winFeatures);
}
    
function getLocation(winWidth, winHeight, winLeft, winTop){
  var winLocation = ""
  if (winLeft < 0)
    winLeft = screen.width - winWidth + winLeft
  if (winTop < 0)
    winTop = screen.height - winHeight + winTop
  if (winTop == "cen")
    winTop = (screen.height - winHeight)/2 - 20
  if (winLeft == "cen")
    winLeft = (screen.width - winWidth)/2
  if (winLeft>0 & winTop>0)
    winLocation =  ",screenX=" + winLeft + ",left=" + winLeft	
                + ",screenY=" + winTop + ",top=" + winTop
  else
    winLocation = ""
  return winLocation;
  }
