function goto_url(url){
	if(window.opener){
		url=addPopupParm(url);		
	}
	location.href=url;	
}

/*
====================================================================================================================
* 1. 함 수 명 : add_hidden
* 2. 기능설명 : 폼에 Hidden값을 추가한다.
* 3. 인수
--------------------------------------------------------------------------------------------------------------------
  인수명             타입            설명                                  기타사항
--------------------------------------------------------------------------------------------------------------------
  frm                Object          폼 객체                               필수
  name               String          Hidden Name                           필수
  value              String          Hidden Value                          필수(공백 허용 안함)
  multi              Integer         멀티 허용                             옵션(1:같은 이름을 멀티로 추가한다. 기본:한개씩만)
--------------------------------------------------------------------------------------------------------------------
*/
function add_hidden(frm, name, value, multi) {
	if (!frm) return;
	if (!name || name == "") return;

	var obj = frm.elements[name];
	if (!(obj && obj.type == "hidden") || multi == 1) {
		obj = frm.document.createElement('<input type="hidden" name="' + name + '" value="">');
		frm.appendChild(obj);
	}
	if (value != undefined) obj.value = value;

	return obj;
}

function create_form(name) {
	if (!name) name = "";

	var frm = document.forms[name];
	if (!frm) {
		frm = document.createElement('<form name="' + name + '"></form>');
		document.appendChild(frm);
	}
	for (var i = frm.elements.length - 1; i >= 0; i--) {
		frm.removeChild(frm.elements[i]);
	}
	return frm;
}

function remove_form(frm) {
	try {
		if (frm) frm.document.removeChild(frm);
	}
	catch(e) {
	}
}

function open_window(popupurl,_width,_height,_name) {

	if (popupurl=="") return;

	var win_popup_window;
	var _left, _top;
	var sURL, sName, sFeatures, bReplace;

	if (!_width || _width == null || _width == "") {
		_width  = "865";
	}
	if (!_height || _height == null || _height == "") {
		_height = "600";
	}
	_left = Math.max((screen.availWidth  - _width)  / 2, 0);
	_top  = Math.max((screen.availHeight - _height) / 2, 0);

	if (popupurl && popupurl.tagName == "FORM") {// form전송방법 알고리즘 미구현
		//sURL = "/~erp/frame_popup.php";

		//frm.action = get_fullpath(frm.action);

		//frm_window = frm;
	}
	else {
		sURL = popupurl;
	}

	sName = (_name && _name != "" ? _name : "win_popup_window");
	sFeatures = "channelmode=no,directories=no,fullscreen=no,location=no,menubar=no,status=no,toolbar=no,resizable=no,scrollbars=yes," + "left=" + _left + ",top=" + _top + ",width=" + _width + ",height=" + _height;
	bReplace = false;
	
	sURL = addPopupParm(sURL);

	win_popup_window = window.open(sURL, sName, sFeatures, bReplace);
	win_popup_window.focus();

	return win_popup_window;

}

function get_fullpath(url, doc) {
	if (!doc) doc = document;
	if (url.toLowerCase().indexOf(".php") == -1) url += ".php";
	if (url.substring(0, 1) != "/" && url.substring(0, 7) != "http://") {
		var path = doc.location.pathname;
		url = path.substring(0, path.lastIndexOf("/") + 1) + url;
	}
	return url;
}

//팝업창일경우 URI에 _ispopup_파라미터를 추가한다
function addPopupParm(sURL){
	if(sURL ==""){return;}
	
	if(sURL.indexOf("?") == -1){
		sURL += "?_ispopup_=1";
	}else{
		sURL += "&_ispopup_=1";
	}
	
	return sURL;	
}

function setCookie(c_name,value,expiredays){
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +value+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name){
	if(document.cookie.length>0){
		c_start=document.cookie.indexOf(c_name + "=");
	  	if(c_start!=-1){ 
	    	c_start=c_start + c_name.length+1;
	    	c_end=document.cookie.indexOf(";",c_start);
	    if(c_end==-1)c_end=document.cookie.length;
	    	return unescape(document.cookie.substring(c_start,c_end));
		}
	}
	return "";
}

/*
==================================================
최초작성일 : 2002년 1월 25일
최근수정일 : 2004년 9월  7일
--------------------------------------------------
  본 문서는 자유롭게 배포/복사 할 수 있으나 반드시
  이 문서의 저자에 대한 언급을 삭제하시면 안됩니다.
  (이 내용은 javaservice.net에서 copy.)
--------------------------------------------------
  이호훈(siva6)
  E-mail: siva6@dreamwiz.com
==================================================
/*
/****************************************************
    tbl      : 병합할 대상 table object
    startRow : 병합 시작 row, title 한 줄일 경우 1
    cNum     : 병합 실시할 컬럼번호, 0부터 시작
    length   : 병합할 row의 길이, 보통 1
    add      : 비교할 기준에 추가할 컬럼번호
              A | 1
              B | 1
             을 서로 구분하고 싶다면, add에 0번째
             컬럼을 추가
*****************************************************/
function mergeCell(tbl, startRow, cNum, length, add)
{
	var isAdd = false;
	if(tbl == null) return;
	if(startRow == null || startRow.length == 0) startRow = 1;
	if(cNum == null || cNum.length == 0) return ;
	if(add  == null || add.length == 0) {
		isAdd = false;
	}else {
		isAdd = true;
		add   = parseInt(add);
	}
	cNum   = parseInt(cNum);
	length = parseInt(length);
	
	rows   = tbl.rows;
	rowNum = rows.length-1; //페이지부분의 Tr은 merge대상에서 제거
	tempVal  = '';
	cnt      = 0;
	startRow = parseInt(startRow);

	for( i = startRow; i < rowNum; i++ ) { 
		curVal = rows[i].cells[cNum].innerHTML;
		if(isAdd) curVal += rows[i].cells[add].innerHTML;
		if( curVal == tempVal ) {
			if(cnt == 0) {
				cnt++;
				startRow = i - 1;
			}
			cnt++;
		}else if(cnt > 0) {
			merge(tbl, startRow, cnt, cNum, length);
			startRow = endRow = 0;
			cnt = 0;
		}else {
		}
		tempVal = curVal;
	}

	if(cnt > 0) {
		merge(tbl, startRow, cnt, cNum, length);
	}
}

/*******************************************
    mergeCell에서 사용하는 함수
********************************************/
function merge(tbl, startRow, cnt, cellNum, length)
{
	rows = tbl.rows;
	row  = rows[startRow];

	for( i = startRow + 1; i < startRow + cnt; i++ ) {
		for( j = 0; j < length; j++) {
			rows[i].deleteCell(cellNum);
		}
	}
	for( j = 0; j < length; j++) {
		row.cells[cellNum + j].rowSpan = cnt;
	}
}

