
//================= DESIGN ===================//

// Å©±â±¸ÇÏ±â
function getStrSize(OrgS){
	var Cntkr=0;
	var outLength;
	
	for (var i=0; i<OrgS.length; i++){
		if (OrgS.charAt(i)>'~'){
			Cntkr = Cntkr+1;
		}
	}
	outLength = OrgS.length + Cntkr;
	
	return outLength;
}

// ³ÎÃ¼Å©
function checkNullStr(s){
	if (s.length+1 == s.split(" ").length) {		
		return false;
    	}
    	return true;
}

// ÆË¾÷Ã¢´Ý±â
function CloseSelf(){
	self.close();
}

// ¼ýÀÚÀÎÁö Ã¼Å©
function IsNum(numstr){
	var tempstr = "0123456789";
	for(var i=0;i<numstr.length;i++) 
	{
		if(tempstr.indexOf(numstr.charAt(i)) == -1) {
			return false;
		}
	}
	return true;
}

// ¼ýÀÚ,Æ¯¼ö¹®ÀÚ ºÒ°¡ Ã¼Å©
function IsChar(aStr, aLen, aHan){
        var isValid = true;
        for (var i=0; i< aLen; i++){
          if (aHan == "ENG") {
             if (!( (aStr.charCodeAt(i) >= 65 && aStr.charCodeAt(i) <= 90 ) ||
                    (aStr.charCodeAt(i) >= 97 && aStr.charCodeAt(i) <= 122) )) {
                isValid = false;
                break;
             }
          } else if (aHan == "HAN") {
             if (!( aStr.charCodeAt(i) >  127 )  )  {
                isValid = false;
                break;
             }
          } else {
             if (!( (aStr.charCodeAt(i) >= 65 && aStr.charCodeAt(i) <= 90 ) ||
                    (aStr.charCodeAt(i) >= 97 && aStr.charCodeAt(i) <= 122) ||
                    (aStr.charCodeAt(i) >  127 ) ))  {
                isValid = false;
                break;
             }
          } 
        } 
        return isValid;
}

//ÇÑ±Û¸¸ ÀÔ·Â°¡´É
function NameCheck(strName){
	 for(i=0; i<strName.length; i++){
		if(!((strName.charCodeAt(i) > 0x3130 && strName.charCodeAt(i) < 0x318F) || (strName.charCodeAt(i) >= 0xAC00 && strName.charCodeAt(i) <= 0xD7A3))) return false;
	}return true;
}

// »ç¿ëÀÚ ID À¯È¿¼ºÃ¼Å©
function IsIdChar(aStr){
        tempstr = "0123456789abcdefghijklmnopqrstuvwxyz_";
        for(i=0;i<aStr.length;i++)
          if(tempstr.indexOf(aStr.charAt(i)) == -1) return false;
        return true;
}

// ÇÑ¿µ Åä±Û
function ToggleIME(obj, ime){
	if (ime == "K") {
		obj.style.imeMode = "active";
	} else{
		obj.style.imeMode = "inactive";
	}		
}

// ÁÖ¹Î¹øÈ£ À¯È¿¼ºÃ¼Å©
function IsResId(id1, id2){
	a = Array(6);
	b = Array(7);

	for (var i=0; i<6; i++)
		a[i] = parseInt(id1.charAt(i));

	for (var j=0; j<7; j++)
		b[j] = parseInt(id2.charAt(j));

	ssntot = (a[0]*2)+(a[1]*3)+(a[2]*4)+(a[3]*5)+(a[4]*6)+(a[5]*7) + (b[0]*8)+(b[1]*9)+(b[2]*2)+(b[3]*3)+(b[4]*4)+(b[5]*5);
	ssnave = 11 - (ssntot%11);

	if (ssnave == 11) ssnave = 1;
	else if(ssnave == 10) ssnave = 0;

	if (b[6] == ssnave) return true;
	else return false;
}

