elemAnim = null;
function couponPop(boxid, width, height) {
  fadeCenterBox(boxid, width, height, true);
  elemAnim = new YAHOO.util.Anim(boxid, { opacity: { from: 0, to: 1 }}, 0, YAHOO.util.Easing.easeIn);
  elemAnim.animate();
  
  return false;
}

function couponPopClose(boxid) {
  var o = document.getElementById(boxid);
  
  if(o != null)
    o.style.display = 'none';
  
  removePopupBlock();
}

function centerBox(boxid, width, height) {
  var cBox = document.getElementById(boxid);
  if(cBox != null) {
    var w = YAHOO.util.Dom.getViewportWidth();
    var h = YAHOO.util.Dom.getViewportHeight();
    var t = YAHOO.util.Dom.getDocumentScrollTop();
    
    cBox.style.left = (parseInt(w / 2) - (width / 2)).toString() + "px";
    cBox.style.top = (parseInt(h / 2) - (height / 2) + t).toString() + "px";
  }
  
  return cBox;
}

function fadeCenterBox(boxid, width, height, fadeOnly) {
  var cBox = centerBox(boxid, width, height);
  
  if(cBox != null || fadeOnly == true) {
    if(cBox != null)
      cBox.style.display = 'block';
    
    YAHOO.util.Dom.setStyle("fadeblock", "display", "block");
    YAHOO.util.Dom.setStyle("fadeblock", "opacity", 0);
    YAHOO.util.Dom.setStyle("fadeblock", "width", YAHOO.util.Dom.getDocumentWidth() + "px");
    YAHOO.util.Dom.setStyle("fadeblock", "height", "4500px");
    
    var a = new YAHOO.util.Anim("fadeblock", { opacity: { from: 0, to: 0.5 } }, 0.2, YAHOO.util.Easing.easeNone);
    a.animate();
  }
  
  return false;
}

function removePopup(boxid) {
  var cBox = document.getElementById(boxid);
  if(cBox != null)
    cBox.style.display = 'none';
  
  YAHOO.util.Dom.setStyle("fadeblock", "display", "none");
  
  return false;
}
