// Determine how much the visitor had scrolled

function OpenPopupCenter(PopupName, PopupBackgroundName, PopupWidth, PopupHeight) {
	var objPopup = document.getElementById(PopupName);
	var objPopupBackground = document.getElementById(PopupBackgroundName);

	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 the page
	
	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 - objPopup.style.offsetWidth) / 2;
	//var topOffset = scrolledY + (centerY - objPopup.style.height) / 2;
	var leftOffset = scrolledX + ((centerX - PopupWidth) / 2);
	var topOffset = scrolledY + ((centerY - PopupHeight) / 2);

	objPopup.style.width = PopupWidth + "px";
	//objPopup.style.offsetWidth = PopupWidth;
	objPopup.style.height = PopupHeight + "px";
	//objPopup.style.offsetHeight = PopupHeight;
	objPopup.style.top = topOffset + "px";
	objPopup.style.left = leftOffset + "px";
	objPopup.style.display = "block";

	//Turn on the background...
	objPopupBackground.style.display = "block";
}

function OpenPopupSpecified(PopupName, PopupBackgroundName, PopupWidth, PopupHeight, x, y) {
	var objPopup = document.getElementById(PopupName);
	var objPopupBackground = document.getElementById(PopupBackgroundName);

	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 the page
	
	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 - objPopup.style.offsetWidth) / 2;
	//var topOffset = scrolledY + (centerY - objPopup.style.height) / 2;
	var leftOffset = scrolledX + x;
	var topOffset = scrolledY + y;

	objPopup.style.width = PopupWidth + "px";
	objPopup.style.height = PopupHeight + "px";
	objPopup.style.top = topOffset + "px";
	objPopup.style.left = leftOffset + "px";
	objPopup.style.display = "block";

	//Turn on the background...
	objPopupBackground.style.display = "block";
}


function ClosePopup(PopupName, PopupBackgroundName) {
	document.getElementById(PopupName).style.display='none';
	document.getElementById(PopupBackgroundName).style.display='none';
}