//replaced all window.innerWidth with document.body.offsetWidth


//floatW is the width of the element you are passing in.  Needed to work for IE

function showPopUp(func, onCompleteFunc, closeFuncName, postUrl, floatW)
{
	if(navigator.appVersion.match('MSIE 6.'))
	{
		hideSelectElements();
	}
	floatW = floatW ? floatW : '500';
	if(!postUrl)postUrl = location.href;
	window.scrollTo(0,0);
	if (!closeFuncName)
	{
		closeFuncName = 'closePopUp';
	}
	if (!$('overlayNew'))
	{
		genOverlayNew();
	}
	//$('overlayNew').style.display='';
	//$('overlayContainer').style.display='';
	
	$('overlayNew').addEvent('click', function(){ //close popup if you click on the overlay
		eval(closeFuncName+'();');
	});
	$('overlayNew').style.display='block';
	var windowSize = window.getScrollSize();
	$('overlayNew').style.height=windowSize.y+'px';
	//scroll(0,0);

	$('overlayNew').style.zIndex='1210';
	$('overlayNew').fade('.5');
	//easeIn('overlayNew', .5);
	$('overlayContainer').style.width = floatW.toString()+'px';
	if (func.substring(0,4)=='func')//if we're passing a func
	{
		new Request({
			url: postUrl,
			method: 'post',
			evalScripts: true,
			onComplete: function(ret) {
				$('overlayContainer').style.zIndex='1211';
				$('overlayContainer').style.display='block';
				$('overlayContainer').innerHTML += ret;
				//$('overlayContainer').style.width = '500px';
				var winW = document.body.offsetWidth;

				var leftW = (winW - floatW)/2;
				$('overlayContainer').style.left = leftW + 'px';
				$('overlayContainer').fade('in');
				$('overlayContainer').style.position = 'absolute';
				$('overlayContainer').style.top = '100px';
				//easeIn('overlayContainer', 1);

				if(onCompleteFunc)
				{
					eval(onCompleteFunc);
				}
			}
		}).send('&'+func);
		
	}
	else //we're passing in text
	{
		$('overlayContainer').style.zIndex='1211';
		$('overlayContainer').innerHTML += func;
		$('overlayContainer').style.display='block';
		var winW = document.body.offsetWidth;
		var leftW = (winW - floatW)/2;
		$('overlayContainer').style.left = leftW + 'px';
		$('overlayContainer').style.position = 'absolute';
		$('overlayContainer').style.top = '100px';
		//easeIn('overlayContainer', 1);
		$('overlayContainer').fade('in');
		
	}
	
	
}

function closePopUp()
{
	if(navigator.appVersion.match('MSIE 6.'))
	{
		unHideSelectElements();
	}
	$('overlayContainer').style.opacity=0;
	$('overlayNew').style.opacity=0;
	$('overlayNew').style.zIndex='-10';
	$('overlayNew').style.display='none';
	$('overlayContainer').style.zIndex='-10';
	$('overlayContainer').innerHTML = '';
	$('overlayContainer').style.display='none';
	$('overlayNew').removeEvents('click');
}

function genOverlayNew()
{
	
	var blah = '<div style="background: rgb(60, 60, 60) none repeat scroll 0% 0%; display: none; width: 100%; position: absolute; top: 0pt; left: 0pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; z-index: -10; height: 100%; opacity: 0;" id="overlayNew"></div><div width="10px;" style="padding: 15px; background: rgb(255, 255, 255) none repeat scroll 0% 0%; display: none; position: fixed; top: 100px; left: 380.5px; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-border-radius-topleft: 8px; -moz-border-radius-topright: 8px; -moz-border-radius-bottomright: 8px; -moz-border-radius-bottomleft: 8px; z-index: -10; opacity: 0;" class="mainStyle" id="overlayContainer"></div>';
	
	var overlayNew = new Element('div', {
	'id': 'overlayNew',
	'style': 'display: none; width: 100%; height: 100%; position: absolute; opacity: 0; top: 0; left: 0; background: #3c3c3c; z-index: -10;'
	});

	var overlayContainer = new Element('div', {
	'id': 'overlayContainer',
	'class': 'mainStyle',
	'style': 'display: none; position: fixed; top: 100px; padding: 15px; left: 0; opacity: 0; background: #FFF; -moz-border-radius:8px; z-index: -10;'
	});

	document.body.appendChild(overlayNew);			// set the overlay
	document.body.appendChild(overlayContainer); 			// set the overlay

//	document.body.innerHTML += blah;
}

function easeIn(id,opacity_amount)
{
	if (!opacity_amount) { opacity_amount = 1; }

	var myLog = $(id);
	
	myLog.style.display = "block";

	var fx = new Fx.Tween(myLog, {
		property:'opacity',
		duration: 100/*,
		wait: false,
		transition: Fx.Transitions.Quad.easeIn*/
	});
	fx.start(0, opacity_amount);
}

function showCloseButton()
{
	$html = '<div style="margin-top: 10px; text-align: center;"><input type="button" value="Close" onclick="closePopUp();"></div>';
	return $html;
}
function hideSelectElements()
{
	var selectElements = document.body.getElements('select');
	for(var i = 0; i < selectElements.length; i++)
	{
		selectElements[i].style.visibility='hidden';
	}
}
function unHideSelectElements()
{
	if(!overrideOverlayClose)
	{
		var selectElements = document.body.getElements('select');
		for(var i = 0; i < selectElements.length; i++)
		{
			selectElements[i].style.visibility='';
		}
	}
}