function createPopup() {

	// Position the popup semi-randomly near
	// the center of the browser window
	var x_position = (parseInt(getPageWidth()) / 2) - 300;
	var x_entropy = Math.floor(Math.random() * getPageWidth()/10);
	var y_position = parseInt(getPageYOffset()) + parseInt(getPageHeight()) / 4;
	var y_entropy = Math.floor(Math.random() * getPageHeight()/5);

	var popup_top = (y_position + y_entropy) + 'px';
	var popup_left = (x_position + x_entropy) + 'px';

	// Create a new popup wrapper
	var popup_html = '<div id="popup_window" class="popup-wrapper" style="position: absolute; z-index: 21; top: '+popup_top+'; left: '+popup_left+';"><div id="popup_content"></div></div>'

	// ...and stick it into our document
	//document.body.appendChild(popup);
	$('container').insert(popup_html);
}

function closePopup() {
	$('popup_window').remove();

}

/**
 * Gets the scrolling offset for the height of a page
 * @author   Peter-Paul Koch (taken from his site, www.quirksmode.org)
 * @author   Sean McCann (modifications to the original code)
 */
function getPageYOffset()
{
	// pageYOffset is the standard property used to get
	// the scrolling offset for a page's height.  However,
	// IE uses its own properties.

	if (self.pageYOffset) // all except Explorer
	{
		return self.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
		// Explorer 6 Strict
	{
		return document.documentElement.scrollTop;
	}
	else if (document.body) // all other Explorers
	{
		return document.body.scrollTop;
	}
	else return false;

}

/**
 * Gets the actual width of a page
 * @author   Stephen Chapman, 3rd Jan 2005, 8th Dec 2005
 * @author   Sean McCann (modifications to the original code)
 */
function getPageWidth() {
	// pageYOffset is the standard property used to get
	// the scrolling offset for a page's height.  However,
	// IE uses its own properties.
	if (window.innerWidth != null) {
		return window.innerWidth;
	}

	// for Explorer 6 Strict ...
	if (document.documentElement && document.documentElement.clientWidth) {
		return document.documentElement.clientWidth;
	}

	// all other Explorers
	if (document.body != null) {
		return document.body.clientWidth;
	}
	else return null;
}

/**
 * Gets the actual height of a page
 * @author   Stephen Chapman, 3rd Jan 2005, 8th Dec 2005
 * @author   Sean McCann (modifications to the original code)
 *
 * The source is almost identical to getPageWidth().
 */
function getPageHeight() {
	// most browsers
	if (window.innerHeight != null) {
		return window.innerHeight;
	}

	// IE 6 Strict
	if (document.documentElement && document.documentElement.clientHeight) {
		return document.documentElement.clientHeight;
	}

	// most other IE's
	if (document.body != null) {
		return document.body.clientHeight;
	}
	else return null;
}

