function f_isDialogWindow() {
	return ( typeof(self.dialogWidth) != "undefined" );
}

function f_getTopBodyObj() {
	return ( document ? document.body : false )
}

function windowPositionCenter(w,h) {
	self.top.moveTo((screen.width-w)/2,(screen.height-h)/2);
}

function f_makeObjChangeSize(w, h) {
	this.width = w;
	this.height = h;
}

function f_getChangeSize(w, h) {
	var curWidth, curHeight, objBody, objRet;
	var changeWidth, changeHeight;
	if ( !(objBody = f_getTopBodyObj()) )
		return;
	
	changeWidth = w - objBody.clientWidth;
	changeHeight = h - objBody.clientHeight;
	
	if ( isNaN(changeWidth) 
		|| isNaN(changeHeight)
		|| ( changeWidth == 0 && changeHeight == 0))
		return false;
	return new f_makeObjChangeSize(changeWidth, changeHeight);
}

function f_normalWinResize(objChangeSize) {
	if ( !objChangeSize )
		return;
	
}
function f_modalWinResize(w, h, bCenter) {
	var objChangeSize, dWidth, dHeight;
	
	if ( !w || !h )
		return;
	
	if ( !(objChangeSize = f_getChangeSize(w, h)) ) 
		return;
	
	dWidth = parseInt(top.dialogWidth)+objChangeSize.width;
	dHeight = parseInt(top.dialogHeight)+objChangeSize.height;
	
	self.top.dialogWidth = dWidth+"px";
	self.top.dialogHeight = dHeight+"px";
	
	if ( bCenter )
		windowPositionCenter(w,h);
}
function windowPositionCenter(w,h) {
	var nTop, nLeft;
	if ( !w || !h )
		return;
	nTop = (screen.height-h)/2;
	nLeft = (screen.width-w)/2;
	if ( f_isDialogWindow() ) {
		self.top.dialogTop = nTop+"px";
		self.top.dialogLeft = nLeft+"px";
	}
	else
		self.top.moveTo(nLeft, nTop);
}
function windowResize( w, h, bCenter) {
	windowResizeBy(w, h, bCenter);
}
function windowResizeBy(w, h, bCenter) {
	var objChangeSize;
	try {
		if ( f_isDialogWindow() )
			return setTimeout("f_modalWinResize("+w+", "+h+", "+bCenter+")",0);
		
		if ( !w )
			return;
		if ( !h )
			h = document.body.scrollHeight;
		
		if ( !(objChangeSize = f_getChangeSize(w, h)) ) 
			return;
			
		self.top.resizeBy(objChangeSize.width , objChangeSize.height);
		
		if ( bCenter )
			windowPositionCenter(w,h);
	}
	catch(x) {
	}
}
function windowResizeEx(w,h, bCenter) {
	windowResizeBy(w, h, bCenter);
}
function windowAutoResize(bCenter) {
	windowResizeBy(document.body.scrollWidth,document.body.scrollHeight,bCenter);
}
function windowAutoResize2(bCenter) {
	windowAutoResize(bCenter);
}
function winAutoResize(bCenter) {
	windowAutoResize(bCenter);
}
function windowGetSize() {
	alert(document.body.scrollWidth+"/"+document.body.scrollHeight);
}