// ÀÌ¸ÞÀÏÁÖ¼Ò À¯È¿¼ºÃ¼Å©
function IsMailStr(aStr){
     tempstr = "0123456789abcdefghijklmnopqrstuvwxyz_-@.";
     str1cnt = 0;
     str2cnt = 0;
     for(i=0;i<aStr.length;i++) { 
       if(tempstr.indexOf(aStr.charAt(i)) == -1) return false;
       if(aStr.charAt(i) == '@')  str1cnt += 1;
       if(aStr.charAt(i) == '.')  str2cnt += 1;
     } 
     if (str1cnt != 1 || str2cnt < 1 || str2cnt > 2) return false;
     return true;
}

// ÀüÈ­ Áö¿ª¹øÈ£ Ã¼Å©
function IsValidDDD(obj){
        if ( obj == '02'  || obj == '031' || obj == '032' || obj == '033' ||
             obj == '041' || obj == '042' || obj == '043' || obj == '051' ||
             obj == '052' || obj == '053' || obj == '054' || obj == '055' ||
             obj == '061' || obj == '062' || obj == '063' || obj == '064' ||
             obj == '011' || obj == '017' || obj == '016' || obj == '018' ||
             obj == '019'
           )
            return true;
        else
            return false;
}

// ÀüÈ­¹øÈ£ 4ÀÚ¸®·Î Ã¤¿öÁÜ(½ºÆäÀÌ½º·Î Ã¤¿ò)("012"-->"012 ")
function GetFourDigit(v){
	var ret="";
	if(v.length==4){ ret=v; }
	else if(v.length==3){ ret=v+" "; }
	else if(v.length==2){ ret=v+"  "; }
	else{ ret=v+"   "; }
	return ret;
}

// ³¯Â¥Çü½ÄÃ¼Å©
function IsDate(src){
	if(src.length==8){
		if(src.substring(4,6)<13){
			if(src.substring(6,8)>0 && src.substring(6,8)<32){
				return true;
			}
		}
	}
	return false;
}

var link_url = "http://www.bulkwangsa.org";
//==================== ÆË¾÷Ã¢ =====================//

// ¿ìÆí¹øÈ£ °Ë»öÃ¢
function FindZipCode(){
	var w=450; var h=490;
	var url="/php/common/_findzip.php";
	var t="tFindZip";	
	var opt="height=" + h + ",innerHeight=" + h + ",width=" + w + ",innerWidth=" + w;
  	if(window.screen) { 
    		var ah = screen.availHeight - 30;
    		var aw = screen.availWidth - 10;
    		var xc = (aw - w) / 2; 
    		var yc = (ah - h) / 2; 
    		opt += ",left=" + xc + ",screenX=" + xc; 
    		opt += ",top=" + yc + ",screenY=" + yc; 
    		opt += ",scrollbars=no";
  	}
	var win=window.open(url,t,opt);
	if(win) win.focus();
}

// »çÁøÀÌ¹ÌÁö ¾÷·ÎµåÃ¢
function UploadImage(){
	var w=400; var h=266;
	var url="/php/common/_uploadimg.php";
	var t="tUpdImg";	
	var opt="height=" + h + ",innerHeight=" + h + ",width=" + w + ",innerWidth=" + w;
  	if(window.screen) { 
    		var ah = screen.availHeight - 30;
    		var aw = screen.availWidth - 10;
    		var xc = (aw - w) / 2; 
    		var yc = (ah - h) / 2; 
    		opt += ",left=" + xc + ",screenX=" + xc; 
    		opt += ",top=" + yc + ",screenY=" + yc; 
    		opt += ",scrollbars=no";
  	}
	var win=window.open(url,t,opt);
	if(win) win.focus();
}

// ID/ºñ¹Ð¹øÈ£Ã£±â
function FindPassword(){
	var w=340; var h=265;
	var url="/php/member/Find_ID.php";
	var t="tFindPwd";	
	var opt="height=" + h + ",innerHeight=" + h + ",width=" + w + ",innerWidth=" + w;
  	if(window.screen) { 
    		var ah = screen.availHeight - 30;
    		var aw = screen.availWidth - 10;
    		var xc = (aw - w) / 2; 
    		var yc = (ah - h) / 2; 
    		opt += ",left=" + xc + ",screenX=" + xc; 
    		opt += ",top=" + yc + ",screenY=" + yc; 
    		opt += ",scrollbars=no";
  	}
	var win=window.open(url,t,opt);
	if(win) win.focus();
}

