//아이디/비밀번호 찾기레이어 모두닫기
function closeIdPw() {
	document.getElementById("NotMemWin").style.visibility = "hidden";
	document.getElementById("passFindLayer").style.visibility = "hidden";
	document.getElementById("idFindLayer").style.visibility = "hidden";
}

/*------------------------------------------------아이디 찾기 시작----------------------------------------------*/
//아이디 찾기 요청
function requestFindID(sendForm) {
	var ajaxForm = document.ajaxFm;
	ajaxForm.findName.value = encodeURIComponent(sendForm.findName.value);
	ajaxForm.findSSN1.value = encodeURIComponent(sendForm.findSSN1.value);
	ajaxForm.findSSN2.value = encodeURIComponent(sendForm.findSSN2.value);
	document.oldForm.joinName.value = sendForm.findName.value;
	document.oldForm.joinSSN1.value = encodeURIComponent(sendForm.findSSN1.value);
	document.oldForm.joinSSN2.value = encodeURIComponent(sendForm.findSSN2.value);

	ajaxForm.regFlg.value = "";
	ajaxForm.joinName.value = "";
	ajaxForm.DupInfo.value = "";
	ajaxForm.certifyFlg.value = "";

//alert($("form[name='ajaxFm']").serialize());
	var httpObj = new Ajax.Request    (
		'find_id_ajax.asp',  {
		method:'post',
//    parameters:Form.serialize('ajaxFm'),
    parameters:$("form[name='ajaxFm']").serialize(),
		onSuccess:resultFindID,
		onFailure:resultFindIDError
		}
	);
}

//아이디 찾기 성공시
function resultFindID() {
	//closeIdPw();
    var returnData = responseHttpObj.responseText;
    //alert(responseHttpObj.responseText);
	var data = returnData.split("|");
	var sendForm = document.idFm;
	var sendOldForm = document.oldForm;

	switch (data.length)	{								//기존회원 이거나
	case 2 :
		if (data[0] == "O")			{						//기존회원 전송

			sendOldForm.action = "join2.asp";
			sendOldForm.submit();
			sendOldForm.reset();
			sendForm.reset();

		} else {
			alert("일치하는 회원정보가 없습니다.");
			//LayerGrayOn('L_findnot',300);
		}
		break;

	case 3 :														//통합회원 일경우 아이디 표시
		if (data[0] == "U")			{
			LayerGrayOn('L_findid',300);   //로그인 레이어 함수
//  document.getElementById("L_findid").style.display = "block";
//			document.getElementById("L_findpw").style.display = "inline";
//			document.getElementById("resultID").innerText = data[1];
			document.getElementById("resultName").innerHTML = data[2];
			document.getElementById("resultID").innerHTML = data[1];
			sendOldForm.reset();
			sendForm.reset();

		} else {
			alert("일치하는 회원정보가 없습니다.");
			sendOldForm.reset();
			sendForm.reset();
			//LayerGrayOn('L_findnot',300);
		}
		break;
	default :
		alert("일치하는 회원정보가 없습니다.");
		sendOldForm.reset();
		sendForm.reset();
		//LayerGrayOn('L_findnot',300);
	}
}

//아이디 찾기 실패시
function resultFindIDError() {
	//alert("아이디 찾기 조회중 문제가 발생하였습니다. 잠시후 다시 시도해주시기 바랍니다.                                ");
	LayerGrayOn('L_findnot',300);
}

//아이디 찾기 레이어 닫기
function hideidFindLayer() {
	document.getElementById("idFindLayer").style.visibility = "hidden";
}

//아이디/비밀번호 찾기 일치정보 없음 레이어닫기
function hideNotMatch() {
	document.getElementById("NotMemWin").style.visibility = "hidden";
}


//아이디 찾기
function findIMemD(fmNm) {
	//closeIdPw();

	var sendForm = document.forms[fmNm];

	if (alertSpace(sendForm, "findName",  "[이름]은" )) return false;

	if (checkNumLen(sendForm, "findSSN1",  "[주민등록번호 앞자리]는",  6)) return false;
	if (checkNumLen(sendForm, "findSSN2",  "[주민등록번호 뒷자리]는",  7)) return false;
	//if (alertSSN(sendForm.findSSN1, sendForm.findSSN2)) return false;

	requestFindID(sendForm);			//아이디 찾기 요청
}

//아이디 찾기 엔터키 처리
function enterFindID(obj) {
  if (event.keyCode =='13') { findIMemD(obj.form.name); }
}

//아이디 찾기 (아이핀 1)
function findIMemDIpin(fmNm) {

	var sendForm = document.forms[fmNm];

	requestFindIDIpin(sendForm);			//아이디 찾기 요청
}

//아이디 찾기 요청  (아이핀 2)
function requestFindIDIpin(sendForm) {
	var ajaxForm = document.ajaxFm;
	ajaxForm.regFlg.value = encodeURIComponent(sendForm.regFlg.value);
	ajaxForm.joinName.value = encodeURIComponent(sendForm.joinName.value);
	ajaxForm.DupInfo.value = sendForm.DupInfo.value;
	ajaxForm.certifyFlg.value = encodeURIComponent(sendForm.certifyFlg.value);
	
	document.oldForm.joinName.value = sendForm.findName.value;
	document.oldForm.joinSSN1.value = encodeURIComponent(sendForm.findSSN1.value);
	document.oldForm.joinSSN2.value = encodeURIComponent(sendForm.findSSN2.value);
	
	var httpObj = new Ajax.Request    (
		'find_id_ajax.asp',  {
		method:'post',
//    parameters:Form.serialize('ajaxFm'),
    parameters:$("form[name='ajaxFm']").serialize(),
		onSuccess:resultFindID,
		onFailure:resultFindIDError
		}
	);
}
/*------------------------------------------------아이디 찾기 종료----------------------------------------------*/

