function popDiv(url, vars) {
	if(!$('overlay')) { // Verify we don't already have the overlay
		Element.insert('contentWrapper', {'before':'<div id="overlay" style="display:none;"></div>'});
	}
	
	if(!$('popDiv')) { // Checks to make sure the popup doesn't already exist
		Element.insert('contentWrapper', {'before':'<div id="popDiv" style="display:none"><div class="loading">Loading...</div></div>'});
	} else {
		$('popDiv').update('<div class="loading">Loading...</div>');
	}
	
	new Ajax.Updater('popDiv', url + vars, {evalScripts: true});
	Effect.Appear('overlay',{duration:0.5, to:0.75});
	Effect.Appear('popDiv',{duration:0.5});
}

function closePopDiv() {
	Effect.Fade('popDiv', { duration: 0.6 });
	if($('overlay'))
		Effect.Fade('overlay', { duration: 0.6 });
	if($('footer')) {
		$('footer').relativize();
		$('footer').style.top = footerPositionTop;
	}
}

function popAdmissionFormIframe(url, vars) {
	
	if(!$('popDiv')) { // Checks to make sure the popup doesn't already exist
		Element.insert('contentWrapper', {'top':'<div id="popDiv" style="display:none">Loading...</div>'});
	}
	
	$('popDiv').update('<a onclick="closePopDiv();" style="padding: 0; margin: 0; position:relative; text-decoration:none; cursor:pointer; display:block; background-color:#FFFFFF; color:#000000; text-align:right;font-weight:bold;font-size:1.5em;">- Close -</a><iframe frameborder="0" scrolling="no" width="100%" src="'+url+(vars ? vars : '')+'" id="popDivIframe" onload="resizeIframe(1300)"></iframe>');
	//parent.resizeIframe(document.body.scrollHeight)
	window.scrollTo(0,0);
	Effect.Appear('popDiv',{duration:0.5});
}

var footerPositionTop = 0;

function resizeIframe(newHeight) {
	if($('content'))
		newHeight = $('content').scrollHeight > newHeight ? $('content').scrollHeight : newHeight;
	if($('footer') && $('footer').cumulativeOffset().top < (newHeight+183) ) {
		footerPositionTop = $('footer').style.top ? $('footer').style.top : "0";
		$('footer').absolutize();
		$('footer').style.top = (newHeight+183)+"px";
	}
	$('popDivIframe').style.height = parseInt(newHeight) +'px';
}
