// PopUp Window Functions

function popup_openWindow(newWindowURI,newWindowName,newWindowWidth,newWindowHeight) {
	var widthString = '', heightString = '';
	if ( typeOf(newWindowWidth) == 'number' && newWindowWidth > 0 ) widthString = ',width='+newWindowWidth;
	if ( typeOf(newWindowHeight) == 'number' && newWindowHeight > 0 ) heightString = ',height='+newWindowHeight;
	window.open(newWindowURI,newWindowName,'location=0,menubar=0,resizable=0,titlebar=0'+widthString+heightString,false);
	return false;
}

function popup_windowResizeTrue(changeWidth,changeHeight,doFocus){
	var newWidth, newHeight;
	window.resizeTo(changeWidth,changeHeight);
	newWidth = popup_getInnerSize('width');
	newHeight = popup_getInnerSize('height');
	if ( newWidth > 0 || newHeight > 0 ) {
		if ( newWidth != changeWidth && newWidth > 0 )
			changeWidth += changeWidth-newWidth;
		if ( newHeight != changeHeight && newHeight > 0 )
			changeHeight += changeHeight-newHeight;
		window.resizeTo(changeWidth,changeHeight);
	}
	if ( doFocus == true ) window.focus();
}

function popup_getInnerSize(what) { // credit: http://www.howtocreate.co.uk/tutorials/javascript/browserwindow
	var myWidth = 0, myHeight = 0;
	if ( typeof(window.innerWidth) == 'number' ) {
		//Non-IE
		myWidth		= window.innerWidth;
		myHeight	= window.innerHeight;
	} else if ( document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth		= document.documentElement.clientWidth;
		myHeight	= document.documentElement.clientHeight;
	} else if ( document.body && (document.body.clientWidth || document.body.clientHeight) ) {
		//IE 4 compatible
		myWidth		= document.body.clientWidth;
		myHeight	= document.body.clientHeight;
	}
	return what=='height'?myHeight:myWidth;
}

