Event.observe(window, 'load', function()	{
	var hider = document.createElement('div');
	hider.id = 'hider';
	hider.className = 'hider';
	hider.styleClass = 'hider';
	document.body.appendChild(hider);
	
	hider.style.width = '100%';
	hider.style.height = '100%';
	hider.style.background = 'black';
	hider.style.position = 'absolute';
	hider.style.top = '0px';
	hider.style.left = '0px';
	hider.style.display = 'none';
	hider.style.opacity = '0';
	hider.style.filter = 'alpha(opacity=0)';
	hider.style.zIndex = 1;

	
	$('hider').show_fx = new Fx.Styles($('hider'), {duration: 250, transition: Fx.Transitions.linear});	
	$('hider').hide_fx = new Fx.Styles($('hider'), {duration: 250, transition: Fx.Transitions.linear, onComplete: 
		function()	{
			$('hider').style.display = 'none';
		}
	});	
}, false);

function show_hider()	{
	// window.scrollTo(0,0);
	$('hider').style.display = 'block';
	$('hider').style.width = getInnerWidth() * 1.2 + 'px';
	$('hider').style.height = getScrollTop() + getInnerHeight() * 1.2 + 'px';
	$('hider').style.top = -1 * getInnerHeight() / 12 + 'px';
	$('hider').style.left = -1 * getInnerWidth() / 12 + getScrollWidth() + 'px';
	$('hider').show_fx.custom({
		'opacity' : [0, 0.5]
	});	
}

function hide_hider()	{
	$('hider').hide_fx.custom({
		'opacity' : [0.5, 0]
	});	
}

function show_popup(popup_box)	{
	// fade the background to black
	show_hider();

	// style the popup_box
	popup_box.className = 'popup_form';
	popup_box.styleClass = 'popup_form';
	
	// make sure the popup_box shows up in front
	document.body.insertBefore(popup_box, document.body.firstChild);

	// benchmarks
	popup_box.style.height = '';
	popup_box.style.width = '';
	var target_height = popup_box.offsetHeight;
	var target_width = popup_box.offsetWidth;
	if(	target_height > getInnerHeight() ||
		target_width > getInnerWidth()
	)	{
		target_height = getInnerHeight() * .9;
		target_width = getInnerWidth() * .9;
	}
	popup_box.style.height = 1;
	popup_box.style.width = 1;
	
	popup_box.shown_width = target_width;
	popup_box.shown_height = target_height;

	// go nuts
	popup_box.show_fx = new Fx.Styles(popup_box, {duration: 750, transition: Fx.Transitions.backOut});
	popup_box.show_fx.custom({
		'width' : [1, popup_box.shown_width],
		'height' : [1, popup_box.shown_height],
		'left' : [getScrollWidth() + getInnerWidth(window) / 2, getScrollWidth() + getInnerWidth(window) / 2 - target_width / 2],
		// 'top' : [getScrollHeight() + getInnerHeight(window) / 2, getScrollHeight() + getInnerHeight(window) / 2 - target_height / 2]
		'top' : [0, getScrollHeight() + 25]
	});	
}

function hide_popup(popup_box)	{
	// create a remover function
	popup_box.remove = function()	{
		this.element.parentNode.removeChild(this.element);
	};
	
	// benchmarks
	var source_height = popup_box.offsetHeight;
	var source_width = popup_box.offsetWidth;
	
	// in case it's still opening
	popup_box.show_fx.clearTimer();
	
	// go nuts
	popup_box.hide_fx = new Fx.Styles(popup_box, {duration: 250, transition: Fx.Transitions.backIn, onComplete: popup_box.remove});
	popup_box.hide_fx.custom({
		'width' : [source_width, 1],
		'height' : [source_height, 1],
		'left' : [getScrollWidth() + getInnerWidth(window) / 2 - source_width / 2, getScrollWidth() + getInnerWidth(window) / 2],
		// 'top' : [getScrollHeight() + getInnerHeight(window) / 2 - source_height / 2, getScrollHeight() + getInnerHeight(window) / 2]
		'top' : [getScrollHeight() + 25, 0]
	});	
	
	// unfade the background from black
	hide_hider();
}