/***************************************************************************
 * filename : FFWindow.js<br>
 * window관련 자바스크립트<br>
 *
 * @version	: 1.0
 * @author	: Copyright (c) 2001 by free270. All Rights Reserved.
****************************************************************************/


var  WINDOW_ALIGN_CENTER			= 5;
var  WINDOW_ALIGN_RIGHT_TOP		= 9;
var  WINDOW_ALIGN_LEFT_TOP		= 7;
var  WINDOW_ALIGN_RIGHT_BOTTOM	= 3;
var  WINDOW_ALIGN_LEFT_BOTTOM	= 1;

/**
 * window.open() 함수와 동일하면 최초 창의 위치를 지정해 줄 수 있다.
 * @param align   : 정렬방식(위에 정의 되어 있는 WINDOW_ALIGN_CENTER,WINDOW_ALIGN_RIGHT_TOP.... 를 사용하면 된다.)
 * @param url     : 보이고자 하는 URL
 * @param winname : 윈도우 이름(form submit에서 target을 줄때도 필요한 이름이겠죠)
 * @param swidth  : 창의 width (option으로 줄수도 있겠지만 사용하기 편할라구 그냥 뺐다)
 * @param sheight : 창의 height(option으로 줄수도 있겠지만 사용하기 편할라구 그냥 뺐다)
 * @param option  : ex) "fullscreen=yes,toolbar=no"
 *                  fullscreen  = yes/no
 *                  channelmode = yes/no
 *                  toolbar		= yes/no
 *                  location	= yes/no
 *                  directories = yes/no
 *                  status	    = yes/no
 *                  menubar		= yes/no
 *                  scrollbars	= yes/no
 *                  resizable	= yes/no
 *                  top			= number (사용하지 마세요)
 *                  left		= number (사용하지 마세요)
 */
function FFWindowOpen(align,url,winname,swidth,sheight,option){
	if(align == WINDOW_ALIGN_CENTER)
		return openCenter(url,winname,swidth,sheight,option); 
	else if (align == WINDOW_ALIGN_RIGHT_TOP)
		return openRightTop(url,winname,swidth,sheight,option); 
	else if (align == WINDOW_ALIGN_LEFT_TOP)
		return openLeftTop(url,winname,swidth,sheight,option);
}


function FFWindowAlign(align,swidth,sheight){
	//...
}


function FFresizeTo(width,height){
	window.resizeTo(width, height); 
	width = width - (document.body.clientWidth -  width); 
	height = height - (document.body.clientHeight -  height); 
	window.resizeTo(width, height); 
}




///////////////////////////////////////////////////////////////////////
//아래 함수들은 직접 호출하지 말고 위에 있는 함수는 사용하자

function alignCenter(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 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)
}
function openCenter(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 openRightTop(url,winname,swidth,sheight,option){
	var sx=screen.availWidth-swidth - 15
	var sy=20;//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 openLeftTop(url,winname,swidth,sheight,option){
	var sx=0;
	var sy=20;//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 InsertTable() {
  var pVar = ObjTableInfo;
  var args = new Array();
  var arr = null;
   
  // Display table information dialog
  args["NumRows"] = ObjTableInfo.NumRows;
  args["NumCols"] = ObjTableInfo.NumCols;
  args["TableAttrs"] = ObjTableInfo.TableAttrs;
  args["CellAttrs"] = ObjTableInfo.CellAttrs;
  args["Caption"] = ObjTableInfo.Caption;
  
  arr = null;
  
  arr = showModalDialog( "../WebEdit/instable.htm",
                             args,
                             "font-family:Verdana; font-size:12; dialogWidth:36em; dialogHeight:25em");
  if (arr != null) {
  
    // Initialize table object
    for ( elem in arr ) {
      if ("NumRows" == elem && arr["NumRows"] != null) {
        ObjTableInfo.NumRows = arr["NumRows"];
      } else if ("NumCols" == elem && arr["NumCols"] != null) {
        ObjTableInfo.NumCols = arr["NumCols"];
      } else if ("TableAttrs" == elem) {
        ObjTableInfo.TableAttrs = arr["TableAttrs"];
      } else if ("CellAttrs" == elem) {
        ObjTableInfo.CellAttrs = arr["CellAttrs"];
      } else if ("Caption" == elem) {
        ObjTableInfo.Caption = arr["Caption"];
      }
    }
    tbContentElement.ExecCommand(DECMD_INSERTTABLE,OLECMDEXECOPT_DODEFAULT, pVar);  
  }
}
*/
