
//width and height are values of client display area
//this function sets the window size so that the display area is exactly the specified width/height
//works for Windows IE, Windows Firefox, Windows Mozilla, Mac IE, Mac Safari, Mac Firefox

function openWindow(url, name, width, height, other)
{
	if (name == null) name = '';
	if (width == null) width=400;
	if (height == null) height = 400;
	if (width >0 && width < 1) //% of screen
		width = width * screen.width;
	if (height >0 && height < 1) //% of screen
		height = height * screen.height-80;
	if (other == null) other = 'toolbar=no,scrollbars=no,sizable=yes';
	if (height > 600)
		other = 'toolbar=no, scrollbars=yes,sizable=yes';
	if (width && height)
		var newWindow = window.open(url, name, 'width=' + width + ',height=' + height + ',' + other); 
	else
		var newWindow = window.open(url, name, other); 
	if (!newWindow)
		alert("You must enable popups for this functionality");
	else
	{
		newWindow.focus();
		if (width && height)
			newWindow.moveTo((screen.width-width)/2,(screen.height-height-150)/2);
	}
	//return newWindow;
}

function setWindowSize(width, height, padding)  //also centers in middle of screen
{
	try
	{
	//takes out space normally added around an html element
	if (!padding)
	{
		document.body.style.marginLeft = "0px";
		document.body.style.marginTop = "0px";
		document.body.style.marginRight = "0px";
		document.body.style.marginBottom = "0px";
	}
	var tempWidth = width;//screen.width-10;
	var tempHeight = height;//screen.height-10;
	//approximately the correct size and center
	window.resizeTo(tempWidth, tempHeight);
	


//	alert("full height is " + tempHeight + " - clientHeight is " + document.body.clientHeight + " innerHeight is " + window.innerHeight);
	//IE doesn't have innerHeight (it uses document.body.clientHeight)
	if (window.innerHeight)
		useInner = 1;
	else useInner = 0;
	if (useInner)  //for non IE, make the width/height the width of the area needed, plus the length of the non-display area (toolbar, etc)
	{
		tempWidth = width+(tempWidth-window.innerWidth)+100;
		tempHeight = height + (tempHeight-window.innerHeight)+100;
	}
	else
	{
		tempWidth = width+(tempWidth-document.body.clientWidth);
		tempHeight = height + (tempHeight-document.body.clientHeight);
	}
	window.resizeTo(tempWidth,tempHeight);
	//do this one more time (mainly for IE, because otherwise it leaves space for a scrollbar)
	if (useInner)
	{
		tempWidth = width+(tempWidth-window.innerWidth);
		tempHeight = height + (tempHeight-window.innerHeight);
	}
	else
	{
		tempWidth = width+(tempWidth-document.body.clientWidth);
		tempHeight = height + (tempHeight-document.body.clientHeight);
	}
	window.resizeTo(tempWidth+1,tempHeight+1);
	window.moveTo((screen.width-width)/2,(screen.height-height-150)/2);
	//self.focus();
	}
	catch(e) { }
}
