//회원모듈 자바스크립트

/**
 * 로그인폼 전송
 */
function loginExec(){
    obj = document.loginF;
    if(!check_blank('아이디',obj.id)) return false;
    if(!check_length('아이디',obj.id,2,12)) return false;
    if(!check_blank('비밀번호',obj.passwd)) return false;
    if(!check_null('비밀번호',obj.passwd)) return false;
    if(!check_length('비밀번호',obj.passwd,4,12)) return false;
	if(ie==true){
		postForm(obj,'iezn_member::Login::loginExec',0,0,'로그인중입니다');
	}else{
		postForm(obj,'iezn_member::Login::loginExec',0,1);
	}
	return false;
}

/**
 * 로그아웃
 */
function logoutExec(){
	if(document.loginF){
		postForm(document.loginF,'iezn_member::Login::logoutExec');
	}else{
		postXml(Array(''),Array(''),'iezn_member::Login::logoutExec');
	}
	return false;
}

/**
 * 자동로그인 체크부분
 */
function checkAutoLogin(){
    if(document.loginF.saveLogin.checked==true){
        if(confirm('자동 로그인을 사용하시겠습니까?\n\n자동로그인 기능 사용시 다음접속부터 로그인하실 필요가 없습니다.\n\n개인용 컴퓨터가 아닌 사용자(게임방,학교,회사)의 경우는 개인정보가 유출될 수 있습니다.')){
            document.loginF.saveLogin.checked=true;
            document.loginF.auto_login.value=1;
        }else{
            document.loginF.saveLogin.checked=false;
            document.loginF.auto_login.value='';
        }
    }
}

/**
 * 사용자 메뉴 
 */
var userMenuShowVar = 0;
document.write("<div id=\"userMenuDiv\" style='position:absolute;display:none;height:auto;padding:0px;width:auto;background:transparent'></div>");
function userMenuShow(e,m_id){
	if(userMenuShowVar==1){
		userMenuHide();
	}
	if(typeof(g_num)=='undefined') g_num='';
	if(typeof(gs_num)=='undefined') gs_num='';
	if(typeof(num)=='undefined') num='';
	if(typeof(now)=='undefined') now='';
	xmlVal = postXml(Array('idx','g_num','gs_num','num','m_id','now'),Array(idx,g_num,gs_num,num,m_id,now),'iezn_member::UserMenu::userMenuShow',1);
	
	if(xmlVal['script']){
		eval(xmlVal['script']);//스크립트 출력
	}else if(xmlVal['html']){
		obj = document.getElementById('userMenuDiv');
		obj.style.zIndex = 100;
		obj.style.display = 'inline';
		obj.style.overflow = 'visible';
		obj.innerHTML = xmlVal['html'];
		if (ie) {obj.style.pixelLeft=mouseX-40; obj.style.pixelTop=mouseY+10;}
		else if (ns) {obj.style.left=mouseX+"px"; obj.style.top=mouseY+"px";}
		userMenuShowVar = 1;

	}else{
		if(xmlVal['message']){alert(xmlVal['message']);}
	}
}


//사용자메뉴 숨기기
function userMenuHide()
{
   if(userMenuShowVar == 1)
   {
      obj = document.getElementById('userMenuDiv');
      obj.style.display = 'none';
      obj.style.overflow = 'hidden';
	  obj.innerHTML = '';
      userMenuShowVar = 0;
   }
}



//비밀번호 분실 페이지로 이동
function goto_lost_passwd(){
    location.href=http_app_path+'/?idx='+idx+'&g_num='+g_num+'&gs_num='+gs_num+'&now=lost_passwd';
}

// 회원가입페이지로 이동
function goto_provision(){
    location.href=http_app_path+'/?idx='+idx+'&g_num='+g_num+'&gs_num='+gs_num+'&now=provision';
}

// 회원가입페이지로 이동
function goto_friend(){
    location.href=http_app_path+'/?idx='+idx+'&g_num='+g_num+'&gs_num='+gs_num+'&now=friendship';
}

function goto_id_confirm(){
    location.href=http_app_path+'/?idx='+idx+'&g_num='+g_num+'&gs_num='+gs_num+'&now=id_confirm';
}

function goto_admin(){
	window.open(http_app_path+'/modules/iezn/admin/index.php');
}

//add Friend
function addFriend(m_id){
	if(getCookie('ld')!=1){
		alert('로그인 해주시기 바랍니다');
	}else{
		if(typeof(m_id)=='undefined'){
			alert('회원정보가 존재하지 않습니다');
		}else{
			xmlVal=postXml(Array('m_id'),Array(m_id),'iezn_member::AddFriend::addFriendExec',1);
			if(xmlVal['code']==1){//참인경우
				alert(xmlVal['message']);
			}else if(xmlVal['code']==0){//거짓인경우
				alert(xmlVal['message']);
			}
		}
	}
}

