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];}
}
function setPng24(obj) {
    obj.width=obj.height=1;
    obj.className=obj.className.replace(/\bpng24\b/i,'');
    obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');"
    obj.src='';
    return '';
}

function checkCharacter(sID) {
	var AlphaDigit;
	var IDLength;
    var ID;

    ID = sID;
    AlphaDigit = "abcdefghijklmnopqrstuvwxyz0123456789";

	IDLength = ID.length;
	if (IDLength  < 4 || IDLength > 12) {
        return false;
    }

	for (i = 0; i < ID.length; i++) {
		if (AlphaDigit.indexOf( ID.substring(i, i+1)) < 0) {
	        return false;
		}
	}
	return true;
}
function checkAlphabet(sID) {
	var AlphaDigit;
    var ID;

    ID = sID;
    AlphaDigit = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

	for (i = 0; i < ID.length; i++) {
		if (AlphaDigit.indexOf( ID.substring(i, i+1)) < 0) {
	        return false;
		}
	}
	return true;
}
function checkNumber(curNumber) {
	var i;

	for(i = 0; i < curNumber.length; i++)
	{
		if(curNumber.charAt(i) != '0' && curNumber.charAt(i) !='1'
			&& curNumber.charAt(i) != '2' && curNumber.charAt(i) != '3'
			&& curNumber.charAt(i) != '4' && curNumber.charAt(i) != '5'
			&& curNumber.charAt(i) != '6' && curNumber.charAt(i) != '7'
			&& curNumber.charAt(i) != '8' && curNumber.charAt(i) != '9')
		{
			return false;
		}
	}

	return true;
}
function validEmail(email) {
	invalidChars = " /:,;"
	if (email == "") {
		return false
	}
	for (i=0; i<invalidChars.length; i++) {
		badChar = invalidChars.charAt(i)
		if (email.indexOf(badChar,0) > -1) {
			return false
		}
	}
	atPos = email.indexOf("@",1)
	if (atPos == -1) {
		return false
	}
	if (email.indexOf("@",atPos+1) != -1) {
		return false
	}
	periodPos = email.indexOf(".",atPos)
	if (periodPos == -1) {
		return false
	}
	if (periodPos+3 > email.length)	{
		return false
	}
	return true
}

function getCookie(name) {
	var nameOfCookie = name + "=";
	var x = 0;
	while (x <= document.cookie.length) {
		var y = (x + nameOfCookie.length);
		if (document.cookie.substring(x, y) == nameOfCookie) {
			if ((endOfCookie=document.cookie.indexOf(";", y)) == -1)
				endOfCookie = document.cookie.length;
			return unescape(document.cookie.substring( y, endOfCookie ));
		}
		x = document.cookie.indexOf(" ", x) + 1;
		if (x == 0)
			break;
	}
	return "";
}
function setCookie(name, value, expiredays) {
	var todayDate = new Date();
	todayDate.setDate(todayDate.getDate() + expiredays);
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";";
}

function getBrowserLeft(object_id) {
	var strID = object_id;
	var strBody = document.body;
	var strDocu = document.documentElement;
	var strLeft = (strBody.clientWidth - parseInt(strID.style.width.substring(0,3)))/2 + "px";
	return strLeft;
}
function getBrowserTop(object_id) {
	var strID = object_id;
	var strBody = document.body;
	var strDocu = document.documentElement;
	var strTop = "";
	if(navigator.userAgent.indexOf("Firefox") > 0) {
		strTop =  strDocu.scrollTop + (strDocu.clientHeight - parseInt(strID.style.height.substring(0,3)))/2 + "px";
	} else if(navigator.userAgent.indexOf("Chrome") > 0) {
		strTop =  strBody.scrollTop + (strDocu.clientHeight - parseInt(strID.style.height.substring(0,3)))/2 + "px";
	} else {
		strTop = strDocu.scrollTop + (strDocu.clientHeight - parseInt(strID.style.height.substring(0,3)))/2 + "px";
	}
	return strTop;
}

