/*
Sprint Popup script

This script will autmatically resize popups to sprint standard sizes, based on the length of the content.  It will only resize the window if it has an "opener" so you can go directly to the page and it won't resize.  Has legacy sizes for pre-redo popups that are still hanging around.

Any questions, suggestions, or requests contact Aaron Barker (abarke04).


REQUIREMENTS:
	- must call the common.js before this file.
	
OPTIONS
	- can define "popW" and "popH" after this file is called, but before the onload fires off to define your own size that will override the standard sizes.  MUST define both.
	- press "ctrl-`" to force a resize if full screen
*/

var popW, popH, forceResize2;

function printThis() {
	var ua = navigator.userAgent.toLowerCase();

	var is_mac = ua.indexOf('mac') > 0;

	if (is_mac) { alert('To print:\n\nUse Command + P. on your keyboard\n') }
	else { print(); } 
}

function resizeWin(popUpSize){
	// legacy function... leaving to prevent errors
}


function resizeWin2(){
	if(opener || forceResize2){ // only resize if it has a parent or we are forcing it
		if(document.body.id=="pop" && !popW){

			// check for large div's denoting a 3col wide page
			isWide = false;
			divs = d.getElementsByTagName('div');
			for(x=0; x<divs.length; x++){
				if(divs[x].className.indexOf('large') != -1) isWide=true;
			}
			footY = findPosY(document.getElementById('footer')); // find the Y of the footer
			// redo sizes
			if (isWide){
				window.resizeTo(750, footY+100);
			} else if (footY+100 <= 499){
				window.resizeTo(537, footY+100);
			} else {
				window.resizeTo(537, 400);
			}
		}else if(popW){ // defined size, so use it
			window.resizeTo(popW, popH);
		}else{ // pre redo sizes
			if (popUpSize == "short"){
				window.resizeTo(537, 300);
			} else if (popUpSize == "wide"){
				window.resizeTo(750, 400);
			} else {
				window.resizeTo(537, 500);
			}
		}
	} else {
		d.onkeydown=forceResize;
	}
}
function forceResize(e){ // alows user to force it to resize, even if no parent... prss ctrl-`
	e=document.all?window.event:e;
	if(e.ctrlKey && e.keyCode == 192){
		forceResize2 = true;
		resizeWin2();
	}
	return;
}

sprint_addLoadEvent(resizeWin2);