//중복체크
function uniqueCheck(obj,name,m_id){
    if(!check_null(name,obj)) return false;
	postXml(Array('check_value','e_name','h_name','m_id'),Array(obj.value,obj.name,name,m_id),'iezn_member::UniqueCheck::uniqueCheckExec');
}


//중복체크
function existCheck(obj,name){
    if(!check_null(name,obj)) return false;
	postXml(Array('check_value','e_name','h_name'),Array(obj.value,obj.name,name),'iezn_member::UniqueCheck::uniqueCheckExec');
}


//폼메일보내기
function formmailWrite(m_nick,m_email){
   value = '';
   if(m_email) value += m_emial;
   value = m_nick + ',' + m_email;
   if(ie == true){//익스인경우 모달창으로 처리
      showModalDialog(http_app_path+"/modules/iezn_member/formmail_write.php?value=" + value, '', "dialogWidth:438px; dialogHeight:488px;status:no;unadorned:yes;scroll:no;resizable:no;edge;sunken");
   }else{
      open_window(http_app_path+"/modules/iezn_member/formmail_write.php?value=" + value, 'formmail', 438, 488, 'no');
   }
}

//캐쉬삭제
function cacheEmpty(g_num){
	g_num.toString();
	postXml(Array('g_num'),Array(g_num),'iezn::CacheEmpty::cacheEmptyExec');
}



function idConfirm(){
	var obj = document.idConfirmF;
	if(!check_blank('이름',obj.name)) return false;
	if(!check_length('이름',obj.name,2,12)) return false;
	if(!check_null('이메일',obj.email)) return false;
	if(!check_blank('이메일',obj.email)) return false;
	if(!check_email('이메일',obj.email)) return false;
	postForm(obj,'iezn_member::IdConfirm::idConfirmExec');
	return false;
}

//이메일인증코드전송
function emailAuthSend(obj,name,email_f,btn,ck){
	
    if(!check_null(name,email_f)) return false;
	if(!check_email(name,email_f)) return false;	
	//중복체크 이메일에 대한 전송인경우 중복체크를 하도록 한다
	if(ck=='unique'){
		if(getCookie("unique["+obj.name+"]")==null){
			alert('중복체크를 해주세요');
			return false;
		}
	}else if(ck=='exist'){
		if(getCookie("exist["+obj.name+"]")==null){
			alert('존재체크를 해주세요');
			return false;
		}
	}
	postXml(Array('email','input_field'),Array(obj.value,obj.name,name),'iezn_member::MemberJoin::emailAuthCodeSend');
}







//우편번호 관련
function zipSearchCall(e,n){
	xmlVal = postXml(Array('fname'),Array(n),'iezn_member::ZipSearch::zipSearchExec',1);
	if(xmlVal['code']==0){
		alert(xmlVal['message']);
	}else{
		obj = document.getElementById('zipSearchDiv');
		obj.style.overflow = 'visible';
		obj.style.left = (ns)? e.pageX : event.x+document.body.scrollLeft
		obj.style.top = (ns)? e.pageY : event.y+document.body.scrollTop + 10;
		obj.style.display = 'inline';
		obj.innerHTML = xmlVal['html'];
		document.zipSearchF.keyword.focus();
	}
}

//우편번호 관련
function zipSearchExec(n){
	obj = document.zipSearchF;
	xmlVal = postForm(obj,'iezn_member::ZipSearch::zipSearchExec',1);
	if(xmlVal['code']==0){
		alert(xmlVal['message']);
		obj.keyword.focus();
	}else{
		document.getElementById('zipSearchDiv').innerHTML = xmlVal['html'];
		if(document.zipSearchF.num){
			document.zipSearchF.num.focus();
		}else{
			document.zipSearchF.bunji.focus();
		}
	}
	return false;
}

function zipSearchEnd(fname){
	if(document.zipSearchF.bunji.value.length<1){
		alert('나머지 주소를 입력해 주세요');
		document.zipSearchF.bunji.focus();
		return false;
	}

	document.getElementById(fname+'_zip1').value = document.zipSearchF.zip_1.value;
	document.getElementById(fname+'_zip2').value = document.zipSearchF.zip_2.value;
	document.getElementById(fname+'_sido').value = document.zipSearchF.sido.value;
	document.getElementById(fname+'_gugun').value = document.zipSearchF.gugun.value;
	document.getElementById(fname+'_dong').value = document.zipSearchF.dong.value;
	document.getElementById(fname+'_bunji').value = document.zipSearchF.bunji.value;
	document.getElementById(fname+'_address').value = document.zipSearchF.sido.value + " " + document.zipSearchF.gugun.value + " " + document.zipSearchF.dong.value + " "+ document.zipSearchF.bunji.value;
	document.getElementById('zipSearchDiv').innerHTML = '';
	document.getElementById('zipSearchDiv').style.border = 'none';
	document.getElementById('zipSearchDiv').style.display = 'none';
	//document.getElementById('zipSearchDiv').style.visibility = 'hide';
}

