function dlr_buildPopup(el, cook, fixedPosition, fromTop){
  
  var dlr_popup = {
  
    fromTop: fromTop ? fromTop : 0,
    
    isTrident: navigator.userAgent.indexOf('MSIE ') >= 0,
    
    resizeBg: function(){      
      if(dlr_popup.isTrident){//IE is bad at fixed positioning. So position is absolute is CSS declaration and we reposition div on scroll.
        document.getElementById('dlr_couponBg').style.top = document.body.scrollTop;
        //document.getElementById('dlr_couponBg').style.position = 'absolute';
      }
    },
    
    repositionPopUp: function(){
      var w = document.body.clientWidth / 2;
      var ww = document.getElementById(el).offsetWidth / 2;
      var www = w - ww;
      document.getElementById(el).style.left = w - ww;
      if(fixedPosition){
        //if(document.defaultView == null){//Trident
        if(dlr_popup.isTrident){//Trident
          document.getElementById(el).style.top = document.body.scrollTop + dlr_popup.fromTop;
        }
        else{//Gecko, WebKit
          document.getElementById(el).style.position = 'fixed';
          document.getElementById(el).style.top = dlr_popup.fromTop;
        }
      }
    },
    
    showBox: function(){
      document.getElementById('dlr_couponBg').style.display = 'block';
      document.getElementById(el).style.display = 'block';
      dlr_popup.repositionPopUp();
      dlr_popup.resizeBg();
      dlr_popup.addLoadListener('resize', dlr_popup.resizeBg);
      dlr_popup.addLoadListener('resize', dlr_popup.repositionPopUp);
      dlr_popup.addLoadListener('scroll', dlr_popup.resizeBg);
      if(fixedPosition){//Trident
        dlr_popup.addLoadListener('scroll', dlr_popup.repositionPopUp);
      }
    },
    
    setCookie: function(value, days, domain, secure){
      if(parseInt(days) > 0){
        var today = new Date();
        var expires = new Date(today.getTime() + (days * 86400000));
      }
      path = "/";
      document.cookie = cook + "=" + escape(value) +
       ((expires) ? ";expires=" + expires.toGMTString() : "") +
       ((path) ? ";path=" + path : "") +
       ((domain) ? ";domain=" + domain : "") +
       ((secure) ? ";secure" : "");
       
       document.getElementById('dlr_couponBg').style.display = 'none';
       document.getElementById(el).style.display = 'none';
       
       return false;
    },
    
    getCookie: function(){
      var regExpCook = new RegExp(cook + '=');
      var positionCook = document.cookie.search(regExpCook);
      if(positionCook != -1){
        var stateCook = document.cookie.substring(positionCook + cook.length + 1, positionCook + cook.length + 2);
        if(stateCook == '1'){
          dlr_popup.showBox();
          dlr_popup.repositionPopUp();
        }
      }
      else{
        dlr_popup.showBox();
        dlr_popup.repositionPopUp();
      }
    },
    
    addLoadListener: function(ev, fn){
      if(typeof window.addEventListener != 'undefined'){
        window.addEventListener(ev, fn, false);
      }
      else if(typeof document.addEventListener != 'undefined'){
        document.addEventListener(ev, fn, false);
      }
      else if(typeof window.attachEvent != 'undefined'){
        window.attachEvent('on' + ev, fn);
      }
      else{
        var oldfn = window.onload;
        if(typeof window.onload != 'function'){
          window.onload = fn;
        }
        else{
          window.onload = function(){
          oldfn();
          fn();
          }
        }
      }
    }
  }
  
  this.resizeBg = dlr_popup.resizeBg;
  this.repositionPopUp = dlr_popup.repositionPopUp;
  this.alert = dlr_popup.alert;
  this.getCookie = dlr_popup.getCookie;
  this.setCookie = dlr_popup.setCookie;
  this.showBox = dlr_popup.showBox;
  this.addLoadListener = dlr_popup.addLoadListener;
  if(typeof(doNotSetListener) == "undefined"){
    this.addLoadListener('load', this.getCookie);
  }
}