/*
function getWidget(idx, code) {
	// 브라우저에 따른 위치 잡기
	var strID = document.getElementById("popWebWidget");
	var strBody = document.body;
	var strDocu = document.documentElement;
	var strLeft = (strBody.clientWidth - parseInt(strID.style.width.substring(0,3)))/2 + "px";
	var strTop = "";
	if(navigator.userAgent.indexOf("Firefox") > 0) {
		strTop =  strDocu.scrollTop + (strDocu.clientHeight - parseInt(strID.style.height.substring(0,3)))/2;
	} else if(navigator.userAgent.indexOf("Chrome") > 0) {
		strTop =  strBody.scrollTop + (strDocu.clientHeight - parseInt(strID.style.height.substring(0,3)))/2;
	} else {
		strTop = strDocu.scrollTop + (strDocu.clientHeight - parseInt(strID.style.height.substring(0,3)))/2;
	}
	document.getElementById("popWebWidget").style.left = strLeft;
	document.getElementById("popWebWidget").style.top = strTop + "px";
	document.getElementById("popWebWidget").style.display = 'block';
	// 스크립트 삽입
	var strScript = '<script type="text/javascript" src="http://' + location.hostname + '/new/gateway/?idx=' + idx + '"></script>';
	document.getElementById("widget_code").value = strScript;
	document.getElementById("widget_code").select();
	if(navigator.userAgent.indexOf("MSIE") > 0) {
		if(window.clipboardData.setData('Text', document.getElementById('widget_code').value)) {
			alert('코드가 복사되었습니다');
		}
	}
	document.getElementById("widget_body").oncontextmenu = new Function("return false");
	document.getElementById("widget_body").onmousedown = new Function("return false");
	document.getElementById("widget_body").ondragstart = new Function("return false");
	document.getElementById("widget_body").onselectstart = new Function("return false");
	document.getElementById("widget_body").style.filter = 'alpha(opacity=50)';
	document.getElementById("widget_body").style.MozOpacity = 0.5;
	document.getElementById("widget_body").style.opacity = 0.5;
}
function getSourceCopy() {
	document.getElementById('widget_code').select();
	if(navigator.userAgent.indexOf("MSIE") > 0) {
		if(window.clipboardData.setData('Text', document.getElementById('widget_code').value)) {
			alert('코드가 복사되었습니다');
		}
	} else {
		alert('선택된 영역을 복사해서 사용하세요');
	}
}
function goHelp() {
	window.open('/new/community/help.php', 'widget_help', '');
}
function closeWebWidget() {
	document.getElementById("widget_body").onselectstart = null;
	document.getElementById("widget_body").onmousedown = null;
	document.getElementById("widget_body").style.filter = 'alpha(opacity=100)';
	document.getElementById("widget_body").style.MozOpacity = 1;
	document.getElementById("widget_body").style.opacity = 1;
	document.getElementById("widget_code").value = 'block';
	document.getElementById("popWebWidget").style.display = 'none';
}
*/