/*------------------------------------------------비밀번호 찾기 시작----------------------------------------------*/
//비밀번호 찾기 요청
function requestFindPass(sendForm) {
	var ajaxForm = document.ajaxFm;
	ajaxForm.findID.value = encodeURIComponent(sendForm.findID.value);
	ajaxForm.findName.value = encodeURIComponent(sendForm.findName.value);
	ajaxForm.findSSN1.value = encodeURIComponent(sendForm.findSSN1.value);
	ajaxForm.findSSN2.value = encodeURIComponent(sendForm.findSSN2.value);

	ajaxForm.regFlg.value = "";
	ajaxForm.joinName.value = "";
	ajaxForm.DupInfo.value = "";
	ajaxForm.certifyFlg.value = "";

	var httpObj = new Ajax.Request    (
		'find_pw_ajax.asp',  {
		method:'post',
//    parameters:Form.serialize('ajaxFm'),
    parameters:$("form[name='ajaxFm']").serialize(),
		onSuccess:resultFindPass,
		onFailure:resultFindPassError
		}
	);
}

//비밀번호 찾기 성공시
function resultFindPass() {
	//closeIdPw();

    var returnData = responseHttpObj.responseText;
	var data = returnData.split("|");
	var sendForm = document.pwdFm;

	switch (data.length)	{								//기존회원 이거나
	case 2 :
		if (data[0] == "O")			{						//기존회원 전송
			sendForm.action = "id_pw_originally.asp";
			sendForm.submit();
			sendForm.reset();
		} else {													//일치하는 정보가 없다는 메시지 표시
			alert("일치하는 회원정보가 없습니다.");
			sendForm.reset();
//			LayerGrayOn('L_findnot',300);
		}
		break;
	case 3 :														//통합회원 일경우 아이디 표시
		if (data[0] == "U")			{
			LayerGrayOn('L_findpw',300);
			document.getElementById("resultPwdName").innerHTML = data[1];
			document.getElementById("resultPwdEmail").innerHTML = data[2];
			sendForm.reset();
		} else {
			alert("일치하는 회원정보가 없습니다.");
//			LayerGrayOn('L_findnot',300);
			sendForm.reset();	
		}
		break;
	default :														//기본적으로는 일치하는 정보가 없다는 메뉴 표시
		alert("일치하는 회원정보가 없습니다.");
//		LayerGrayOn('L_findnot',300);
		sendForm.reset();
	}
}

//비밀번호 찾기 실패시
function resultFindPassError() {
	alert("비밀번호 찾기 조회중 문제가 발생하였습니다. 잠시후 다시 시도해주시기 바랍니다.                                ");
	//LayerGrayOn('L_findnot',300);
}

//비밀번호 찾기 창 닫기
function hidepassFindLayer() {
	document.getElementById("passFindLayer").style.visibility = "hidden";
}


//비밀번호 찾기
function findIMemPass(fmNm) {
	//closeIdPw();
	var sendForm = document.forms[fmNm];

	if (checkEngNumLimit(sendForm, "findID", "[아이디]는", 5))  return;
	if (alertSpace(sendForm, "findName",  "[이름]은" )) return;		
	if (checkNumLen(sendForm, "findSSN1",  "[주민등록번호 앞자리]는",  6)) return;
	if (checkNumLen(sendForm, "findSSN2",  "[주민등록번호 뒷자리]는",  7)) return;
	//if (alertSSN(sendForm.findSSN1, sendForm.findSSN2)) return;

	requestFindPass(sendForm);
}

//비밀번호 찾기
function findIMemPass2(fmNm) {
	closeIdPw();
	var sendForm = document.forms[fmNm];

	if (checkEngNumLimit(sendForm, "findID", "[아이디]는", 5))  return;

	if (alertSpace(sendForm, "findSSN1",  "[주민등록번호 앞자리]는",  6)) return;
	if (checkNumLen(sendForm, "findSSN2",  "[주민등록번호 뒷자리]는",  7)) return;
	//if (alertSSN(sendForm.findSSN1, sendForm.findSSN2)) return;

	//requestFindPass(sendForm);
   sendForm.action = "find_pw_ajax2.asp";
   sendForm.submit();
}


//비밀번호 찾기 엔터키 처리
function enterFindPass(obj) {
  if (event.keyCode =='13') { findIMemPass(obj.form.name); }
}

//비밀번호 찾기 (아이핀1)
function findIMemPassIpin(fmNm) {
	var sendForm = document.forms[fmNm];

	requestFindPassIpin(sendForm);
}
//비밀번호 찾기 요청 (아이핀2)
function requestFindPassIpin(sendForm) {
	var ajaxForm = document.ajaxFm;
	ajaxForm.regFlg.value = encodeURIComponent(sendForm.regFlg.value);
	ajaxForm.joinName.value = encodeURIComponent(sendForm.joinName.value);
	ajaxForm.DupInfo.value = sendForm.DupInfo.value;
	ajaxForm.certifyFlg.value = encodeURIComponent(sendForm.certifyFlg.value);

	var httpObj = new Ajax.Request    (
		'find_pw_ajax.asp',  {
		method:'post',
//    parameters:Form.serialize('ajaxFm'),
    parameters:$("form[name='ajaxFm']").serialize(),
		onSuccess:resultFindPass,
		onFailure:resultFindPassError
		}
	);
}

/*------------------------------------------------비밀번호 찾기 종료----------------------------------------------*/


