
function find_typeLayer(is_check){

	switch(is_check){
		case '1':
			allHidden();
			document.getElementById("name_view").style.display = '';
			document.getElementById("ssn_view").style.display = '';
		break;

		case '2':
			allHidden();
			document.getElementById("name_view").style.display = '';
			document.getElementById("email_view").style.display = '';
		break;

		case '3':
			allHidden();
			document.getElementById("ipin_view").style.display = '';
		break;
	}
}

function allHidden(){
	if(document.getElementById('name_view') != null){
		document.getElementById("name_view").style.display = 'none';
	}
	if(document.getElementById('ssn_view') != null){
		document.getElementById("ssn_view").style.display = 'none';
	}
	if(document.getElementById('email_view') != null){
		document.getElementById("email_view").style.display = 'none';
	}
	if(document.getElementById('ipin_view') != null){
		document.getElementById("ipin_view").style.display = 'none';
	}
}


function fnIpinPopup(){
	var f3 = document.frmIpin;
	// È¸¿ø±¸ºÐ
	f3.ipin_param1.value='lost_id';

	window.name ="ipin_parent_window";
    window.open('', 'popupIpin','width=448, height=500');
    f3.target = "popupIpin";
    f3.action = "http://i-pin.cafe24.com/ipin/?cont=callIpinPopup&cpKey=I0001";
    f3.submit();
}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function check_submit(){
	var f = document.frm;
	var is_check = getCheckedValue(f.is_check);
	if(is_check == '1'){

		if(f.name.value == ''){
			alert('ÀÌ¸§À» ÀÔ·ÂÇÏ¼¼¿ä');
			f.name.focus();
			return false;
		}

		if(typeof(f.ssn) != "undefined"){
			if(f.ssn.value == ''){
				alert('ÁÖ¹Îµî·Ï¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä.');
				f.ssn.focus();
				return false;
			}
		}

	}else if(is_check == '2'){
		if(f.name.value == ''){
			alert('ÀÌ¸§À» ÀÔ·ÂÇÏ¼¼¿ä');
			f.name.focus();
			return false;
		}

		if(f.email.value == ''){
			alert('ÀÌ¸ÞÀÏÀ» ÀÔ·ÂÇÏ¼¼¿ä.');
			f.email.focus();
			return false;
		}
	}else if(is_check == '3'){
		fnIpinPopup();
		return false;
	}

    setPersonInfo(f);
    encryptSubmit() ;
    return false;
}

/**
 *  °³ÀÎÁ¤º¸ ¾ÏÈ£È­¸¦ À§ÇØ 
 *  hidden À¸·Î »ý¼ºÇØ ÁØ´Ù.
 */
function setPersonInfo(f)
{
    var iSsn = document.getElementsByName('ssn')[0].value;
    var iSsn1 = iSsn.substr(0, 6);
    var iSsn2 = iSsn.substr(6, 13);
    var oSsnInput1 = document.createElement("input");
    oSsnInput1.name = "ssn1";
    oSsnInput1.id = "ssn1";
    oSsnInput1.type = "hidden";
    oSsnInput1.value = iSsn1;
    f.appendChild(oSsnInput1);
    var oSsnInput2 = document.createElement("input");
    oSsnInput2.name = "ssn2";
    oSsnInput2.id = "ssn2";
    oSsnInput2.type = "hidden";
    oSsnInput2.value = iSsn2;
    f.appendChild(oSsnInput2);
}
/**
 * ¾ÏÈ£È­ ¿äÃ»¹æ¹ý
 */
function encryptSubmit() 
{
	AuthSSLManager.weave({
		// encrypt / decrypt
		'auth_mode': 'encrypt'
		// ¿¤¸®¸ÕÆ® ¾ÆÀÌµð È¤Àº ¶óµð¿À¹Ú½º´Â name
		, 'aEleId': ['member_id', 'name', 'ssn1', 'ssn2', 'is_check', 'email']
		// callback function-name
		, 'auth_callbackName': 'encryptSubmit_Complete'
	});
}
/**
 * callback
 * @param String output
 */
function encryptSubmit_Complete(output) {
    var oForm = document.createElement("form");    
    document.body.appendChild(oForm);
    var oBjencode_str = document.createElement("input");
    oBjencode_str.name = "encode_str";
    oBjencode_str.id = "encode_str";
    oBjencode_str.type = "hidden";
    oForm.appendChild(oBjencode_str);

	if( AuthSSLManager.isError(output) == true ) {
		alert("°³ÀÎÁ¤º¸ ¾ÏÈ£È­ ½ÇÆÐ. °ü¸®ÀÚ¿¡°Ô ¹®ÀÇÇØ ÁÖ¼¼¿ä.");
		return false;
	}
	document.getElementById('encode_str').value = output;
    oForm.method = "post";
    oForm.action = "/front/php/lost_pw/lost_pw_a.php";
    oForm.submit();
}

/**
 *  ¾ÆÀÌµð/ºñ¹Ð¹øÈ£ Ã£±â form ¼³Á¤
 *  2010-06-18 jykim
 */
var _iCntTrySubmitEvt = 0;
function initOnSubmitEvt(sActionUrl)
{
    try {
        document.getElementsByName('ssn1')[0].id = "ssn1";
        document.getElementsByName('ssn2')[0].id = "ssn2";
        document.getElementsByName('member_id')[0].id = "member_id";
        document.getElementsByName('name')[0].id = "name";
        document.getElementsByName('email')[0].id = "email";
        document.getElementsByName('is_check')[0].id = "is_check";

        oForm = getTargetForm(sActionUrl);
        oForm.onsubmit = function () {
            encryptSubmit();
            return false;
        }
    } catch (e) {
        if (_iCntTrySubmitEvt < 100) {
            setTimeout('initOnSubmitEvt("/front/php/lost_pw/lost_pw_a.php")', 500);
        }
        _iCntTrySubmitEvt++;
    }
}

initOnSubmitEvt("/front/php/lost_pw/lost_pw_a.php");

