function addField(id, str) {
	
	var innerhtml = document.all[id].innerHTML;
	document.all[id].innerHTML = innerhtml + str;
	
}


function addHtml(id, str) {
	
	document.all[id].innerHTML = "";
	document.all[id].innerHTML = str;
	
}


function showHideSpan(spanID) {
	
	menu = eval("document.all.idx1.style");
	if(menu.display == "none") {
		menu.display = "block";
	}else {
		menu.display = "none";
	}
	 
}


function showSpan(spanID) {

	span = eval("document.all." + spanID + ".style");
	span.display = "block";

}


function hideSpan(spanID) {

	span = eval("document.all." + spanID + ".style");
	span.display = "none";

}


function delConfirm(moveURL) {

	if( confirm("정말 삭제 하시겠습니까?\n하위 메뉴도 모두 삭제 됩니다.") ) {
		location.href = moveURL;
	}else{
		return;
	}

}

function searchCountry(formName, textName, hiddenField) {
	
	window.open('/common/common_nation_search.php?formName=' + formName + '&textName=' + textName + '&hiddenField=' + hiddenField, '', 
					'width=360, height=150, left=200, top=200, scrollbars=no');

}


function searchZipcode(formName, zipName, addressName) {
	var url = "/common/common_zipcode_search.php?formname="+formName+"&zip_fname="+zipName+"&addr_fname="+addressName;
	var w = 420;		//popup창 가로 크기
	var h = 200;		//popup창 세로 크기
	var x = (screen.availWidth-w)/2;
	var y = (screen.availHeight-h)/2;
	window.open(url,"zipcodeWin","width="+w+",height="+h+",status=no,scrollbars=yes,resizable=yes,left="+x+",top="+y);
}

function searchCode1User(formName, userName, userIdx, companyName, companyIdx) {
	searchCode1User(formName, userName, userIdx, companyName, companyIdx,'');
}

function searchCode1User(formName, userName, userIdx, companyName, companyIdx, postaction) {
	var url = "/common/common_usrcode1_search.php?formname="+formName+"&usrname_fname="+userName+"&usridx_fname="+userIdx+"&comname_fname="+companyName+"&comidx_fname="+companyIdx+"&postaction="+postaction;
	var w = 420;		//popup창 가로 크기
	var h = 180;		//popup창 세로 크기
	var x = (screen.availWidth-w)/2;
	var y = (screen.availHeight-h)/2;
	window.open(url,"usrcode1Win","width="+w+",height="+h+",status=no,scrollbars=yes,resizable=yes,left="+x+",top="+y);
}

function searchCode1Company(formName, textName, hiddenField, continent_fname, country_fname, agent_fname) {
	var url = "/common/common_comcode1_search.php?formname="+formName+"&name_fname="+textName+"&idx_fname="+hiddenField+"&continent_fname="+continent_fname+"&country_fname="+country_fname+"&agent_fname="+agent_fname;
	var w = 420;		//popup창 가로 크기
	var h = 320;		//popup창 세로 크기
	var x = (screen.availWidth-w)/2;
	var y = (screen.availHeight-h)/2;
	window.open(url,"comcode1Win","width="+w+",height="+h+",status=no,scrollbars=yes,resizable=yes,left="+x+",top="+y);
}

function inputMultiSerial(funcName,objCount) {
	var url = "/common/common_serial_input.php?funcname="+funcName+"&objcount="+objCount;
	var w = 420;		//popup창 가로 크기
	var h = 200;		//popup창 세로 크기
	var x = (screen.availWidth-w)/2;
	var y = (screen.availHeight-h)/2;
	window.open(url,"serialWin","width="+w+",height="+h+",status=no,scrollbars=yes,resizable=yes,left="+x+",top="+y);
}

