var reset, distance;

function windowOpen(fileLocation, fileWidth, fileHeight)
{
	displayWindow=window.open(fileLocation,"dynamicWindow","toolbar=no,width=20,height=20,left=30,top=50,directories=no,status=no,scrollbars=yes,resizable=yes,menubar=no");
	displayWindow.window.focus();
	resizeWinStart(fileWidth,fileHeight);
}

function resizeWinStart(targetWidth,targetHeight)
{
	fileWidth = targetWidth + 14;
	fileHeight = targetHeight + 25;
	if (reset) { clearTimeout(reset); }
	try{
      	var currentWidth = (window.innerWidth) ? displayWindow.window.innerWidth : parseInt(displayWindow.document.body.clientWidth);
      	var currentHeight = (window.innerHeight) ? displayWindow.window.innerHeight : parseInt(displayWindow.document.body.clientHeight);
      	resizeWinCycle(fileWidth,fileHeight,currentWidth,currentHeight);
      }catch (ex) {
            clearTimeout(reset);
            resizeWinStart(targetWidth,targetHeight)
      }
}


function resizeWinCycle(targetWidth,targetHeight,currentWidth,currentHeight)
{
	if ((currentWidth != targetWidth) && (currentHeight != targetHeight))
	{
		if (currentWidth < targetWidth)
		{ distance = targetWidth - currentWidth;
			distance = (distance/10);
			distance = Math.round(distance);
			distance = (distance<1)?1:distance;
			currentWidth += distance;
		}
		else
		{ distance = currentWidth - targetWidth;
			distance = (distance/10);
			distance = Math.round(distance);
			distance = (distance<1)?1:distance;
			currentWidth -= distance;
		}
		if (currentHeight < targetHeight)
		{ distance = targetHeight - currentHeight;
			distance = (distance/10);
			distance = Math.round(distance);
			distance = (distance<1)?1:distance;
			currentHeight += distance;
		}
		else
		{ distance = currentHeight - targetHeight;
			distance = (distance/10);
			distance = Math.round(distance);
			distance = (distance<1)?1:distance;
			currentHeight -= distance;
		}
		displayWindow.window.resizeTo(currentWidth,currentHeight);
		reset = setTimeout('resizeWinCycle('+targetWidth+','+targetHeight+','+currentWidth+','+currentHeight+')','25');
	}
	return;
}