function popupDiv() {
  var overlay = document.getElementById('overlay');
  var popup = document.getElementById('popup');
  var popupContent = document.getElementById('popupContent');
  popup.style.top = getScroll() + 100 + 'px'; /* This fixes the top position of the popup on the screen so change to suit */
  prepareIE();
  overlay.style.display = 'block';    
  popup.style.display = 'block';
}

function closePopup() {
  var overlay = document.getElementById('overlay');
  var popup = document.getElementById('popup');
  var popupContent = document.getElementById('popupContent');
  popupContent.innerHTML = '';
  popup.style.display = 'none';
  overlay.style.display = 'none';
}

function getScroll(){
    var yScroll;

    if (self.pageYOffset) {
        yScroll = self.pageYOffset;
    } else if (document.documentElement && document.documentElement.scrollTop){  // Explorer 6 Strict
        yScroll = document.documentElement.scrollTop; 
    } else if (document.body) {// all other Explorers
        yScroll = document.body.scrollTop;
    }
       return yScroll;
}

function prepareIE(){
    var overlay = document.getElementById('overlay');
    overlay.style.width = document.body.clientWidth + 'px';
    overlay.style.height = getDocHeight() + 'px';
    
}

function getDocHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );

}

function getPage(url) {
    var xhr; 
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
      xhr = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
      xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }     
  
    xhr.onreadystatechange  = function()
    { 
         if(xhr.readyState  == 4)
         {
          if(xhr.status  == 200) { 
             response =  xhr.responseText;
             var target = document.getElementById('popupContent');
             if (target) {
              target.innerHTML = response;
              $('#banner pre code').each(function() {
                  eval($(this).text());
              }
              );              
             }
            
          }
          else {
            response = "Error code " + xhr.status;            
            popupDiv('alertPopup',response,"<a href=\"javascript:closePopup('alertPopup');\">Close</a>");            
          }
         }
    }; 

   xhr.open('GET', url,  true); 
   xhr.send(null);

}