// Ã·ºÎÆÄÀÏ ¾÷·ÎµåÃ¢(Parameter: ¾÷·ÎµåDIR Category ID, "/" Á¦¿ÜÇÏ°í ³Ñ±è)
function GoFileUpload(path){
	var w=420; var h=266;
	var url="/php/common/_uploadfile.php?p_upload_id="+path;
	var t="tUpdFile";	
	var opt="height=" + h + ",innerHeight=" + h + ",width=" + w + ",innerWidth=" + w;
  	if(window.screen) { 
    		var ah = screen.availHeight - 30;
    		var aw = screen.availWidth - 10;
    		var xc = (aw - w) / 2; 
    		var yc = (ah - h) / 2; 
    		opt += ",left=" + xc + ",screenX=" + xc; 
    		opt += ",top=" + yc + ",screenY=" + yc; 
    		opt += ",scrollbars=no";
  	}
	var win=window.open(url,t,opt);
	if(win) win.focus();
}

// ºñ¹Ð¹øÈ£ ÀÔ·ÂÃ¢
function GetPassword(){
	var w=420; var h=266;
	var url="/php/common/_getpwd.php";
	var t="tGetPwd";	
	var opt="height=" + h + ",innerHeight=" + h + ",width=" + w + ",innerWidth=" + w;
  	if(window.screen) { 
    		var ah = screen.availHeight - 30;
    		var aw = screen.availWidth - 10;
    		var xc = (aw - w) / 2; 
    		var yc = (ah - h) / 2; 
    		opt += ",left=" + xc + ",screenX=" + xc; 
    		opt += ",top=" + yc + ",screenY=" + yc; 
    		opt += ",scrollbars=no";
  	}
	var win=window.open(url,t,opt);
	if(win) win.focus();
}

//ÄÚ¸àÆ®ÀÛ¼º½Ã ±ÛÀÚ¼ö Á¦ÇÑ
function cal_pre(tmpStr,strObj)
{        
        cal_byte(tmpStr,strObj);
}

function cal_byte(aquery,strObj) 
{

        var tmpStr;
        var temp=0;
        var onechar;
        var tcount;
		var maxlimit;
        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++; }
        }
		maxlimit = 300;
//        document.write1.nakcount.value = maxlimit-tcount;
        if(tcount>300) {
                reserve = tcount-300;
                alert("³»¿ëÀº 300ÀÚ ÀÌ»óÀº ÀÔ·Â ÇÏ½Ç¼ö ¾ø½À´Ï´Ù.\n ¾²½Å ³»¿ëÀº "+reserve+"¹ÙÀÌÆ®°¡ ÃÊ°úµÇ¾ú½À´Ï´Ù."); 
                cutText(tmpStr,strObj)
        return;
        }        

}

function cutText(tmpStr,strObj)
{
        nets_check(tmpStr,strObj);
}

function nets_check(aquery,strObj)
{

        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 {
                        // ¿£ÅÍ°ªÀÌ µé¾î¿ÔÀ»¶§ °ª(rn)ÀÌ µÎ¹ø½ÇÇàµÇ´Âµ¥ Ã¹¹øÂ° °ª(n)ÀÌ µé¾î¿ÔÀ»¶§ tcount¸¦ Áõ°¡½ÃÅ°Áö ¾Ê´Â´Ù.
                        if(escape(onechar)=='%0A') {
                        } else {
                                tcount++;
                        }
                }

                if(tcount>300) {
                        tmpStr = tmpStr.substring(0,k);
                        break;
                }

        }
        strObj.value = tmpStr;
        cal_byte(tmpStr);

}


//============= ÆäÀÌÁöÀÌµ¿ °ü·Ã/ =============//

// ¸ÞÀÎÆäÀÌÁö
function GoHome(){
	location.href="/index.php";
}

//ÀÌº¥Æ®
function GoEvent(){
	location.href="/php/product/List2.php";
}

