/*
<b>ConstrainWindowSize(setWidth,setHeight,buffer) </b>
written by Matt Pressnall 04/15/05

<b>What does it do?</b>
It will check what the current size of a window is and will resize it if it is not within the right dimensions...A buffer can be applied so that there can be a little give and take to account for different browsers and OSs

<b>How do I use it?</b>
(call to JS files need to be on a page only once)

&lt;script type="text/javascript" src="/js/standardFunctionality/GetBrowserOSVersion.js"&gt;&lt;/script&gt; 
&lt;script type="text/javascript" src="/js/standardFunctionality/ConstrainWindowSize.js"&gt;&lt;/script&gt; 
&lt;script type="text/javascript" src="/js/standardFunctionality/ResizeWindow.js"&gt;&lt;/script&gt; 
&lt;script language="JavaScript1.2"&gt; 
var setWidth = 500;
var setHeight = 500;
var buffer = 10;
&lt;/script&gt; 
&lt;body onload="ConstrainWindowSize(setWidth,setHeight,buffer);"&gt; 

<i>Parameters:</i>
setWidth - the width you want the window to be
setHeight - the height you want the window to be	
buffer - the amount of pixels you are willing to let the window to be over or under...can be 0 if you want
*/

function ConstrainWindowSize(setWidth,setHeight,buffer){
	GetBrowserOSVersion();
	
	var windowWidth;
	var windowHeight;
	var shouldResize;
	
	
	// get the width of the browser window
	if(browser == "Microsoft Internet Explorer"){
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	} else {
		windowWidth = parent.innerWidth;
		windowHeight = parent.outerHeight;
	}
	
	// width is the only way to determine if this is popped off or not
	if(windowWidth){
		// check the window size
		if((windowWidth  > (setWidth + buffer)) || (windowWidth  < (setWidth - buffer))){
			shouldResize = 1;
		}
	}
	
	// make sure we want to resize
	if(shouldResize){
		// can figure out more info from non-ie browsers
		if(browser != "Microsoft Internet Explorer"){
			// already has missing location bar
			if(! window.locationbar.visible){
				shouldResize = 0;
			}
		}
	}
	
	// resizing so need to make the window a little bigger since it has toolbars and whatnot
	if(shouldResize){
		setWidth = setWidth + buffer;
		setHeight = setHeight + buffer + buffer;
		ResizeWindow(setWidth,setHeight);
	}
}