////////////////////////////////////////////////////////////////////////////////<description>
// <filename>winx.js</filename>
// <language>JavaScript</language>
// <funtions>
//	<prototype>void setDefWinSize(iWidth, iHeight);</prototype>
//	<prototype>void sizingWindows(iWidth, iHeight);</prototype>
// <revision>2003.09.17.0445</revision>
////////////////////////////////////////////////////////////////////////////////</description>

ns=(navigator.appName.indexOf("Netscape")!=-1)?1:0; 
ie=(navigator.appName.indexOf("Microsoft")!=-1)?1:0; 
vn=parseInt(navigator.appVersion);

function centerWinSize(defWidth, defHeight, offWidth, offHeight)
{
	var barHeight = 25;
	var minWidth = screen.availWidth * .25;
	var minHeight = screen.availHeight * .25;
	var maxWidth = screen.availWidth * .8;
	var maxHeight = screen.availHeight * .9;
	var offLeft = 0;
	var offTop = 0;
	var posLeft = 0;
	var posTop = 0;

	if(defWidth<minWidth || defWidth>maxWidth) defWidth = maxWidth;
	if(defHeight<minHeight || defHeight>maxHeight) defHeight = maxHeight;

	posTop = (screen.availHeight - defHeight) * .5;
	posLeft = (screen.availWidth - defWidth) * .5;

	window.moveTo(posLeft, posTop);

	if(typeof(window.screenTop) != "undefined" && typeof(window.screenTop) != undefined)
	{
	  defWidth += window.screenLeft - posLeft;
	  defHeight += window.screenTop + barHeight - posTop;
	}
	else if (ns)
	{
	  defWidth += window.outerWidth - window.innerWidth;
	  defHeight += window.outerHeight - window.innerHeight;
	}
	if(screen.availWidth < defWidth) defWidth = screen.availWidth;
	if(screen.availHeight < defHeight) defHeight = screen.availHeight;

	window.resizeTo(defWidth, defHeight);

	offTop = screen.availHeight - defHeight;
	offLeft = screen.availWidth - defWidth;

	posTop = offTop / 2 - offHeight;
	posLeft = offLeft / 2 - offWidth;

	if(posTop > offTop) posTop = offTop * .6;
	if(posLeft > offLeft) posLeft = offLeft * .6;

	window.moveTo(posLeft, posTop); 
}

function offsetWinSize(aWidth, aHeight, offsetWidth, offsetHeight)
{
	setDefWinSize(aWidth, aHeight);
	window.moveBy(offsetWidth, offsetHeight);
}

function setDefWinSize(aWidth, aHeight)
{
	var maxWidth = screen.availWidth;
	var maxHeight = screen.availHeight;
	var minWidth = screen.width * .25;
	var minHeight = screen.height * .25;
	var defWidth = screen.width * .75;
	var defHeight = screen.height * .75;
	var offWidth = 0;
	var offHeight = 0;
	var posTop = 0;
	var posLeft = 0;

	window.resizeTo(maxWidth, maxHeight);
	if(document.body.clientWidth!=undefined) offWidth = maxWidth - document.body.clientWidth;
	if(document.body.clientHeight!=undefined) offHeight = maxHeight - document.body.clientHeight;
	if(defWidth < (aWidth + offWidth)) defWidth = aWidth + offWidth;
	if(defWidth > maxWidth) defWidth = maxWidth;
	if(defHeight < (aHeight + offWidth)) defHeight = aHeight + offHeight;
	if(defHeight > maxHeight) defHeight = maxHeight;
	window.resizeTo(defWidth, defHeight);
	offWidth = defWidth - document.body.clientWidth;
	offHeight = defHeight - document.body.clientHeight;
	posLeft = (maxWidth - defWidth + offWidth) / 2;
	posTop = (maxHeight - defHeight - offHeight) / 2;
	if(posLeft > (maxWidth - defWidth)) posLeft = maxWidth - defWidth;
	if(posTop > (maxHeight - defHeight)) posTop = maxHeight - defHeight;
	if(posLeft < 0) posLeft = 0;
	if(posTop < 0) posTop = 0;
	window.moveTo(posLeft, posTop);
}

function sizingWindows(aWidth, aHeight)
{
	var maxWidth = screen.availWidth;
	var maxHeight = screen.availHeight;
	var minWidth = screen.width * .25;
	var minHeight = screen.height * .25;
	var defWidth = screen.width * .75;
	var defHeight = screen.height * .75;
	var offWidth = 0;
	var offHeight = 0;
	var posTop = 0;
	var posLeft = 0;
	var step = 10;

	while(minWidth < defWidth || minHeight < defHeight)
	{
		window.resizeTo(minWidth, minHeight);
		offWidth = minWidth - document.body.clientWidth;
		offHeight = minHeight - document.body.clientHeight;
		if(typeof(offWidth)=='undefined' || offWidth==undefined) offWidth = 0;
		if(typeof(offHeight)=='undefined' || offHeight==undefined) offHeight = 0;
		posLeft = (maxWidth - minWidth + offWidth) / 2;
		posTop = (maxHeight - minHeight - offHeight) / 2;
		if(posLeft > (maxWidth - minWidth)) posLeft = maxWidth - minWidth;
		if(posTop > (maxHeight - minHeight)) posTop = maxHeight - minHeight;
		if(posLeft < 0) posLeft = 0;
		if(posTop < 0) posTop = 0;
		window.moveTo(posLeft, posTop);
		if(defWidth < (aWidth + offWidth)) defWidth = aWidth + offWidth;
		if(defWidth > maxWidth) defWidth = maxWidth;
		if(defHeight < (aHeight + offWidth)) defHeight = aHeight + offHeight;
		if(defHeight > maxHeight) defHeight = maxHeight;
		if(minWidth < defWidth) minWidth += step;
		if(minHeight < defHeight) minHeight += step;
	}
}

////////////////////////////////////////////////////////////////////////////////
// <eof filename="winsize.js" />
////////////////////////////////////////////////////////////////////////////////