function viewUsedParts(reportmasteridx) {
	var url = "/common/report/common_report_pop_usedparts.php?idx="+reportmasteridx;
	var w = 420;		//popup창 가로 크기
	var h = 300;		//popup창 세로 크기
	var x = (screen.availWidth-w)/2;
	var y = (screen.availHeight-h)/2;
	window.open(url,"usedpartsWin","width="+w+",height="+h+",status=no,scrollbars=yes,resizable=yes,left="+x+",top="+y);
}

function openNewWin(URL, width, height, left, top) {
	
	window.open(URL, "newWin", 'width=' + width + ', height=' + height + ', top=' + top + ', left=' + left + ', scrollbars=yes, resizable=no');
					
}


var statisticsWin = "";
				
function openWin(URL, width, height, left, top) {
	
	if(statisticsWin != ''){
		statisticsWin.close();
	}
	statisticsWin = window.open(URL, 'newWin', 'width=' + width + ', height=' + height + ', left=' + left + ', top=' + top + ', scrollbars=yes, resizable=no');
	
}


function parentResizeIframe(name)
{
	if (parent && parent != this && parent.resizeIframe != null)
	{
		parent.resizeIframe(name);
	}
}


function resizeIframe(name)
{
	if (name == null || name == "")
	{
		name = "cafe_main";
	}
	
	try
	{
		var oBody   = document.frames(name).document.body;
		var oIFrame = document.all(name);
		var frmWidth  = oBody.scrollWidth + (oIFrame.offsetWidth - oIFrame.clientWidth);
		var frmHeight = oBody.scrollHeight + (oIFrame.offsetHeight - oIFrame.clientHeight);
		var frmWidth  = oBody.scrollWidth;
		var frmHeight = oBody.scrollHeight;
		
		oIFrame.style.height = frmHeight;
		oIFrame.style.width = frmWidth;
		
	}
	catch (e)
	{
		window.status = "error";
	}
}



/* 한글 스트링 처리 함수 */
// string String::cut(int len, string tail)
String.prototype.cut = function(len, tail) 
{
	var str = this;
	var l = 0;
	for (var i=0; i<str.length; i++) 
	{
		l += (str.charCodeAt(i) > 128) ? 2 : 1;
		if (l > len) return str.substring(0,i) + tail;
	}
	return str;
}

// bool String::bytes(void)
String.prototype.bytes = function() 
{
	var str = this;
	var l = 0;
	for (var i=0; i<str.length; i++) 
		l += (str.charCodeAt(i) > 128) ? 2 : 1;

	return l;
}


//시간 체크 함수
function checkTime(year, month, day, hh, mm, state) {
	
	d = new Date();
	
	nowTime = d.getTime();
	
	if(year == null) {
		year = d.getFullYear( );
	}
	if(month == null)  {
		month = d.getMonth( );
	}
	if(day == null) {
		day = d.getDate();
	}
	if(hh == null) {
		hh = d.getHours();
	}
	if(mm == null) {
		mm = d.getMinutes( );
	}
	compareD = new Date(year, month, day, hh, mm, 0, 0);
	compareTime = compareD.getTime();
	
	//현재 시간 보다 이전
	if(state == true) {
		if( nowTime < compareTime ) return false;
	}
	//현재 시간 보다 이후
	 else {
		if( nowTime > compareTime ) return false;
	}
	
	return true;
	
}


/**
* 마우스보안관련스크립트
* 정규식으로 현재URL에 /protal/이 포함된 경우만 처리
* PORTAL 메뉴에대해서만 다 막음
* jgkim 2008.09.04 
**/
function f_ondragstart() {
  return false;
}

function f_onselectstart() {
  return false;
}

function f_oncontextmenu() {
  return false;
}

var GLOBAL_URL = location.href;	//현재URL
var _urlCheck = /\/portal\//i;	//체크할 정규식
if(_urlCheck.test(GLOBAL_URL)){	 //포탈인경우
	document.onselectstart = f_onselectstart;
	document.ondragstart = f_ondragstart;
	document.oncontextmenu = f_oncontextmenu;
}else{
	document.oncontextmenu = f_oncontextmenu;
}
//보안스크립트 끝