/***************************************************************************
 * filename : FFWindow.js<br>
 * Window관련 클래스<br>
 *
 * @version	: 1.0
 * @author	: Copyright (c) 2003 by free270. All Rights Reserved.
****************************************************************************/
if(FFWINDOW_CLASS!=null) {
	alert("[FFWindow.js]는 이미 include 되어있습니다!!");
}
var FFWINDOW_CLASS = true;

function FFWindowClass(){
	this.ALIGN_LEFT_TOP			= 7;
	this.ALIGN_CENTER_TOP		= 8;
	this.ALIGN_RIGHT_TOP		= 9;

	this.ALIGN_LEFT_MIDDLE		= 4;
	this.ALIGN_CENTER_MIDDLE	= 5;
	this.ALIGN_RIGHT_MIDDLE		= 6;

	this.ALIGN_LEFT_BOTTOM		= 1;
	this.ALIGN_CENTER_BOTTOM	= 2;
	this.ALIGN_RIGHT_BOTTOM		= 3;

	this.ALIGN_NONE				= 3;


	this.open		= FFWindow_open;
	this.openModal	= FFWindow_openModal;
	this.resizeTo	= FFWindow_resizeTo;
	this.align		= FFWindow_align;
	this.resizeAuto = FFWindow_resizeAuto;
	this.resizeAutoHeight = FFWindow_resizeAutoHeight;
	this.resizeAutoModal = FFWindow_resizeAutoModal;
	this.resizeToModal   = FFWindow_resizeToModal;
}

var FFWindow = new FFWindowClass();









/*###########[아래 함수들은 클래스의 정의를       ]######################*/
/*###########[위해서만 사용됩니다.                ]######################*/
/*###########[직접 사용하시지 마시고 위에 정의된  ]######################*/
/*###########[클래스를 이용해 호출해 주세요       ]######################*/
function FFWindow_resizeAutoModal(){
	var oBody = self.document.body;
	var i_height = oBody.scrollHeight + (oBody.offsetHeight-oBody.clientHeight);
	var i_width  = oBody.scrollWidth +  (oBody.offsetWidth-oBody.clientWidth);
	//alert(oBody.scrollWidth + "," + oBody.offsetWidth + "," + oBody.clientWidth + "," + oBody.posWidth); //590, 594, 590
	FFWindow.resizeToModal(i_width, i_height);
	self.scrollTo(0,0); 
}

function FFWindow_resizeToModal(width,height){
	var frameborder_h = parseInt(self.dialogHeight) - document.body.clientHeight;
	var frameborder_w = parseInt(self.dialogWidth)  - document.body.clientWidth;

	window.dialogWidth  = (width  + frameborder_w) + "px";
	window.dialogHeight = (height + frameborder_h) + "px"; 
}

function FFWindow_resizeAuto(){
	var oBody = self.document.body;
	var i_height = oBody.scrollHeight + (oBody.offsetHeight-oBody.clientHeight);
	var i_width  = oBody.scrollWidth + (oBody.offsetWidth-oBody.clientWidth);

	FFWindow.resizeTo(oBody.scrollWidth, oBody.scrollHeight);
	self.scrollTo(1,1); 
}

function FFWindow_resizeAutoHeight(){
	var oBody = self.document.body;
	var i_width  = oBody.scrollWidth + (oBody.offsetWidth-oBody.clientWidth);
	var i_height = oBody.scrollHeight + (oBody.offsetHeight-oBody.clientHeight);

	FFWindow.resizeTo(oBody.scrollWidth, oBody.scrollHeight);
	self.scrollTo(1,1); 
}

function FFWindow_open(align,url,winname,swidth,sheight,option){		
	if (	  align == this.ALIGN_LEFT_TOP){
		return FFWindow_openLeftTop(url,winname,swidth,sheight,option);
	}else if (align == this.ALIGN_CENTER_TOP){
		return FFWindow_openCenterTop(url,winname,swidth,sheight,option);
	}else if (align == this.ALIGN_RIGHT_TOP){
		return FFWindow_openRightTop(url,winname,swidth,sheight,option);
	}else if (align == this.ALIGN_LEFT_MIDDLE){
		return FFWindow_openLeftMiddle(url,winname,swidth,sheight,option);
	}else if (align == this.ALIGN_CENTER_MIDDLE){
		return FFWindow_openCenterMiddle(url,winname,swidth,sheight,option);
	}else if (align == this.ALIGN_RIGHT_MIDDLE){
		return FFWindow_openRightMiddle(url,winname,swidth,sheight,option);
	}else if (align == this.ALIGN_LEFT_BOTTOM){
		return FFWindow_openLeftBottom(url,winname,swidth,sheight,option);
	}else if (align == this.ALIGN_CENTER_BOTTOM){
		return FFWindow_openCenterBottom(url,winname,swidth,sheight,option);
	}else if (align == this.ALIGN_RIGHT_BOTTOM){
		return FFWindow_openRightBottom(url,winname,swidth,sheight,option);
	}else{
		open(url,winname, "width="+swidth+" ,height="+sheight+"," + option);
	}
}
function FFWindow_resizeTo(width,height){
	window.resizeTo(width, height); 
	width = width - (document.body.clientWidth -  width); 
	height = height - (document.body.clientHeight -  height); 
	window.resizeTo(width, height); 
}
function FFWindow_align(align,swidth,sheight){
	if (	  align == this.ALIGN_LEFT_TOP){
		FFWindow_alignLeftTop(swidth,sheight);
	}else if (align == this.ALIGN_CENTER_TOP){
		//
	}else if (align == this.ALIGN_RIGHT_TOP){
		//
	}else if (align == this.ALIGN_LEFT_MIDDLE){
		//
	}else if (align == this.ALIGN_CENTER_MIDDLE){
		FFWindow_alignCenterMiddle(swidth,sheight);
	}else if (align == this.ALIGN_RIGHT_MIDDLE){
		//
	}else if (align == this.ALIGN_LEFT_BOTTOM){
		//
	}else if (align == this.ALIGN_CENTER_BOTTOM){
		//
	}else if (align == this.ALIGN_RIGHT_BOTTOM){
		//
	}else{
		open(url,winname, "width="+swidth+" ,height="+sheight+"," + option);
	}
}
function FFWindow_openModal(url,args,swidth,sheight,option, popupTitle){
  if(popupTitle!=null) self.popupTitle = popupTitle;  
  var arr = showModalDialog( url, args,"dialogWidth:"+swidth+"px; dialogHeight:"+sheight+"px;" + option);
  return arr;
}