function zipSearchUSA(fname){
	if(document.zipSearchF.address1.value.length<1){
		alert('나머지 주소를 입력해 주세요');
		document.zipSearchF.address1.focus();
		return false;
	}
	document.getElementById(fname+'_zip1').value = document.zipSearchF.address1.value;
	document.getElementById(fname+'_zip2').value = document.zipSearchF.address2.value;
	document.getElementById(fname+'_sido').value = document.zipSearchF.city.value;
	document.getElementById(fname+'_gugun').value = document.zipSearchF.state.value;
	document.getElementById(fname+'_dong').value = document.zipSearchF.zipcode.value;
	document.getElementById(fname+'_bunji').value = document.zipSearchF.etc.value;
	document.getElementById(fname+'_address').value = document.zipSearchF.address1.value + " " + document.zipSearchF.address2.value + " " + document.zipSearchF.city.value + " "+ document.zipSearchF.state.value + " "+ document.zipSearchF.zipcode.value;
	document.getElementById('zipSearchDiv').innerHTML = '';
	document.getElementById('zipSearchDiv').style.border = 'none';
	document.getElementById('zipSearchDiv').style.display = 'none';
	//document.getElementById('zipSearchDiv').style.visibility = 'hide';
}

function zipSearchHide(){
	document.getElementById('zipSearchDiv').innerHTML = '';
	document.getElementById('zipSearchDiv').style.border = 'none';
	document.getElementById('zipSearchDiv').style.display = 'none';
	//document.getElementById('zipSearchDiv').style.visibility = 'hide';
}


function iconDeleteExec(key){
	if(confirm('삭제하시겠습니까?')){
		key = key.toString();
		postXml(Array('key'),Array(key),'iezn_member::Icon::iconDeleteExec');
	}
}

function emoDeleteExec(key){
	if(confirm('삭제하시겠습니까?')){
		key = key.toString();
		postXml(Array('key','now'),Array(key,'emo'),'iezn_member::Icon::iconDeleteExec');
	}
}


function setMyPhotoExec(key){
	key = key.toString();
	postXml(Array('key'),Array(key),'iezn_member::Icon::setMyPhotoExec');
}


function setMyBlogExec(key){
	key = key.toString();
	postXml(Array('key'),Array(key),'iezn_member::Icon::setMyBlogExec');
}

function setMyBlogBannerExec(key){
	key = key.toString();
	postXml(Array('key'),Array(key),'iezn_member::Icon::setMyBlogbannerExec');
}

function setMyEmoExec(key){
	key = key.toString();
	postXml(Array('key'),Array(key),'iezn_member::Icon::setMyEmoExec');
}



//비밀번호 인증코드 발송
function lostPasswd(){
	var obj = document.lostPasswdF;
	if(!check_null('이메일',obj.email)) return false;
	if(!check_email('이메일',obj.email)) return false;
	postXml(Array('email'),Array(obj.email.value),'iezn_member::LostPasswd::sendAuthCode',1);
	if(xmlVal['code']==1){
		alert(xmlVal['message']);
		obj.email_submit.disabled=true;
		obj.email.disabled=true;
		obj.auth_code.disabled=false;
		obj.auth_code_submit.disabled=false;	
		obj.auth_code.style.backgroundColor='#ffffff';
		obj.auth_code.focus();
	}else{
		alert(xmlVal['message']);
		obj.email.value='';
		obj.email.focus();
	}
}

//인증코드 전송및 비밀번호 재설정
function lostPasswdAuthCodeCheck(){
	var obj = document.lostPasswdF;
	if(!check_null('인증코드',obj.auth_code)) return false;
	postForm(obj,'iezn_member::LostPasswd::lostPasswdCheck');
	return false;
}

function unregisterExec(){		
	obj = document.unregisterF;
	if(!check_null('아이디', obj.id)) return false;
	if(!check_length('아이디',obj.id,2,12)) return false;
	if(!check_null('비밀번호', obj.passwd)) return false;
	if(!check_length('비밀번호',obj.passwd,2,12)) return false;		
	postForm(obj,'iezn_member::Unregister::unregisterExec',0,1,'<P align="CENTER"><b>회원정보 삭제중입니다</b></p>');
}



