// ±Û ¼öÁ¤/»èÁ¦ -------------------------------

function update_writing(read_type, BGNO)
{
	thisfrm = document.R_form;
	thisfrm.action = read_type + "_edit.asp?BGNO=" + BGNO;
	thisfrm.submit();
}

function delete_writing(read_type, BGNO)
{
	thisfrm = document.R_form;

	if(confirm('±ÛÀ» »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?'))
	{
		thisfrm.action = read_type + "_delete.asp?BGNO=" + BGNO;
		thisfrm.submit();
	}
}


// ¸ÞÀÏ¹ß¼Û ------------------------------------

function send_mail(receiver)
{
	var nwin;

	nwin = window.open('/common/sendmail.asp?receiver=' + receiver, 'sendmail', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=620,height=430');
	
	nwin.focus();

}



// °øÁö»çÇ× ÆË¾÷ ÄíÅ° --------------------------------------------

function setCookie( name, value, expiredays )
{
	var todayDate = new Date();
	todayDate.setDate( todayDate.getDate() + expiredays );
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}


function getCookie( name )
{
        var nameOfCookie = name + "=";
        var x = 0;
        while ( x <= document.cookie.length )
        {
                var y = (x+nameOfCookie.length);
                if ( document.cookie.substring( x, y ) == nameOfCookie ) {
                        if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
                                endOfCookie = document.cookie.length;
                        return unescape( document.cookie.substring( y, endOfCookie ) );
                }
                x = document.cookie.indexOf( " ", x ) + 1;
                if ( x == 0 )
                        break;
        }
        return "";
}

function open_Popup_html(site_code, BOARD_NO)
{
	var nwin;
	if ( getCookie( "GAPCK_Notice_" + site_code + '_' + BOARD_NO ) != "no" )
	{
		window.open('http://gapck.org/korea/common/show_notice_html.asp?site_code=' + site_code + '&BOARD_NO=' + BOARD_NO, 'notice' +  BOARD_NO, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=auto,resizable=yes,width=300,height=300');
		nwin.focus();
	}
}

function open_Popup_file(site_code, BOARD_NO)
{
	var nwin;
	if ( getCookie( "GAPCK_Notice_" + site_code + '_' + BOARD_NO ) != "no" )
	{
		window.open('http://gapck.org/korea/common/show_notice_file.asp?site_code=' + site_code + '&BOARD_NO=' + BOARD_NO, 'notice' +  BOARD_NO, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=auto,resizable=yes');
		nwin.focus();
	}
}





// Validation --------------------------------------------------

function trim2(ment){  
  var start;
  var end;

  if (ment == null) return '';

  for(i=0;i<ment.length;i++){
    mentcnt = ment.substring(i,i+1);
    if (mentcnt  !=  ' '){
      start=i;
      break;
    }
  }
  for(i=ment.length - 1;i  >  -1; i--){
    mentcnt = ment.substring(i,i+1);
    if (mentcnt != ' ') {
      end=i;
      break
    }
  }
  str = ment.substring(start,end+1);
  if (str == ' ')
  {
    str = '';
  }
  return str;
}

function Check_Vaildation_BBS(thisfrm)
{
	if (trim2(document.all['NAME'].value) == '')
		{
			alert('ÀÌ¸§À» ÀÔ·ÂÇÏ¼¼¿ä!');
			document.all['NAME'].focus();
			return false;
		}
	if (trim2(document.all['PWD'].value) == '')
		{
			alert('ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä!');
			document.all['PWD'].focus();
			return false;
		}
	if (trim2(document.all['TITLE'].value) == '')
		{
			alert('Á¦¸ñÀ» ÀÔ·ÂÇÏ¼¼¿ä!');
			document.all['TITLE'].focus();
			return false;
		}
	if (trim2(document.all['CONT'].value) == '')
		{
			alert('³»¿ëÀ» ÀÔ·ÂÇÏ¼¼¿ä!');
			document.all['CONT'].focus();
			return false;
		}

	return true;
}

function Check_Vaildation_Addr(thisfrm)
{
	if (trim2(document.all['NAME'].value) == '')
		{
			alert('ÀÌ¸§À» ÀÔ·ÂÇÏ¼¼¿ä!');
			document.all['NAME'].focus();
			return false;
		}
	if (trim2(document.all['HOME_TEL'].value) == '')
		{
			alert('ÀüÈ­¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä!');
			document.all['HOME_TEL'].focus();
			return false;
		}
	if (trim2(document.all['zip1'].value) == '')
		{
			alert('¿ìÆí¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä!');
			document.all['zip1'].focus();
			return false;
		}
	if (trim2(document.all['address2'].value) == '')
		{
			alert('»ó¼¼ÁÖ¼Ò¸¦ ÀÔ·ÂÇÏ¼¼¿ä!');
			document.all['address2'].focus();
			return false;
		}

	if (document.all['group_code'] != null && trim2(document.all['group_code'].value) == '')
		{
			alert('±×·ìÀ» ¼±ÅÃÇÏ¼¼¿ä!');
			document.all['group_code'].focus();
			return false;
		}

	return true;
}

function Check_Vaildation_Reply(thisfrm)
{
	if (trim2(document.all['CONT'].value) == '')
		{
			alert('³»¿ëÀ» ÀÔ·ÂÇÏ¼¼¿ä!');
			document.all['CONT'].focus();
			return false;
		}

	return true;
}


// °Ô½ÃÆÇ ¸®½ºÆ®¿¡¼­ »ç¿ëÀÚ Å¬¸¯½Ã 

function User_Search(name)
{
	document.L_form.KEY_TYPE.value = 'ID';
	document.L_form.SEARCH_KEY.value = name;
	document.L_form.submit();
}




// ·¹ÀÌ¾î ÄÁÆ®·Ñ ------------------------------------------------------------------------------------

function reloadPage(init) {  //reloads the window if Nav4 resized
	if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
		document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=reloadPage; }}
	else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
reloadPage(true);

function find_Obj(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=find_Obj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function showhide_layer() { //v6.0
    
	var i,p,v,obj,args=showhide_layer.arguments;
	for (i=0; i<(args.length-2); i+=3) 
		if ((obj=find_Obj(args[i]))!=null) 
		{ 
			v=args[i+2];
			if (obj.style) 
			{ 
				obj=obj.style; 
				v=(v=='show')?'visible':(v=='hide')?'hidden':v; 

				obj.visibility=v; 

				<!--  window scroll¿¡ µû¶ó À§Ä¡Á¶Àý  -->
				if(window.event != null && window.event.y != null)
					obj.top = window.event.y - 13 + document.body.scrollTop;  

				<!--  readÈ­¸é¿¡¼­ ¿­¾úÀ»¶§ Ã³¸®  -->
				if((obj = find_Obj('CHKPWD')) != null)
				{
					obj.value = '';
					obj.focus();
				}
			}
		}
}


// IFRAME ÄÁÆ®·Ñ ----------------------------------------------------------------------------------

function Resize_Frame(name, val)
{
        var Frame_Body  = document.frames(name).document.body;
        var Frame_name  = document.all(name);
	    var Frame_hieght;

		if (val == "" || val == null)
			Frame_hieght = "300px";
		else
			Frame_hieght = val + "px";

        Frame_name.style.width 
                = Frame_Body.scrollWidth + (Frame_Body.offsetWidth-Frame_Body.clientWidth);
        Frame_name.style.height 
                = Frame_Body.scrollHeight + (Frame_Body.offsetHeight-Frame_Body.clientHeight);

        if (Frame_name.style.height < Frame_hieght || Frame_name.style.width < "586px"){
            Frame_name.style.width = "586px";       //±âº» iframe ³Êºñ
            Frame_name.style.height = Frame_hieght;      //±âº» iframe ³ôÀÌ
            //window.status = 'iframe resizing fail.';
        }else{
            //window.status = '';
        }
}


// window open

function open_News(site_code)
{
	document.location = 'http://gapck.org/korea/office/news/news_list2.asp?site_code=' + site_code;
//	var nwin;
//
//	nwin = window.open('http://220.93.94.196/gapck/news/news_list_popup.asp?BGNO=1061', 'news', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=600,height=700');
//	nwin.focus();

}

