
function fireMyPopupModal() {
var scrolledX, scrolledY;
if( self.pageYOffset ) {
  scrolledX = self.pageXOffset;
  scrolledY = self.pageYOffset;
} else if( document.documentElement && document.documentElement.scrollTop ) {
  scrolledX = document.documentElement.scrollLeft;
  scrolledY = document.documentElement.scrollTop;
} else if( document.body ) {
  scrolledX = document.body.scrollLeft;
  scrolledY = document.body.scrollTop;
}

// Determine the coordinates of the center of browser's window

var centerX, centerY;
if( self.innerHeight ) {
  centerX = self.innerWidth;
  centerY = self.innerHeight;
} else if( document.documentElement && document.documentElement.clientHeight ) {
  centerX = document.documentElement.clientWidth;
  centerY = document.documentElement.clientHeight;
} else if( document.body ) {
  centerX = document.body.clientWidth;
  centerY = document.body.clientHeight;
}

  //var leftOffset = scrolledX + (centerX - 250) / 2;
  //var topOffset = scrolledY + (centerY - 200) / 2;

if (window.innerHeight && window.scrollMaxY) {
	// Firefox         
	yWithScroll = window.innerHeight + window.scrollMaxY;         
	xWithScroll = window.innerWidth + window.scrollMaxX;    
 } else if (document.body.scrollHeight > document.body.offsetHeight)
 { 
 // all but Explorer Mac         
 yWithScroll = document.body.scrollHeight;         
 xWithScroll = document.body.scrollWidth;     
 } else { 
 // works in Explorer 6 Strict, Mozilla (not FF) and Safari         
 yWithScroll = document.body.offsetHeight;         
 xWithScroll = document.body.offsetWidth;       
 }     

  var leftOffset = 0;
  var topOffset = 0;

  document.getElementById("mypopupmodal").style.top = topOffset + "px";
  document.getElementById("mypopupmodal").style.left = leftOffset + "px";
  document.getElementById("mypopupmodal").style.height =  yWithScroll + "px";
  document.getElementById("mypopupmodal").style.display = "block";
  fireMyPopup();
  
} //fim funcao firepopup


//#######################################################################

function fireMyPopup() {
var scrolledX, scrolledY;
if( self.pageYOffset ) {
  scrolledX = self.pageXOffset;
  scrolledY = self.pageYOffset;
} else if( document.documentElement && document.documentElement.scrollTop ) {
  scrolledX = document.documentElement.scrollLeft;
  scrolledY = document.documentElement.scrollTop;
} else if( document.body ) {
  scrolledX = document.body.scrollLeft;
  scrolledY = document.body.scrollTop;
}

// Determine the coordinates of the center of browser's window

var centerX, centerY;
if( self.innerHeight ) {
  centerX = self.innerWidth;
  centerY = self.innerHeight;
} else if( document.documentElement && document.documentElement.clientHeight ) {
  centerX = document.documentElement.clientWidth;
  centerY = document.documentElement.clientHeight;
} else if( document.body ) {
  centerX = document.body.clientWidth;
  centerY = document.body.clientHeight;
}

  var leftOffset = scrolledX + (centerX - 800) / 2;
  var topOffset = scrolledY + (centerY - 450) / 2;

  document.getElementById("mypopup").style.top = topOffset + "px";
  document.getElementById("mypopup").style.left = leftOffset + "px";
  document.getElementById("mypopup").style.display = "block";
}

///########################################################################