// ·Î±×¾Æ¿ô
function GoLogOut(){
	location.href="/php/member/LogOut.php";
}

// È¸¿ø°¡ÀÔ
function GoMemberReg(){
	location.href="/php/member/Reg.php";
}

// ·Î±×ÀÎ
function GoLogIn(){
	location.href="/php/member/Login.php?return_url="+location.href;
}

// ÀÏ¹ÝÈ¸¿ø¼öÁ¤
function GoMemberMod(){
	location.href="/php/member/Mod.php";
}

//Áö´ë¹æ ¸Þ´º¸µÅ©
function GoBoard(strLink,strSeq,strTitle,strCate){
	with(document.frmLink){
		p_CA_SEQ.value = strSeq;
		p_CATE.value = strCate;
		p_CA_BOARD_TITLE.value = strTitle;
		//action = "/php/community/cafe/" + strLink + "List.php?CM_FOLDER=" + document.frmMainLink.CM_FOLDER.value;
		action = "/php/community/cafe/";
		submit();
	}
}
function GoInput(){
	with(document.frmMod){		
		action = "/php/community/cafe/?tfile=input&CM_FOLDER=" + document.frmMainLink.CM_FOLDER.value;
		submit();
	}
}
//ÀÚÀ¯°Ô½ÃÆÇ
function GoFreeBoard(){
	location.href = "/php/freeboard/List.php";
}

// 1Depth/2Depth ¸µÅ©
function GoMenu(x,y){
	var page="";
	//ºÒ±¤¼Ò°³
	if(x=="A"){
		if(y=="1"){
			page="/php/info";							//ºÒ±¤¼Ò°³
		} else if(y=="2"){
			page="/";										//»çÀÌÆ®¸Ê
		} else if(y=="3"){
			page="/php/info/way.php";			//contactus
		} else{
			page="#";										//
		}
	//±¤´ö½º´Ô
	} else if(x=="B"){
		
		if(y=="1"){
           page="/php/Buddhist/Hengjang.php";				// ±¤´ö½º´Ô
		} else {
			page="#";										// 
		}
		//¹Ìµð¾î
	} else if(x=="C"){
		if(y=="1"){
			page="/php/media/";					//¹Ìµð¾î
		} else {
			page = "#";									// 
		}
		//±³À°¿ø
	} else if(x=="D"){
		
		if(y=="1"){ 
		   page="/php/education/";		// ±³À°¿ø
		} else {
			page="#";												//
		}
		// Ä¿¹Â´ÏÆ¼
	} else if(x=="E"){
		if(y=="1"){ 
		   page="/php/community/";				// Ä¿¹Â´ÏÆ¼
		} else {
			page="#";										//
		}
		// ¹Ì´ÏÈ¨ÇÇ
	} else if(x=="F"){
		if(y=="1"){ 
			//alert("ÁØºñÁßÀÔ´Ï´Ù.");
			page="/php/minihome/";
		   //page="#";									// ¹Ì´ÏÈ¨ÇÇ
		} else {
			page="#";									//
		}
		// ÀÚ·á½Ç
	} else if(x=="G"){
		if(y=="1"){ 
		   page="/php/pds/List.php";									// ÀÚ·á½Ç
		} else {
			page="#";									//
		}
	}
	   
	
		
	location.href=page;
}
// Áö´ë¹æ ½ÃÀÛ
function GoCafeBoardView(strCMseq,strFolder,strCBseq,strCate,strCAseq,strCate2,strCBseq2){	
	with(document.frmCafeBoard){
		p_CB_SEQ.value = strCBseq;
		p_CM_SEQ.value = strCMseq;
		p_CB_CATE.value = strCate;
		p_CB_CATE2.value = strCate2;
		p_FOLDER.value = strFolder;
		p_CA_SEQ.value = strCBseq2;

		target = "ifrmCafeView";
		var cafeURL="/cafe/" + strFolder;
		aaa=window.open(cafeURL,"jidaebang");
		aaa.focus();
		action = "/php/community/View.php";
		submit();
	}
	
}

// Áö´ë¹æ ³¡

// =============================·Ñ¿À¹ö================================
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];}
}
