function myPopupRelocate() {

  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;
  }

  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 - 500) / 2;
  var topOffset = scrolledY + (centerY - 200) / 2;

  if(popupnazwa=='popup_pytanie'){
	  var leftOffset = scrolledX + (centerX - 500) / 2;
	  var topOffset = scrolledY + (centerY - 350) / 2;
  }

  if(popupnazwa=='popup_cenowa'){
	  var leftOffset = scrolledX + (centerX - 500) / 2;
	  var topOffset = scrolledY + (centerY - 280) / 2;
  }

  if(popupnazwa=='popup_znajomemu'){
	  var leftOffset = scrolledX + (centerX - 500) / 2;
	  var topOffset = scrolledY + (centerY - 280) / 2;
  }



  var leftOffset2 = scrolledX;
  var topOffset2 = scrolledY;


  document.getElementById(popupnazwa).style.top = topOffset + "px";
  document.getElementById(popupnazwa).style.left = leftOffset + "px";

  document.getElementById("fullscreen").style.top = topOffset2 + "px";
  document.getElementById("fullscreen").style.left = leftOffset2 + "px";

}

function formsHide() {
  document.getElementById("fullscreen").style.visibility='visible';
  if (document.getElementById("shopit20_hide1")){document.getElementById("shopit20_hide1").style.display='none';}
}

function formsShow() {
document.getElementById("fullscreen").style.visibility='hidden';
  if (document.getElementById("shopit20_hide1")){document.getElementById("shopit20_hide1").style.display='inline';}
}

var popupnazwa;

function fireMyPopup(nazwa) {
  popupnazwa=nazwa;
  myPopupRelocate(nazwa);
  document.getElementById(nazwa).style.display = "block";
  document.body.onscroll = myPopupRelocate;
  window.onscroll = myPopupRelocate;
}

function closeMyPopup(nazwa) {
  popupnazwa=nazwa;
  document.getElementById(nazwa).style.display = "none";
  document.getElementById("fullscreen").style.visibility = "hidden";
}
