var procFlag = false;

var customercenter =
{

     getkey:function(e)
    {

        key = event.keyCode;
        tname = event.srcElement.name;

        if(key == 13)
        {
            if(tname == "txt_search_keywd")
            {
                searchBoard(mainTyp);
                return false;
            }
        }
    },

	// 검색어 조회
	 searchBoard:function(mainTyp)
    {
		location.href = "/about-us/services-faq.asp?main_typ="+mainTyp+"&txt_search_keywd="+$('txt_search_keywd').value;
    },

	// 검색어 조회
	 searchBoard2:function(mainTyp)
    {
		location.href = "/about-us/services-faq-kr.asp?main_typ="+mainTyp+"&txt_search_keywd="+$('txt_search_keywd').value;
    },

	// 뷰페이지로 이동
	 serviceView:function(search_keywd,page,main_typ,boardTyp, mainSeq)
    {
		location.href = "/about-us/services-best.asp?txt_search_keywd="+search_keywd+"&txt_curPage="+page+"&main_typ="+main_typ+"&txt_board_typ=" + boardTyp + "&txt_main_seq=" + mainSeq;
	},

	// 뷰페이지로 이동
	 serviceView2:function(search_keywd,page,main_typ,boardTyp, mainSeq)
    {
		location.href = "/about-us/services-best-kr.asp?txt_search_keywd="+search_keywd+"&txt_curPage="+page+"&main_typ="+main_typ+"&txt_board_typ=" + boardTyp + "&txt_main_seq=" + mainSeq;
	},
	// 목록
	 service_goList:function(page,board_typ,main_seq,main_typ)
	{
		location.href = "/about-us/services-faq.asp?txt_curPage="+page+"&txt_board_typ="+board_typ+"&txt_main_seq="+main_seq+"&main_typ="+main_typ;
    },

	 service_goList2:function(page,board_typ,main_seq,main_typ)
	{
		location.href = "/about-us/services-faq-kr.asp?txt_curPage="+page+"&txt_board_typ="+board_typ+"&txt_main_seq="+main_seq+"&main_typ="+main_typ;
    },
	// 이전글 다음글
	 moveSelf:function(gbn,search_keywd,page,boardTyp,mainSeq,rply_seq)
	{
        if(gbn == "PREV")
		{
            location.href = "/about-us/services-best.asp?txt_search_keywd="+search_keywd+"&txt_curPage="+page+"&txt_board_typ="+boardTyp+"&txt_main_seq="+mainSeq+"&txt_rply_seq="+rply_seq;
        }
		else
		{
            location.href = "/about-us/services-best.asp?txt_search_keywd="+search_keywd+"&txt_curPage="+page+"&txt_board_typ="+boardTyp+"&txt_main_seq="+mainSeq+"&txt_rply_seq="+rply_seq;
		}
    },

	// 이전글 다음글
	 moveSelf2:function(gbn,search_keywd,page,boardTyp,mainSeq,rply_seq)
	{
        if(gbn == "PREV")
		{
            location.href = "/about-us/services-best-kr.asp?txt_search_keywd="+search_keywd+"&txt_curPage="+page+"&txt_board_typ="+boardTyp+"&txt_main_seq="+mainSeq+"&txt_rply_seq="+rply_seq;
        }
		else
		{
            location.href = "/about-us/services-best-kr.asp?txt_search_keywd="+search_keywd+"&txt_curPage="+page+"&txt_board_typ="+boardTyp+"&txt_main_seq="+mainSeq+"&txt_rply_seq="+rply_seq;
		}
    },

	//혼인, 가족, 제적, 주민등록 신청
    applyDoc:function(type,rcpType,hodeung,judeung)
	{

		var f=document.frm;

		if(isEmpty(js_vg_login_id))
		{
			alert(Message.getMessage("MSG00180"));
			return;
		}

		//미혼만 - 호등
        if(type == "new")
		{
            if(rcpType == "02")
			{
                alert(Message.getMessage("MSG00184"));
                return;
            }

            if(hodeung == "02")
			{  //미제출

			    document.getElementById("div_applyDoc").style.display = "";
                alert(Message.getMessage("MSG00632"));

                var top  = screen.height/2 - 620/2
                var left = screen.width/2 - 650/2
                var sFeatures = "top=" + top + ",left=" + left + ",width=650,height=620,scrollbars=yes,menubar=no,status=no,resizable=no";

                window.open("","popMngrJoinDocNone",sFeatures);

                f.applitype.value = "1001";

                f.method = "post";
                f.target = "popMngrJoinDocNone";
                f.action = "/common/popMngrJoinDocNone.asp";
                f.submit();
            }

            else if(hodeung == "01")
			{  //완료
                alert(Message.getMessage("MSG00181"));
                return ;
            }
            else if(hodeung == "03")
			{  //불필
                alert(Message.getMessage("MSG00182"));
                return ;
            }
            else if(hodeung == "04")
			{  //진행

				var top  = screen.height/2 - 620/2
                var left = screen.width/2 - 650/2
                var sFeatures = "top=" + top + ",left=" + left + ",width=650,height=620,scrollbars=yes,menubar=no,status=no,resizable=no";

                window.open("","popMngrJoinDocApply",sFeatures);

                f.applitype.value = "1001";

				f.method = "post";
                f.target = "popMngrJoinDocApply";
                f.action = "/common/popMngrJoinDocApply.asp";
                f.submit();
            }
            else
                alert("Error!");
        }
        //새혼만 - 호등/주등
        else
        {
            if (rcpType == "01")
			{
                alert(Message.getMessage("MSG00185"));
                return;
            }
            if (hodeung == "01" || judeung == "01")
			{       //완료
                alert(Message.getMessage("MSG00181"));
                return ;
            }
            else if (hodeung == "03" && judeung == "03")
			{  //불필
                alert(Message.getMessage("MSG00182"));
                return ;
            }
            else if (hodeung == "04" || judeung == "04")
			{  //진행
                // f.action = "hodeung03.asp";
                applitype = "2002";
            }
            else    //신규신청
            {
                document.getElementById("div_applyDoc").style.display = "";
                alert(Message.getMessage("MSG00632"));

			    var top  = screen.height/2 - 620/2
                var left = screen.width/2 - 650/2
                var sFeatures = "top=" + top + ",left=" + left + ",width=650,height=620,scrollbars=yes,menubar=no,status=no,resizable=no";

                window.open("","popMngrJoinDocNone",sFeatures);

                f.action = "/common/popMngrJoinDocNone.asp"

				//진행
                f.applitype.value = "2002";

                f.method = "post";
                f.target = "popMngrJoinDocNone";
                f.submit();
            }
        }
	},

	 chgDcl:function()
	{
        var f = document.frm;
		
        if(f.sel_dcl_typ[1].checked)
        	$("tr_dcl").style.display      = "";
		else
			$("tr_dcl").style.display      = "none";
	},


	chgReplyTyp:function()
	{
		if(document.getElementsByName("rdo_reply_yn")[0].checked)
		{
			$("txt_email").disabled = false;
		}else{
			$("txt_email").disabled = true;
		}
	},

	// 신고등록
	 goReport:function(gbn)
	{
		var f=document.frm;

		var procFlag = false;

		if(isEmpty(js_vg_login_id))
		{

			alert(Message.getMessage("MSG00180"));
			return;
		}

		if(isEmpty($("txt_ttl").value))
		{
			alert(Message.getMessage("MSG00020"));
   			$("txt_ttl").focus();
            return;

		}

		if(isEmpty($("txt_content").value))
		{
			alert(Message.getMessage("MSG00021"));
   			$("txt_content").focus();
            return;
		}
		
		if(f.sel_dcl_typ[1].checked)
		{
			if(isEmpty($("txt_dcl_id").value))
			{
				 alert("Enter Username(or Nicknames) to report.");
				 $("txt_dcl_id").focus();
				return;
			}

		 }

		if(isEmpty($("txt_email").value))
		{
        	alert(Message.getMessage("MSG00179"));
        	$("txt_email").focus();
       		return;
    	}

		if(isValidEmail($("txt_email").value) == false)
		{
        	alert(Message.getMessage("MSG00019"));
        	$("txt_email").focus();
       		return;
    	}

		if (!confirm("Submit inqury?"))
		{
        	return;
		}


		procFlag = true;

		f.method = "post";
        f.target = "if_report";
        f.action = "/about-us/customer-support-proc.asp";
        f.submit();

	},

	// 신고 서버처리 결과
	 reportRslt:function(flag,msg,gbn)
	{
		procFlag = false;
        message(msg);

		if(gbn=="mtm")
		{
			if(flag == "True")
			{
				location.href = "/customercenter/customercenter_ContactUs_new.asp";
			}
		}
		else
		{
			if(flag == "True")
			{
				location.href = "/about-us/customer-support.asp";
			}
		}
	},

	//문서파일 올리기
    addPhoto:function(photo_chk)
	{
		var str_name="";
		var procFlag = false;
        var f = document.frm;



        if(procFlag)
		{
            alert(Message.getMessage("MSG00426"));
            return;
        }
		if (photo_chk=="N")
		{
			// 파일명 체크
			if(isEmpty(f.txt_file_upload.value))
			{
				alert(Message.getMessage("MSG00408"));
				f.txt_file_upload.focus();
				return;
			}
		}

		if (js_vg_cust_nm.length>3)
		{
			str_name=js_vg_cust_nm.substring(2,4);
		}
		else
		{
			str_name=js_vg_cust_nm.substring(1,3);
		}
        if(isMaxLenOver(str_name,str_name.length) == true)
		{
            if(f.txt_file_upload.value.indexOf(str_name) >= 0)
			{

                alert(Message.getMessage("MSG00404"));
                f.txt_file_upload.select();
                f.txt_file_upload.focus();
               return;
            }
        }

        if("::.GIF::.JPG::.PDF::".indexOf(f.txt_file_upload.value.trim().substr(f.txt_file_upload.value.trim().length-4,4).toUpperCase()) < 0)
		{
            alert(Message.getMessage("MSG00387"));
            return false;
        }

        if(isEmpty(f.txt_photo_desc.value))
		{
            alert(Message.getMessage("MSG00445"));

            f.txt_photo_desc.focus();
            return;
        }

        if(!confirm(Message.getMessage("MSG00256")))
		{
            return;
        }

        procFlag = true;

        f.method = "post";

		if (photo_chk=="Y")
		{
			f.txt_photo_mode.value="edit";
		}
		else
		{
			f.txt_photo_mode.value="save";
		}
        f.target = "if_doc_docfileUpload";
        f.action = "/about-us/service_document_upload.asp";
        f.submit();
    },

	//문서파일 올리기2
    addPhoto1:function(photo_chk)
	{
		var str_name="";
		var procFlag = false;
        var f = document.frm1;



        if(procFlag)
		{
            alert(Message.getMessage("MSG00426"));
            return;
        }
		if (photo_chk=="N")
		{
			// 파일명 체크
			if(isEmpty(f.txt_file_upload.value))
			{
				alert(Message.getMessage("MSG00408"));
				f.txt_file_upload.focus();
				return;
			}
		}

		if (js_vg_cust_nm.length>3)
		{
			str_name=js_vg_cust_nm.substring(2,4);
		}
		else
		{
			str_name=js_vg_cust_nm.substring(1,3);
		}
        if(isMaxLenOver(str_name,str_name.length) == true)
		{
            if(f.txt_file_upload.value.indexOf(str_name) >= 0)
			{

                alert(Message.getMessage("MSG00404"));
                f.txt_file_upload.select();
                f.txt_file_upload.focus();
               return;
            }
        }

        if("::.GIF::.JPG::.PDF::".indexOf(f.txt_file_upload.value.trim().substr(f.txt_file_upload.value.trim().length-4,4).toUpperCase()) < 0)
		{
            alert(Message.getMessage("MSG00387"));
            return false;
        }

        if(isEmpty(f.txt_photo_desc.value))
		{
            alert(Message.getMessage("MSG00445"));

            f.txt_photo_desc.focus();
            return;
        }

        if(!confirm(Message.getMessage("MSG00256")))
		{
            return;
        }

        procFlag = true;

        f.method = "post";

		if (photo_chk=="Y")
		{
			f.txt_photo_mode.value="edit";
		}
		else
		{
			f.txt_photo_mode.value="save";
		}
        f.target = "if_doc_docfileUpload";
        f.action = "/about-us/service_document_upload.asp";
        f.submit();
    },

	//문서파일 올리기3
    addPhoto2:function(photo_chk)
	{
		var str_name="";
		var procFlag = false;
        var f = document.frm2;



        if(procFlag)
		{
            alert(Message.getMessage("MSG00426"));
            return;
        }
		if (photo_chk=="N")
		{
			// 파일명 체크
			if(isEmpty(f.txt_file_upload.value))
			{
				alert(Message.getMessage("MSG00408"));
				f.txt_file_upload.focus();
				return;
			}
		}

		if (js_vg_cust_nm.length>3)
		{
			str_name=js_vg_cust_nm.substring(2,4);
		}
		else
		{
			str_name=js_vg_cust_nm.substring(1,3);
		}
        if(isMaxLenOver(str_name,str_name.length) == true)
		{
            if(f.txt_file_upload.value.indexOf(str_name) >= 0)
			{

                alert(Message.getMessage("MSG00404"));
                f.txt_file_upload.select();
                f.txt_file_upload.focus();
               return;
            }
        }

        if("::.GIF::.JPG::.PDF::".indexOf(f.txt_file_upload.value.trim().substr(f.txt_file_upload.value.trim().length-4,4).toUpperCase()) < 0)
		{
            alert(Message.getMessage("MSG00387"));
            return false;
        }

        if(isEmpty(f.txt_photo_desc.value))
		{
            alert(Message.getMessage("MSG00445"));

            f.txt_photo_desc.focus();
            return;
        }

        if(!confirm(Message.getMessage("MSG00256")))
		{
            return;
        }

        procFlag = true;

        f.method = "post";

		if (photo_chk=="Y")
		{
			f.txt_photo_mode.value="edit";
		}
		else
		{
			f.txt_photo_mode.value="save";
		}
        f.target = "if_doc_docfileUpload";
        f.action = "/about-us/service_document_upload.asp";
        f.submit();
    },

	//문서파일올리기 리턴
    addPhotoRslt:function (flag,msg,encodeCustNo)
	{
        procFlag = false;

        if(flag == "True")
		{
			message(msg);
            location.href = "/matching/show-document.asp?c="+encodeCustNo;
        }
		else
		{
            alert(Message.getMessage(msg));
		}
    },

	 init:function()
	{
        document.frm.reset();
	},

	// 검색어 조회
	 searchBoard_announement:function()
	{
        location.href = "/customercenter/customercenter_announement.asp?sel_searchField=" + $("sel_searchField").value + "&txt_search_keywd=" + $("txt_search_keywd").value;
    },

	// 뷰페이지로 이동
	 announemenView:function(sel_searchField,search_keywd,page,ntcSeq, boardTyp, mainSeq, rplySeq)
	{
		location.href = "/customercenter/customercenter_announementView.asp?sel_searchField="+sel_searchField+"&txt_search_keywd="+search_keywd+"&txt_curPage="+page+"&txt_ntc_seq=" + ntcSeq + "&txt_board_typ=" + boardTyp + "&txt_main_seq=" + mainSeq + "&txt_rply_seq=" + rplySeq;
	},

	// 목록
	announe_goList:function (sel_searchField,search_keywd,page)
	{
        location.href = "/customercenter/customercenter_announement.asp?sel_searchField="+sel_searchField+"&txt_search_keywd="+search_keywd+"&txt_curPage="+page;
    },

	// 이전글 다음글
	announe_moveSelf:function(gbn,sel_searchField,search_keywd,page,ntc_seq,board_typ,main_seq,rply_seq)
	{
        if(gbn == "PREV")
		{
            location.href = "/customercenter/customercenter_announementView.asp?sel_searchField="+sel_searchField+"&txt_search_keywd="+search_keywd+"&txt_curPage="+page+"&txt_ntc_seq="+ntc_seq+"&txt_board_typ="+board_typ+"&txt_main_seq="+main_seq+"&txt_rply_seq="+rply_seq;
        }else
		{
            location.href = "/customercenter/customercenter_announementView.asp?sel_searchField="+sel_searchField+"&txt_search_keywd="+search_keywd+"&txt_curPage="+page+"&txt_ntc_seq="+ntc_seq+"&txt_board_typ="+board_typ+"&txt_main_seq="+main_seq+"&txt_rply_seq="+rply_seq;
        }
    },

	// 파일다운
	fileDown:function (param1,param2,param3)
	{
		var f = document.frm;

		f.method = "post";
		f.target = "_self";
		f.action = "/common/fileDown.asp?param1=" + param1 + "&param2=" + param2 + "&param3=" + param3;
		f.submit();
	},

	docReg:function(docTyp)
	{
        if(confirm(Message.getMessage("MSG00633")))
        {
            //location.href = "customercenter_document_Proc.asp?txt_mode=" + docTyp;
            location.href = "/kr/matching/show-document-subs-proc.asp?txt_mode=" + docTyp;
        }
    },

    //회원탈퇴
    saveWithdraw:function() {
        var f = document.frm;

        if(procFlag) {
            alert(Message.getMessage("MSG00426"));
            return;
        }

        if(js_vg_cust_cls_typ != "02") {
            alert(Message.getMessage("MSG00463"));
            return;
        }

        if(!f.chk_agree_yn.checked) {
            alert(Message.getMessage("MSG00698"));
            return;
        }

        if(f.txt_mbr_pw.value == "") {
            alert(Message.getMessage("MSG00003"));
            f.txt_mbr_pw.focus();
            return;
        }

        if(!confirm(Message.getMessage("MSG00464"))) {
            return;
        }

		procFlag = true;

        f.method = "post";
        f.target = "if_proc";
        f.action = "showWithdraw_proc.asp";
        f.submit();
    },

    saveWithdrawRslt:function(flag,msg) {
        procFlag = false;

        message(msg);

        if(flag == "True") {
            //moveMain("<%=vg_home%>","Default.asp");
            parent.location.href = "/";
        }
    },

    showLayerWithdraw:function(recvCustNo) {
        customercenter.showBoxBlind();
        if(IE6) hideSelect();
        customercenter.showBox("/common/showWithdraw.asp?c="+recvCustNo,875,380);
    },

    showBoxBlind:function() {
		var arrayPageSize = getPageSize();

		if(IE)
		{
			$("matching_blind").style.filter="alpha(opacity=60)";
		}
		else
		{
			$("matching_blind").style.opacity="0.6";
		}

		$("matching_blind").style.width=arrayPageSize[0]+"px";
		$("matching_blind").style.height=arrayPageSize[1]+"px";

		$("matching_blind").style.display="block";
    },

    showBox:function(srcStr,widthStr,heightStr) {
        var f = document.frm;

		var l_width  = widthStr;
		var l_height = heightStr;

		var page_scroll = getPageScroll();

		var maxsize_w = getWindowWidth();
		var maxsize_h = getWindowHeight();
		if(maxsize_w < 500) maxsize_w = 500;
		if(maxsize_h < 500) maxsize_h = 500;

		var l_margin_w = (maxsize_w - l_width) / 2;
		var l_margin_h = (maxsize_h - l_height) / 2;

		$("matching_box").style.width  = l_width+"px";
		$("matching_box").style.height = l_height+"px";

		$("matching_box").style.left = (page_scroll[0]+l_margin_w)+"px";
		$("matching_box").style.top  = (page_scroll[1]+l_margin_h)+"px";

		$("matching_box").style.display = "block";

		f.method = "post";
		f.target = "ifr_matching_box";
		f.action = srcStr;
		f.submit();
    },

    hideBox:function() {
        $("matching_box").style.display   = "none";
        $("matching_blind").style.display = "none";
        if(IE6) showSelect();
    }

}

