function windowOpen(url,width,height,scroll)
{
	wid = ( screen.availwidth - width ) / 2;
	hei = ( screen.availheight - height ) / 2;
	size = 'width=' + width + ',height=' + height + ',top=' + hei + ',left=' + wid;
	etc = size + ',resizable=no,scrollbars='+scroll;
	window.open(url,'mainpopup',etc);
}

function companyLink()
{
	windowOpen('http://www.geopia.com/company/home.ggi',750,600,'no');
}

function hompyOpen(userid)
{
	if(userid)
	{
		var width=940;
		var height=540;
		wid = ( screen.availwidth - width ) / 2;
		hei = ( screen.availheight - height ) / 2;
		size = 'width=' + width + ',height=' + height + ',top=' + hei + ',left=' + wid;
		etc = size + ',resizable=no,scrollbars=no,status=no';
		reval = window.open('http://hompy.geopia.com/?masterid='+userid,'geoblog',etc);
		reval.focus();
	}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function select_action(searchword)
{
	var fn = document.searchForm;
	if(fn.flag.value=="unified")
	{
		searchForm.action="http://search.infomaster.co.kr/find_unified.ggi?word="+searchword;
	}
	else if(fn.flag.value=="group")
	{
		searchForm.action="http://search.infomaster.co.kr/find_group.ggi?word="+searchword;
	}
	else if(fn.flag.value=="databank")
	{
		searchForm.action="http://search.infomaster.co.kr/find_databank.ggi?word="+searchword;
	}
	else if(fn.flag.value=="sabu")
	{
		searchForm.action="http://sabu.infomaster.co.kr/?action=left_search&searchWordK="+searchword;
	}
	else if(fn.flag.value=="report")
	{
		searchForm.action="http://report.infomaster.co.kr/?view=list&mode=search&keykind=subject&keyword="+searchword;
	}
	else if(fn.flag.value=="treatise")
	{
		searchForm.action="http://nonmun.infomaster.co.kr/?view=list&mode=search&keykind=subject&keyword="+searchword;
	}
	else if(fn.flag.value=="board")
	{
		searchForm.action="http://data.infomaster.co.kr/databank/search.ggi";
	}
	else if(fn.flag.value=="databankreport")
	{
		searchForm.action="http://data.infomaster.co.kr/databank/search.ggi";
	}
	else if(fn.flag.value=="databankdocu")
	{
		searchForm.action="http://data.infomaster.co.kr/databank/search.ggi";
	}
	else if(fn.flag.value=="sooheng")
	{
		searchForm.action="http://data.infomaster.co.kr/infodata/out_infosearchlist.ggi";
	}
	else if(fn.flag.value=="kstudy")
	{
		searchForm.action="http://data.infomaster.co.kr/infodata/kstudy_infosearchlist.ggi";
	}
	else if(fn.flag.value == 'kdb')
	{
		searchForm.action = 'http://kdb.infomaster.co.kr';
	}

	searchForm.submit();
}

function kdbSearchOpt(flag)
{
	if(flag == 'kdb')
	{
		document.getElementById('categorySearchDiv').style.display = 'block';
	}
	else
	{
		document.getElementById('categorySearchDiv').style.display = 'none';
	}
}

function swindC(url,width,height) {
			wid = ( screen.availwidth - width ) / 2;
			hei = ( screen.availheight - height ) / 2;
			size = 'width=' + width + ',height=' + height + ',top=' + hei + ',left=' + wid;
			etc = size + ',resizable=no,scrollbars=no';
			window.open(url,'mainpopup',etc);
		}


function openWindow(url,target,width,height) {
			wid = ( screen.availwidth - width ) / 2;
			hei = ( screen.availheight - height ) / 2;
			size = 'width=' + width + ',height=' + height + ',top=' + hei + ',left=' + wid;
			etc = size + ',resizable=no,scrollbars=no';
			window.open(url,target,etc);
		}

function swindCDJ(url,width,height) {
	wid = ( screen.availwidth - width ) / 2;
	hei = ( screen.availheight - height ) / 2;
	size = 'width=' + width + ',height=' + height + ',top=' + hei + ',left=' + wid;
	etc = size + ',resizable=no,scrollbars=yes';
	window.open(url,'pop',etc);
}

function open_geohome_page(userid,view) {
	if(userid){
		var width=940;
		var height=540;
		wid = ( screen.availwidth - width ) / 2;
		hei = ( screen.availheight - height ) / 2;
		size = 'width=' + width + ',height=' + height + ',top=' + hei + ',left=' + wid;
		etc = size + ',resizable=no,scrollbars=no,status=no';
		url = 'http://hompy.geopia.com/?masterid='+userid+'&view='+view;
		reval = window.open(url,'geoblog',etc);
		reval.focus();
	}
	else
	{
		alert('·Î±×ÀÎ ÈÄ ÀÌ¿ëÇÏ¼¼¿ä.');
	}
}

function open_geohome(userid) {
	if(userid){
		var width=940;
		var height=540;
		wid = ( screen.availwidth - width ) / 2;
		hei = ( screen.availheight - height ) / 2;
		size = 'width=' + width + ',height=' + height + ',top=' + hei + ',left=' + wid;
		etc = size + ',resizable=no,scrollbars=no,status=no';
		reval = window.open('http://hompy.geopia.com/?masterid='+userid,'geoblog',etc);
		reval.focus();
	}
}

function selectTabMenu(mode)
{
	var imageKey,imageName;
	switch(mode)
	{
		case 'question':
			imageKey = 'listMenu6';
			imageName = 'knowdb_list1_menu_6on.gif';
		break;

		case 'all':
			imageKey = 'listMenu2';
			imageName = 'knowdb_list1_menu_2on.gif';
		break;

		case 'free':
			imageKey = 'listMenu3';
			imageName = 'knowdb_list1_menu_3on.gif';
		break;

		case 'rare':
			imageKey = 'listMenu4';
			imageName = 'knowdb_list1_menu_4on.gif';
		break;

		case 'prepare':
			imageKey = 'listMenu5';
			imageName = 'knowdb_list1_menu_5on.gif';
		break;

		case 'reserve':
			imageKey = 'listMenu7';
			imageName = 'knowdb_list1_menu_7on.gif';
		break;
	}

	if(mode == 'question')
	{
		document.images[imageKey+'_1'].src = 'http://ad.infomaster.co.kr/infomaster/kdb/knowdb_list1_menu_6on.gif';
		document.getElementById(imageKey+'_2').style.background = "url('http://ad.infomaster.co.kr/infomaster/kdb/knowdb_list1_menu_6on_back.gif')";
		document.images[imageKey+'_3'].src = 'http://ad.infomaster.co.kr/infomaster/kdb/knowdb_list1_menu_6on_right.gif';
	}
	else
	{
		document.images[imageKey].src = 'http://ad.infomaster.co.kr/infomaster/kdb/'+imageName;
	}
}

function loginInputCheck()
{
	var fn = document.loginForm;

	if(!fn.userid.value)
	{
		alert('¾ÆÀÌµð¸¦ ÀÔ·ÂÇÏ¼¼¿ä.');
		fn.userid.focus();
		return false;
	}
	else if(!fn.passwd.value)
	{
		alert('ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä');
		fn.passwd.focus();
		return false;
	}
}

// È¸¿ø°¡ÀÔ
function go_join_form()
{
	join_win = window.open('https://addusrs.geopia.com:448/', 'join_win', 'width=773,height=580,marginwidth=0,marginheight=0,resizable=0,scrollbars=1,status=0');
	join_win.blur();
	join_win.focus();
}

function go_idpass_form()
{
	ippass_win = window.open('http://login.geopia.com/geopia/login_pass_01.ggi?vfrom=i', 'PRIVATE','scrollbars=yes,resizable=no,copyhistory=no,width=500,height=260');
}

// °ú±Ý¿©ºÎ °æ°íÃ¢
function paymentAlert(price,mode,type,ctId,idx)
{
	if(confirm('ÀÌ Áö½ÄDB¸¦ ¿­¶÷ÇÏ½Ã·Á¸é Áö½Ä³»°ø '+price+' ¶Ç´Â Áö¿À¸Ó´Ï '+price+'¿øÀÌ Â÷°¨µË´Ï´Ù.\n\n¿­¶÷ÇÏ½Ã°Ú½À´Ï±î?\n\n(ÇÑ¹ø ¿­¶÷ÇÑ Áö½ÄDB´Â 2ÁÖ°£ ¹«·á·Î ¿­¶÷ÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù)'))
	{
		var fn = document.listToView;

		if(type == 'search')
		{
			fn.target = '_blank';
		}

		fn.mode.value = mode;
		fn.ctId.value = ctId;
		fn.idx.value = idx;
		fn.submit();
	}
}

function buyLink(price,mode,type,ctId,idx)
{
	var fn = document.listToView;

	if(type == 'search')
	{
		fn.target = '_blank';
	}

	fn.mode.value = mode;
	fn.ctId.value = ctId;
	fn.idx.value = idx;
	fn.submit();
}

function personalPayAlert(mode,type,ctId)
{
	if(confirm('ÀÌ ÀÚ·á´Â °³ÀÎ Ä«Å×°í¸® Àü¿ëÀÚ·á ÀÌ¿ë·á¸¦ °áÁ¦ÇÏ½Å ÈÄ¿¡ ÀÌ¿ëÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù.'))
	{
		var fn = document.listToPay;

		if(type == 'search')
		{
			fn.target = '_blank';
		}

		fn.mode.value = mode;
		fn.ctId.value = ctId;
		fn.submit();
	}
}

// °³ÀÎÄ«Å×°í¸® Àü¿ë
function personalPayLink(mode,type,ctId,idx)
{
	var fn = document.listToView;

	if(type == 'search')
	{
		fn.target = '_blank';
	}

	fn.mode.value = mode;
	fn.ctId.value = ctId;
	fn.idx.value = idx;
	fn.submit();
}

// °ü¸®ÀÚ ±â´É
function listManager(type)
{
	var fn = document.manager;
	var check = false;

	for(var i=0;i<fn.elements.length;i++)
	{
		if(fn.elements[i].type == 'checkbox' && fn.elements[i].checked == true)
		{
			check = true;
			break;
		}
	}

	if(check == false && type != 'resetMoveCtId')
	{
		alert('°Ô½Ã¹°À» ¼±ÅÃÇÏ¼¼¿ä.');
	}
	else
	{
		if(type == 'delete' && confirm('¼±ÅÃÇÑ °Ô½Ã¹°À» »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?'))
		{
			fn.actionType.value = type;
			fn.submit();
		}
		else if(type == 'move')
		{
			openPopup('http://kdb.infomaster.co.kr?view=categoryMove',700,150,'move','no')
			/*
			if(!fn.category.value)
			{
				alert('ÀÌµ¿ÇÒ Ä«Å×°í¸®¸¦ ¼±ÅÃÇÏ¼¼¿ä.');
			}
			else if(confirm('¼±ÅÃÇÑ °Ô½Ã¹°À» ÀÌµ¿ÇÏ½Ã°Ú½À´Ï±î?'))
			{
				fn.actionType.value = type;
				fn.submit();
			}
			*/
		}
		else if(type == 'price')
		{
			openPopup('http://kdb.infomaster.co.kr?view=priceSet',700,150,'move','no');
		}
		else if(type == 'reserve' && confirm('¼±ÅÃÇÑ °Ô½Ã¹°À» º¸·ùÇÏ½Ã°Ú½À´Ï±î?'))
		{
			fn.actionType.value = type;
			fn.submit();
		}
		else if(type == 'resetMoveCtId' && confirm('ÀÌµ¿ Ä«Å×°í¸®¸¦ ÃÊ±âÈ­ÇÏ½Ã°Ú½À´Ï±î?'))
		{
			fn.actionType.value = type;
			fn.submit();
		}
		else if(type == 'rank')
		{
			fn.actionType.value = type;
			fn.submit();
		}
		else if(type == 'adult' && confirm('¼ºÀÎÀÚ·á Ã³¸®ÇÏ½Ã°Ú½À´Ï±î?'))
		{
			fn.actionType.value = type;
			fn.submit();
		}
		else if (type == 'popular' && confirm('ÀÎ±âÀÚ·á¿¡¼­ ¹èÁ¦ÇÏ½Ã°Ú½À´Ï±î?'))
		{
			fn.actionType.value = type;
			fn.submit();
		}
		else if (type == 'buyDelete' && confirm('±¸¸ÅÇÑ Áö½Äµðºñ Á¤º¸¸¦ »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?'))
		{
			fn.action.value = 'buyDelete';
			fn.actionType.value = type;
			fn.submit();
		}
		else if (type == 'favoriteDelete' && confirm('°ü½É Áö½Äµðºñ Á¤º¸¸¦ »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?'))
		{
			fn.action.value = 'favoriteDelete';
			fn.actionType.value = type;
			fn.submit();
		}
	}
}

function listAllCheck(status)
{
	var fn = document.manager;

	for(var i=0;i<fn.elements.length;i++)
	{
		if(fn.elements[i].type == 'checkbox')
		{
			fn.elements[i].checked = status;
		}
	}
}



function eg_all_checkbox(status,tg)
{
	if(tg == 1){
		var fn = document.manager;
		for(var i=0;i<fn.elements.length;i++)
		{
			if(fn.elements[i].type == 'checkbox')
			{
				fn.elements[i].checked = status;
			}
		}
	}else{
		var fn = document.manager;
		for(var i=0;i<fn.elements.length;i++)
		{
			if(fn.elements[i].type == 'checkbox')
			{
				fn.elements[i].checked = false;
			}
		}
	}
}



function update()
{
	cal_byte2(document.writeform.intro.value);
}

function cal_byte2(aquery)
{
	var tmpStr;
	var temp=0;
	var onechar;
	var tcount;
	tcount = 0;

	tmpStr = new String(aquery);
	temp = tmpStr.length;

	for (k=0;k<temp;k++)
	{
		onechar = tmpStr.charAt(k);
		if (escape(onechar) =='%0D') { } else if (escape(onechar).length > 4) { tcount += 2; } else { tcount++; }
	}

	//document.all['cbyte'].innerHTML = tcount;
	if(tcount > 500)
	{
		reserve = tcount - 500;
		alert("°³¿ä´Â ÇÑ±Û 255ÀÚ±îÁö ÀÛ¼ºÇÒ ¼ö ÀÖ½À´Ï´Ù."); 
		nets_check2(document.writeform.intro.value);
		return;
	}
}

function nets_check2(aquery)
{
	var tmpStr;
	var temp=0;
	var onechar;
	var tcount;
	tcount = 0;

	tmpStr = new String(aquery);
	temp = tmpStr.length;

	for(k=0;k<temp;k++)
	{
		onechar = tmpStr.charAt(k);

		if(escape(onechar).length > 4)
		{
			tcount += 2;
		}
		else
		{
			if(escape(onechar)=='%0A')
			{}
			else
			{
				tcount++;
			}
		}

		if(tcount>500)
		{
			tmpStr = tmpStr.substring(0,k);
			break;
		}

	}
	document.writeform.intro.value = tmpStr;
	cal_byte2(tmpStr);
}

// ¼ýÀÚ¸¸ ÀÔ·Â
function onlynumber()
{
	if((event.keyCode < 48) || (event.keyCode>57))
	{
		event.returnValue=false;
	}
}

function displayToggle(div,type)
{
	if (type == 'none')
	{
		document.getElementById(div).style.display = 'none';
	}
	else if (type == 'block')
	{
		document.getElementById(div).style.display = 'block';
	}
}

function openPopup(url,width,height,target,scrollbar)
{
	wid = ( screen.availwidth - width ) / 2;
	hei = ( screen.availheight - height ) / 2;
	size = 'width=' + width + ',height=' + height + ',top='+hei + ',left='+wid;
	etc = size + ',resizable=no,scrollbars=' + scrollbar;
	window.open(url,target,etc);
}


// XMLHttpRequest °´Ã¼ »ý¼º
function createHttpRequest()
{
	if(document.all)
	{
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
		return new XMLHttpRequest();
	}
}

function AjaxAction(url,divName)
{
	var Req = createHttpRequest();

	Req.open('POST',url,true);
	Req.onreadystatechange = function()
	{
		if(Req.readyState == 4)
		{
			if(Req.status == 200)
			{
				document.getElementById(divName).innerHTML = Req.responseText;
			}
		}
	}
	Req.send(null);
}