function patchFlash(file, width, height, vars) {
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="' + width + '" height="' + height + '" align="middle">');
	document.write('<param name="movie" value="' + file + '" />');
	document.write('<param name="menu" value="false" />');
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="allowFullScreen" value="false" />');
	document.write('<param name="wmode" value="opaque">');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="bgcolor" value="#ffffff" />');
	document.write('<param name="flashVars" value="' + vars + '"/>');
	document.write('<embed src="' + file + '" menu="false" wmode="opaque" flashVars="' + vars + '" quality="high" bgcolor="#ffffff" width="' + width + '" height="' + height + '" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}
function patchWidget(id, file, width, height, vars) {
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="' + width + '" height="' + height + '" align="middle" id="daltong_' + id + '">');
	document.write('<param name="movie" value="' + file + '" />');
	document.write('<param name="menu" value="false" />');
	document.write('<param name="allowScriptAccess" value="always" />');
	document.write('<param name="allowFullScreen" value="false" />');
	document.write('<param name="wmode" value="transparent">');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="bgcolor" value="#ffffff" />');
	document.write('<param name="flashVars" value="' + vars + '"/>');
	document.write('<embed src="' + file + '" menu="false" wmode="transparent" flashVars="' + vars + '" quality="high" bgcolor="#ffffff" width="' + width + '" height="' + height + '" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" name="daltong_' + id + '" />');
	document.write('</object>');
}
function patchFlash2(file, width, height, vars) {
	document.write('<objec classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="' + width + '" height="' + height + '" align="middle">');
	document.write('<param name="movie" value="' + file + '" />');
	document.write('<param name="menu" value="false" />');
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="allowFullScreen" value="false" />');
	document.write('<param name="wmode" value="window">');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="bgcolor" value="#ffffff" />');
	document.write('<param name="flashVars" value="' + vars + '"/>');
	document.write('<embed src="' + file + '" menu="false" wmode="window" flashVars="' + vars + '" quality="high" bgcolor="#ffffff" width="' + width + '" height="' + height + '" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}


// Ajax req 얻기
function getXMLHTTPRequest() {
	try
	{
		req = new XMLHttpRequest();
	}
	catch (err1)
	{
		try
		{
			req = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (err2)
		{
			try
			{
				req = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (err3)
			{
				req = false
			}
		}
	}
	return req;
}

// 위젯 도움말
function goHelp() {
	window.open('/new/community/help.php', 'widget_help', '');
}
// 위젯코드 카피
function getSourceCopy() {
	try {
		document.getElementById('widget_code').select();
		if(navigator.userAgent.indexOf("MSIE") > 0 && window.clipboardData.setData('Text', document.getElementById('widget_code').value)) {
			alert('코드가 복사되었습니다');
		} else {
			alert('선택된 영역을 복사해서 사용하세요');
		}
	} catch(ex) {
		setTimeout("getSourceCopy()", 100);
	}
}
// 위젯 코드 얻기 : 로그인 or 위젯 코드
function getWidgetCode(idx, code, login) {
	if(idx == undefined) {
		Dialog.info({url: "widget_pop.php?login=anonymous"}, {windowParameters: {className: "daltong", width:394, height:255}});
		setTimeout("getSourceCopy()", 300);
	} else if(login == '1') {
		Dialog.info({url: "widget_pop.php?idx="+idx+"&code="+code}, {windowParameters: {className: "daltong", width:394, height:255}});
		setTimeout("getSourceCopy()", 300);
	} else {
		Dialog.info({url: "widget_pop.php?idx="+idx+"&code="+code}, {windowParameters: {className: "daltong", width:394, height:375}});
		goFocusLogin();
	}
}

// 네이버 블로그 위젯 담기
function goNaverBlog(idx, code) {
	var strWidth = '384';
	var strHeight = '255';
	var strTop = '200';
	var strLeft = (document.body.clientWidth - parseInt(strWidth))/2 + 'px';
	var url_widget = '/new/widget/widget_naver.php?idx='+idx+'&code='+code;
	window.open(url_widget,'widget_naver','width='+strWidth+',height='+strHeight+',top='+strTop+',left='+strLeft+',scrollbars=no,toolbar=no,statusbar=no');
}

// IE에서 엔터키
function goEnterKey(type) {
	var ieKey = window.event.keyCode;
	if (ieKey == 13) {
		if(type == "login") {
			reqLogin();
		} else if(type == "join") {
			reqJoin();
		} else if(type == "idfind") {
			reqIDFind();
		}
	}
}
// 아이디 포커스
function goFocusLogin() {
	try {
		document.getElementById("userid").focus();
		//윈도우 IE 일 때 엔터키 작동
		if(navigator.userAgent.indexOf("MSIE") > 0) document.onkeyup = function() { goEnterKey('login'); }
		if(navigator.userAgent.indexOf("MSIE 6.0") > 0 || navigator.userAgent.indexOf("MSIE 7.0") > 0) {
			document.getElementById("userid").style.height = "14px";
			document.getElementById("passwd").style.height = "14px";
		}
	} catch(ex) {
		setTimeout("goFocusLogin()", 100);
	}
}
// 아이디찾기 포커스
function goFocusIDFind() {
	try {
		document.getElementById("email").focus();
		//윈도우 IE 일 때 엔터키 작동
		if(navigator.userAgent.indexOf("MSIE") > 0) document.onkeyup = function() { goEnterKey('idfind'); }
		if(navigator.userAgent.indexOf("MSIE 6.0") > 0 || navigator.userAgent.indexOf("MSIE 7.0") > 0) {
			document.getElementById("email").style.height = "14px";
		}
	} catch(ex) {
		setTimeout("goFocusIDFind()", 100);
	}
}
// 회원가입 포커스
function goFocusJoin() {
	try {
		document.getElementById("userid").focus();
		//윈도우 IE 일 때 엔터키 작동
		if(navigator.userAgent.indexOf("MSIE") > 0) document.onkeyup = function() { goEnterKey('join'); }
		if(navigator.userAgent.indexOf("MSIE 6.0") > 0 || navigator.userAgent.indexOf("MSIE 7.0") > 0) {
			document.getElementById("userid").style.height = "14px";
			document.getElementById("passwd").style.height = "14px";
			document.getElementById("passwd0").style.height = "14px";
			document.getElementById("email").style.height = "14px";
			document.getElementById("regkey").style.height = "14px";
		}
	} catch(ex) {
		setTimeout("goFocusJoin()", 100);
	}
}
// 회원 정보 포커스
function goFocusMyInfo() {
	try {
		document.getElementById("passwd").focus();
		if(navigator.userAgent.indexOf("MSIE 6.0") > 0 || navigator.userAgent.indexOf("MSIE 7.0") > 0) {
			document.getElementById("passwd").style.height = "14px";
			document.getElementById("passwd0").style.height = "14px";
			document.getElementById("email").style.height = "14px";
		}
	} catch(ex) {
		setTimeout("goFocusMyInfo()", 100);
	}
}
function checkLoginID() {
	if(document.getElementById('userid').value == '')  document.getElementById('userid').focus();
	else document.getElementById('passwd').focus();
}
// 로그인 창
function goLogin() {
	try {
		Dialog.info({url: "/new/member/login.php"}, {windowParameters: {className: "daltong", width:394, height:251, zIndex:99}});
		goFocusLogin();
	} catch(ex) {
		setTimeout("goLogin()", 100);
	}
}
// 아이디 찾기 창
function goIDFind() {
	try {
		Dialog.info({url: "/new/member/idfind.php"}, {windowParameters: {className: "daltong", width:394, height:197, zIndex:99}});
		goFocusIDFind();
	} catch(ex) {
		setTimeout("goIDFind()", 100);
	}
}
// 회원가입 창
function goJoin() {
	try {
		Dialog.info({url: "/new/member/join.php"}, {windowParameters: {className: "daltong", width:394, height:539, zIndex:99}});
		goFocusJoin();
	} catch(ex) {
		setTimeout("goJoin()", 100);
	}
}
// 회원정보 창
function goMyInfo() {
	try {
		Dialog.info({url: "/new/member/myinfo.php"}, {windowParameters: {className: "daltong", width:394, height:358, zIndex:99}});
		goFocusMyInfo();
	} catch(ex) {
		setTimeout("goMyInfo()", 100);
	}
}

// 로그인
function reqLogin() {
	var request = getXMLHTTPRequest();
	var formid = document.loginform;
	if(formid.userid.value == '') {
		alert('아이디를 입력하세요');
		formid.userid.focus();
		return false;
	}
	if(formid.passwd.value == '') {
		alert('비밀번호를 입력하세요');
		formid.passwd.focus();
		return false;
	}
	var myurl = "/new/member/process.php";
	var url_query = "mode=login&userid=" + formid.userid.value + "&passwd=" + formid.passwd.value;
	request.open("POST", myurl, true);
	request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	request.onreadystatechange = function() {resLogin(request);};
	request.send(url_query);
	return false;
}
// 로그인 결과
function resLogin(request) {
	var formid = document.loginform;
	if(request.readyState == 4 && request.status == 200) {
		var isLogin = request.responseText;
		if(isLogin == 'already') {
			alert('현재 로그인 중입니다');
			Dialog.closeInfo();
		} else if(isLogin == 'no') {
			alert('아이디나 패스워드가 잘못되었습니다');
			formid.passwd.value = '';
			formid.userid.select();
		} else {
			alert('로그인 되었습니다');
			Dialog.closeInfo();
			document.getElementById("topLogin").innerHTML = isLogin;
			try {
				document.getElementById("login").value = '1';
			} catch(ex) {
			}
			if(formid.widgetlogin.value == "1") getWidgetCode();
		}
	}
}
// 로그아웃
function goLogout() {
	var request = getXMLHTTPRequest();
	var myurl = "/new/member/process.php";
	var myRand = new Date().getTime();
	var url_query = myurl + "?mode=logout&rand=" + myRand;
	request.open("GET", url_query, true);
	request.onreadystatechange = function() {resLogout(request);};
	request.send(null);
	return false;
}
// 로그아웃 결과
function resLogout(request) {
	var formid = document.loginform;
	if(request.readyState == 4 && request.status == 200) {
		var isLogout = request.responseText;
		document.getElementById("topLogin").innerHTML = isLogout;
		try {
			document.getElementById("login").value = '';
		} catch(ex) {
		}
	}
}
// 아이디 찾기
function reqIDFind() {
	var request = getXMLHTTPRequest();
	var formid = document.idfindform;
	if(!validEmail(formid.email.value)) {
		alert('이메일을 입력하세요');
		formid.email.focus();
		return false;
	}
	var myurl = "/new/member/process.php";
	var url_query = "mode=idfind&email=" + formid.email.value;
	request.open("POST", myurl, true);
	request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	request.onreadystatechange = function() {resIDFind(request);};
	request.send(url_query);
	return false;
}
// 아이디 찾기 결과
function resIDFind(request) {
	var formid = document.idfindform;
	if(request.readyState == 4 && request.status == 200) {
		var isIDFind = request.responseText;
		if(isIDFind == 'already') {
			alert('현재 로그인 중입니다');
			Dialog.closeInfo();
		} else if(isIDFind == 'noEmail') {
			alert('이메일을 올바르게 입력하세요');
			formid.email.select();
		} else if(isIDFind == 'noMember') {
			alert('가입된 이메일이 없습니다');
			Dialog.closeInfo();
			goJoin();
		} else if(isIDFind == 'okSend') {
			alert('가입하신 이메일로 아이디와 새로운 비밀번호가 발송되었습니다');
			Dialog.closeInfo();
		} else {
			alert('다시 한번 시도해주세요');
		}
	}
}

// 아이디 중복 검사
function checkID() {
	var request = getXMLHTTPRequest();
	var formid = document.joinform;
	if(!checkCharacter(formid.userid.value) || formid.userid.value.length < 4 || formid.userid.value.length > 12) {
		alert('아이디는 4~12자 사이의 영문소문자 숫자를 허용합니다');
		formid.userid.select();
		return;
	}
	var myurl = "/new/member/process.php";
	var myRand = new Date().getTime();
	var modurl = myurl + "?mode=idcheck&userid=" + formid.userid.value + "&rand=" + myRand;
	request.open("GET", modurl, true);
	request.onreadystatechange = function() {resCheckID(request);};
	request.send(null);
	return;
}
// 아이디 중복 결과
function resCheckID(request) {
	var formid = document.joinform;
	if(request.readyState == 4 && request.status == 200) {
		var isWrite = request.responseText;
		if(isWrite == 'noLogin') {
			alert('현재 로그인 중입니다');
		} else if(isWrite == '1') {
			alert('아이디를 사용하실 수 있습니다');
			formid.idcheck.value = '1';
			formid.passwd.focus();
		} else {
			alert('중복된 아이디가 있습니다 다시 입력하세요');
			formid.userid.value = '';
			formid.userid.focus();
		}
	}
}

// 회원 가입
function reqJoin() {
	var formid = document.joinform;
	if(!checkCharacter(formid.userid.value) || formid.userid.value.length < 4 || formid.userid.value.length > 12) {
		alert('아이디는 4~12자 사이의 영문소문자 숫자를 허용합니다');
		formid.userid.focus();
		return false;
	}
	if(formid.idcheck.value == "") {
		alert('아이디 중복체크를 하셔야합니다');
		return false;
	}
	if(!checkCharacter(formid.passwd.value) || formid.passwd.value.length < 6 || formid.passwd.value.length > 12) {
		alert('패스워드는  6~12자 사이의 영문소문자 숫자를 허용합니다');
		formid.passwd.focus();
		return false;
	}
	if(formid.passwd.value != formid.passwd0.value) {
		alert('패스워드의 확인을 위해 같은 패스워드를 입력해야합니다');
		formid.passwd.value = "";
		formid.passwd0.value = "";
		formid.passwd.focus();
		return false;
	}
	if(formid.email.value == "" || !validEmail(formid.email.value)) {
		alert("이메일 주소를 정확하게 입려해야합니다");
		formid.email.focus();
		return false;
	}
	if(formid.regkey.value.length != 6) {
		alert("인증코드를 정확하게 입력해야합니다");
		formid.regkey.focus();
		return false;
	}
	if(!formid.agree.checked) {
		alert("이용약관에 동의하셔야합니다");
		formid.agree.focus();
		return false;
	}
	var request = getXMLHTTPRequest();
	var myurl = "/new/member/process.php";
	var url_query = "mode=join&userid=" + formid.userid.value + "&passwd=" + formid.passwd.value + "&email=" + formid.email.value + "&regkey=" + formid.regkey.value + "&checkkey=" + formid.checkkey.value;
	request.open("POST", myurl, true);
	request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	request.onreadystatechange = function() {resJoin(request);};
	request.send(url_query);
	return false;
}
// 회원 가입 결과
function resJoin(request) {
	var formid = document.joinform;
	if(request.readyState == 4 && request.status == 200) {
		var isJoin = request.responseText;
		if(isJoin == 'isLogin') {
			alert('현재 로그인 중입니다');
		} else if(isJoin == 'noParam') {
			alert('가입하실 정보를 입력하세요');
		} else if(isJoin == 'errorKey') {
			alert('인증키가 잘못되었습니다');
		} else if(isJoin == 'isID') {
			alert('중복된 아이디입니다');
			formid.idcheck.value = '';
			formid.userid.select();
		} else if(isJoin == 'isEmail') {
			alert('가입되어 있는 이메일이 있습니다');
			Dialog.closeInfo();
			goIDFind();
		} else if(isJoin == 'noJoin') {
			alert('다시 시도하여 주세요');
		} else {
			alert('회원가입이 되었습니다');
			Dialog.closeInfo();
			document.getElementById("topLogin").innerHTML = isJoin;
			if(formid.widgetjoin.value == "1") getWidgetCode();
		}
	}
}

// 비밀번호 변경
function checkPasswd() {
	var request = getXMLHTTPRequest();
	var formid = document.myform;
	if(formid.passwd.value == "" || formid.passwd.value != formid.passwd0.value) {
		alert('패스워드의 확인을 위해 같은 패스워드를 입력해야합니다');
		formid.passwd.value = "";
		formid.passwd0.value = "";
		formid.passwd.focus();
		return false;
	}
	var myurl = "/new/member/process.php";
	var url_query = "mode=passwd&passwd=" + formid.passwd.value;
	request.open("POST", myurl, true);
	request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	request.onreadystatechange = function() {resPasswd(request);};
	request.send(url_query);
	return false;
}
function resPasswd(request) {
	var formid = document.myform;
	if(request.readyState == 4 && request.status == 200) {
		var isWrite = request.responseText;
		if(isWrite == 'noLogin') {
			alert('로그인을 하셔야합니다');
		} else if(isWrite == 'noPasswd') {
			alert('비밀번호를 입력하세요');
		} else if(isWrite == '1') {
			alert('비밀번호가 변경되었습니다');
			formid.passwd.value = "";
			formid.passwd0.value = "";
		} else {
			alert('다시 변경하여 주세요');
			formid.passwd.value = "";
			formid.passwd0.value = "";
		}
	}
}
// 이메일 변경
function checkEmail() {
	var request = getXMLHTTPRequest();
	var formid = document.myform;
	if(formid.email.value == "" || !validEmail(formid.email.value)) {
		alert("이메일 주소를 정확하게 입려해야합니다");
		formid.email.focus();
		return false;
	}
	var myurl = "/new/member/process.php";
	var url_query = "mode=email&email=" + formid.email.value;
	request.open("POST", myurl, true);
	request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	request.onreadystatechange = function() {resEmail(request);};
	request.send(url_query);
	return false;
}
function resEmail(request) {
	var formid = document.myform;
	if(request.readyState == 4 && request.status == 200) {
		var isWrite = request.responseText;
		if(isWrite == 'noLogin') {
			alert('로그인을 하셔야합니다');
		} else if(isWrite == 'noEmail') {
			alert('이메일을 바르게 입력하세요');
		} else if(isWrite == '1') {
			alert('변경되었습니다');
		} else {
			alert('다시 변경하여 주세요');
			formid.email.select();
		}
	}
}

// 회원 탈퇴
function goOutJoin() {
	if(confirm("정말 탈퇴 하시겠습니까?\n회원 탈퇴를 하시면 귀하께서 사용하셨던\n아이디와 자료가 모두 삭제됩니다.\n탈퇴후 귀하의 아이디는 타인이 가입하여 사용가능하게 됩니다.")) {
		var request = getXMLHTTPRequest();
		var myurl = "/new/member/process.php";
		var myRand = new Date().getTime();
		var modurl = myurl + "?mode=joinout&rand=" + myRand;
		request.open("GET", modurl, true);
		request.onreadystatechange = function() {resJoinOut(request);};
		request.send(null);
		return;
	}
}
// 회원 탈퇴 처리 결과
function resJoinOut(request) {
	if(request.readyState == 4 && request.status == 200) {
		var isJoinOut = request.responseText;
		if(isJoinOut == 'noLogin') {
			alert('로그인을 하셔야합니다');
		} else if(isJoinOut == 'noJoinOut') {
			alert('다시 시도해주세요');
		} else {
			alert('회원에서 탈퇴되셨습니다');
			Dialog.closeInfo();
			document.getElementById("topLogin").innerHTML = isJoinOut;
		}
	}
}

function goItunes(itunes_url) {
	if(confirm("애플 iTunes가 설치되어있습니까?")) {
		window.open(itunes_url,"iTunes",'');
	}
}
function goTwitter(link_url) {
	var open_url = "http://twitter.com/home?status=" + encodeURI(link_url);
	window.open(open_url,"twitter",'');
}
function goIgoogle(link_url) {
	var open_url = "http://fusion.google.com/add?source=atgs&moduleurl=" + encodeURI(link_url);
	window.open(open_url,"igoogle",'');
}
function goFacebook(link_url) {
	var open_url = "http://www.facebook.com/share.php?u=" + encodeURI(link_url);
	window.open(open_url,"facebook",'');
}

function goDownload(sCode, sType) {
	document.getElementById("widget_down").src = "widget_down.php?code=" + sCode + "&type=" + sType;
}
