function showDialog() {
   var dialog = document.getElementById('dialog');
   var dialogmask = document.getElementById('dialog-mask');
   if (dialog && dialogmask) {
      var width = pageWidth();
      var left = leftPosition();
      var top = topPosition();
      var dialogwidth = dialog.offsetWidth;
      var topposition = top + 150;
      var leftposition = left + (width / 2) - (dialogwidth / 2);
      dialog.style.top = topposition + "px";
      dialog.style.left = leftposition + "px";
      dialogmask.style.height = pageHeight() + "px";
      dialogmask.style.width = pageWidth();
   }
}
// hide the dialog box //
function hideDialog() {
   var dialog = document.getElementById('dialog');
   if (dialog) {
      dialog.style.visibility = 'hidden';
   }
   var dialogMask = document.getElementById('dialog-mask');
   if (dialogMask) {
      dialogMask.style.visibility = 'hidden';
   }
}
// calculate the current window width //
function pageWidth() {
   return window.innerWidth != null ? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
}

// calculate the current window height //
function pageHeight() {
   return window.innerHeight != null ? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null ? document.body.clientHeight : null;
}

// calculate the current window vertical offset //
function topPosition() {
   return typeof window.pageYOffset != 'undefined' ? window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;
}

// calculate the position starting at the left of the window //
function leftPosition() {
   return typeof window.pageXOffset != 'undefined' ? window.pageXOffset : document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;
}