///////////////////////////////////////////////////////////////////////
//아래 함수들은 직접 호출하지 말고 위에 있는 함수를 사용하자

function FFWindow_openLeftTop(url,winname,swidth,sheight,option){
	var sx=0;
	var sy=0;
	var obj
	if(option==null) option = "";
	obj = open(url,winname, "width="+swidth+" ,height="+sheight+",top="+sy+",left="+sx+","+option);	
	return obj
}
function FFWindow_openCenterTop(url,winname,swidth,sheight,option){
	var sx=screen.availWidth/2-swidth/2;
	var sy=0;
	var obj
	if(option==null) option = "";
	obj = open(url,winname, "width="+swidth+" ,height="+sheight+",top="+sy+",left="+sx+","+option);	
	return obj
}
function FFWindow_openRightTop(url,winname,swidth,sheight,option){
	var sx=screen.availWidth-swidth - 15
	var sy=0;
	var obj
	if(option==null) option = "";
	obj = open(url,winname, "width="+swidth+" ,height="+sheight+",top="+sy+",left="+sx+","+option);	
	return obj
}

function FFWindow_openLeftMiddle(url,winname,swidth,sheight,option){
	var sx=0;
	var sy=screen.availHeight/2-sheight/2;
	var obj
	if(option==null) option = "";
	obj = open(url,winname, "width="+swidth+" ,height="+sheight+",top="+sy+",left="+sx+","+option);	
	return obj
}
function FFWindow_openCenterMiddle(url,winname,swidth,sheight,option){
	var sx=screen.availWidth/2-swidth/2;
	var sy=screen.availHeight/2-sheight/2;
	var obj
	if(option==null) option = "";
	obj = open(url,winname, "width="+swidth+" ,height="+sheight+",top="+sy+",left="+sx+","+option);	
	return obj
}
function FFWindow_openRightMiddle(url,winname,swidth,sheight,option){
	var sx=screen.availWidth-swidth - 15
	var sy=screen.availHeight/2-sheight/2;
	var obj
	if(option==null) option = "";
	obj = open(url,winname, "width="+swidth+" ,height="+sheight+",top="+sy+",left="+sx+","+option);	
	return obj
}


function FFWindow_openLeftBottom(url,winname,swidth,sheight,option){
	var sx=0;
	var sy=screen.availHeight-sheight;
	var obj
	if(option==null) option = "";
	obj = open(url,winname, "width="+swidth+" ,height="+sheight+",top="+sy+",left="+sx+","+option);	
	return obj
}
function FFWindow_openCenterBottom(url,winname,swidth,sheight,option){
	var sx=screen.availWidth/2-swidth/2;
	var sy=screen.availHeight-sheight;
	var obj
	if(option==null) option = "";
	obj = open(url,winname, "width="+swidth+" ,height="+sheight+",top="+sy+",left="+sx+","+option);	
	return obj
}
function FFWindow_openRightBottom(url,winname,swidth,sheight,option){
	var sx=screen.availWidth-swidth - 15
	var sy=screen.availHeight-sheight;
	var obj
	if(option==null) option = "";
	obj = open(url,winname, "width="+swidth+" ,height="+sheight+",top="+sy+",left="+sx+","+option);	
	return obj
}


function FFWindow_alignCenterMiddle(swidth,sheight){
	if(swidth == null){
		swidth = self.width;
	}
	if(sheight==null){
		sheight = self.height;
	}
	self.focus();
	var sx=screen.availWidth/2-swidth/2;
	var sy=screen.availHeight/2-sheight/2;
	this.resizeTo(swidth,sheight);
	self.moveTo(sx,sy)
}
function FFWindow_alignLeftTop(swidth,sheight){
	if(swidth == null){
		swidth = self.width;
	}
	if(sheight==null){
		sheight = self.height;
	}
	self.focus();
	var sx=0;
	var sy=20;
	this.resizeTo(swidth,sheight);		
	self.moveTo(sx,sy)
}


