//-- 이미지 원본보기
String.prototype.popupView = function () {
	var img_view = this;
	var x = x + 20 ;
	var y = y + 30 ;
	htmlz = "<html><head><title>이미지크게보기</title><style>body{margin:0;cursor:hand;}</style></head><body scroll=auto onload='width1=document.all.Timage.width;height1=document.all.Timage.height;top.window.resizeTo(width1+30,height1+54);' onclick='top.window.close();'><img src='"+img_view+"'  title='클릭하시면 닫힙니다.' name='Timage' id='Timage'></body></html>"
	imagez = window.open('', "image", "width="+ 100 +", height="+ 100 +", top=0,left=0,scrollbars=auto,resizable=1,toolbar=0,menubar=0,location=0,directories=0,status=1");
	imagez.document.open();
	imagez.document.write(htmlz)
	imagez.document.close();
}

//-- 마이룸 팝업 호출
function myroom(mode){
	if(!mode) mode = 'main';
	window.open('/popup/community/myroom.grm?mode='+mode, '', "width=519,height=483,resizable=0,scrollbars=0");
}

//-- 다른 사람 마이룸 팝업 호출
function userMyroom(cust_id){
	window.open('/popup/community/myroom.grm?mode=userroom&cust_id='+cust_id, '', "width=519,height=483,resizable=0,scrollbars=0");
}

/** 플래시 게임 시작 버튼에서 호출 **/
function autocheck(){
	download();
}

function download(){
	document.menuLinkForm.action = '/pds/download/download.grm';
	document.menuLinkForm.submit();
}

	/** 로그인 상태 및 불량회원 상태 체크 **/
	var registFormUrl = '';

	function check_login(formUrl) {
		registFormUrl = formUrl;
		dwr.loginStatus(checkInfractInfo);
	}

	function checkInfractInfo(result){
		if (result == -1 || result == 0) {
			move2LoginPageComfirm();
		} else {

			dwr.selectInfractInfo(
				function(result) {
					if (result < 0) {
						move2LoginPageComfirm();
					} else if(result == 0) {
						if( registFormUrl != '') location.href= registFormUrl;
						else{
							return 1;
						}
					} else if(result > 0) {
						alert("회원님은 구름 운영정책에 따라 글쓰기 제재가 되었습니다.");
					}
				}
			);

		}
	}

	function popup_check_login(formUrl) {
		registFormUrl = formUrl;
		dwr.loginStatus(checkInfractInfoPopup);
	}

	function checkInfractInfoPopup(result){
		if (result == -1 || result == 0) {
			move2LoginPageComfirmPopup();
		} else {

			dwr.selectInfractInfo(
					function(result) {
						if (result < 0) {
							move2LoginPageComfirmPopup();
						} else if(result == 0) {
							if( registFormUrl != '') location.href= registFormUrl;
							else{
								return 1;
							}
						} else if(result > 0) {
							alert("회원님은 구름 운영정책에 따라 글쓰기 제재가 되었습니다.");
						}
					}
			);

		}
	}

	function move2LoginPageComfirm() {

		try{
			if( !certUrl || certUrl == '' ){

			}
		}catch(e){
			alert( 'certUrl 을 정의해주세요.');
			return;
		}

		if(confirm("로그인 후 이용하실 수 있습니다. 로그인 하시겠습니까?")) {
			var url = encodeURIComponent(document.URL);
			location.href='https://'+ certUrl +'/member/loginInput.gm?backUrl='+url;
		}
	}

	function move2LoginPageComfirmPopup() {

		try{
			if( !certUrl || certUrl == '' ){

			}
		}catch(e){
			alert( 'certUrl 을 정의해주세요.');
			return;
		}

		if(confirm("로그인 후 이용하실 수 있습니다. 로그인 하시겠습니까?")) {
			try{
				var openerUrl = encodeURIComponent(opener.document.URL);
				try{
					opener.location.href='https://'+ certUrl +'/member/loginInput.gm?backUrl='+openerUrl;
				}catch(e){
					window.open('https://'+ certUrl +'/member/loginInput.gm?backUrl='+openerUrl, 'newGuideWindow');
				}
			}catch(e){
				window.close();
				window.open('http://weonline.goorm.com', '_newHomePopup');
			}
		}
	}
	/** 로그인 상태 및 불량회원 상태 체크 **/


	/************* login ******************/
	/*--------------------------------------------------------------------------
	* 사용 예 :
	* <FORM name="form1" onSubmit="return chkForm(this)">
	* input tag에 대한 설명
	* <input
	*	type="text" 	//형식
	*	name="id" 		//이름
	*	hname="아이디" 	//한글 이름
	*	pattern="regId" //어떤 정규식으로 처리할지 선언 (pattern="/^[a-zA-Z]+$/")
	*	required 		//필수 항목에 설정
	*   maxlength=10 	//길이 제한(byte)
	* >
	*-------------------------------------------------------------------------*/

	// 폼객체의 이름을 가져오기. 나중에 에러메세지 등에 사용할 객체 이름을 적을것.
	function FormGetElementName(obj)
	{
		if (obj.getAttribute("hname") != null) {
			return obj.hname;
		} else {
			return obj.name;
		}
	}

	// 패턴하고 비교하여 패턴에 맞지 않는 값일 경우 alert 메세지 띄움.
	function FormCheckPattern(obj,pattern,hname)
	{
		var regNum = /^[0-9]+$/;
		var regPhone =/^[0-9]{2,3}-[0-9]{3,4}-[0-9]{4}$/;
		var regMail =/^[_a-zA-Z0-9-]+@[._a-zA-Z0-9-]+\.[a-zA-Z]+$/;
		var regDomain =/^[.a-zA-Z0-9-]+.[a-zA-Z]+$/;
		var regAlpha =/^[a-zA-Z]+$/;
		var regHost =/^[a-zA-Z-]+$/;
		var regHangul =/[가-힣]/;
		var regHangulEng =/[가-힣a-zA-Z]/;
		var regHangulEngNum =/[가-힣a-zA-Z0-9]/;
		var regHangulOnly =/^[가-힣]*$/;
		var regPasswd = /^[a-zA-Z0-9_-]+$/;
		var regPlainPhone = /^[0-9_-]+$/;
		var regDate =/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/;
		var regEngNum =/[a-zA-Z0-9]/;

		pattern = eval(pattern);

		if(!pattern.test(obj.value)){
			alert("" + hname + " 항목의 형식이 올바르지 않습니다.");
			obj.focus();
			return false;
		}
		return true;
	}

	// 문자열의 길이를 계산.
	function StringLength(str)
	{
	//	return (str.length + (escape(str) + "/%u").match(/%u/g).length-1);
	    var l = 0;
	    for (var i=0; i<str.length; i++)
	    	l += (str.charCodeAt(i) > 128) ? 2 : 1;
	    return l;
	}

	// form 객체의 maxlength를 가져와 길이 비교를 하고 넘어갈 경우 alert 메세지를 띄움.
	function FormGetElementLength(obj,len,hname)
	{
		if(StringLength(obj.value) > len){
			alert("" + hname + " 항목은 " + "최대 " + len + "byte로 입력이 제한되어 있습니다.\n\n(영문숫자1byte,한글2byte로 계산)");
			obj.focus();
			return false;
		}

		return true;
	}

	function FormMinElementLength(obj,len,hname)
	{
		if(StringLength(obj.value) < len){
			alert("" + hname + " 항목은 " + "최소 " + len + "byte 이상입니다.\n\n(영문숫자1byte,한글2byte로 계산)");
			obj.focus();
			return false;
		}

		return true;
	}

	// value가 없을 경우 select, text에 따라 적절한 alert 메세지 띄움
	function FormCheckText(obj, hname)
	{
		if(obj.value.length < 1){
			if (obj.tagName.toUpperCase() == "SELECT")
				alert("" + hname + " 항목을 선택하여 주십시요.");
			else
				alert("" + hname + "를 입력해 주세요.");

			obj.focus();
			return false;
		}
		return true;
	}

	function FormCheckSelect(obj, hname)
	{
		if(obj.value.length < 1){
			alert("" + hname + " 항목을 선택하여 주십시요.");
			obj.focus();
			return false;
		}
		return true;
	}

	function FormCheckCheckbox(form, ele, hname)
	{

		//obj = eval(form.name+'.'+ele.name);
		obj = document.getElementsByName(ele.name);

		//2006-05-02 체크박스가 여러개일경우 추가
		if(obj.length > 1){
			var count = 0;
			for (i = 0; i < obj.length; i++) {
	       		if (obj[i].checked == true ) {
	    			count++;
				}
			}

			if (count == 0 ) {
				alert("" + hname + " 항목을 선택하여 주십시요.");
				return false;
			}
		}
		else{

			alert("" + hname + " 항목을 선택하여 주십시요.");
			obj.focus();
			return false;
		}

		return true;

		/*
		if (!obj.checked){
			alert("" + hname + " 항목을 선택하여 주십시요.");
			obj.focus();
			return false;
		}
		return true;
		*/

	}

	function FormCheckRadio(form, ele, hname)
	{
		obj = eval(form.name+'.'+ele.name);
		for (i=0;i<obj.length;i++) {
			if (obj[i].checked)
				return true;
		}
		alert("" + hname + " 항목을 선택하여 주십시요.");
		obj.focus();
		return false;
	}

	// 실제 Form 객체들의 값들을 체크하는 함수
	function FormValidate(f)
	{
		var i,currEl;

		for(i = 0; i < f.elements.length; i++){
			currEl = f.elements[i];

			//필수 항목을 체크한다.
			if (currEl.getAttribute("required") != null){
				if(currEl.type.toUpperCase() == "TEXT" || currEl.tagName.toUpperCase() == "SELECT" || currEl.tagName.toUpperCase() == "TEXTAREA" ||currEl.type.toUpperCase() == "PASSWORD" || currEl.type.toUpperCase() == "FILE" || currEl.type.toUpperCase() == "HIDDEN"){
					if(!FormCheckText(currEl,FormGetElementName(currEl)))
						return false;
				}
				else if(currEl.type.toUpperCase() == "CHECKBOX"){
					if(!FormCheckCheckbox(f, currEl,FormGetElementName(currEl)))
						return false;
				}
				else if(currEl.type.toUpperCase() == "RADIO"){
					if(!FormCheckRadio(f, currEl,currEl.hname))
						return false;
				}
			}

			// 길이 제한을 체크한다.
			if(currEl.type  != null && (currEl.type.toUpperCase() == "TEXT" || currEl.tagName.toUpperCase() == "TEXTAREA" ||currEl.type.toUpperCase() == "PASSWORD")) {
				if(currEl.getAttribute("maxlength") != null && currEl.value.length > 0){
					if(!FormGetElementLength(currEl,currEl.getAttribute("maxlength"),FormGetElementName(currEl))) {
						return false;
					}
				}

				if(currEl.getAttribute("minlength") != null && currEl.value.length > 0){
					if(!FormMinElementLength(currEl,currEl.getAttribute("minlength"),FormGetElementName(currEl))) {
						return false;
					}
				}
			}

			// 입력 패턴을 체크한다.
			if(currEl.getAttribute("pattern") != null && currEl.value.length > 0){
				if(!FormCheckPattern(currEl,currEl.pattern,FormGetElementName(currEl)))
					return false;
			}
		}

		return true;
	}

	/**
	*	파일 사이즈를 용량 표시와 함께 리턴 한다.
	*/
	function getFileSize(nSize) {
		if (nSize <= 1024)
			return parseInt(nSize) + " byte";
		else if (nSize <= 1024 * 1024)
			return parseInt(nSize / 1024 * 100) / 100 + " Kbyte";
		else if (nSize <= 1024 * 1024 * 1024)
			return parseInt(nSize / (1024 * 1024) * 100) / 100 + " Mbyte";

		return parseInt(nSize / (1024 * 1024 * 1024) * 100) / 100 + " Gbyte";
	}
	// 쿠키관련 모음
	function popup_setcookie( name, value, expiredays )
	{
		var todayDate = new Date();
		todayDate.setDate( todayDate.getDate() + expiredays );
		document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
	}


	function popup_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  login_check()
	{
		var f = document.login_form;

		if(checkFormValue(f) ) {


			saveform();
			f.id.value = f.id.value.toLowerCase();
			document.getElementById("custInfoExtDto.custId").value=f.id.value;
			document.getElementById("custInfoExtDto.pwd").value=f.passwd.value;
			//f.action = CERT_HOME_URL + "/sso/loginRedirect.do?backURL=" + BACK_URL;
			f.submit();
		}

	}

	function checkFormValue(form)
	{
		if(FormValidate(form))
		{
			return true;
		}
		else
		{
			return false;
		}
	}

	//로그인 폼 아이디/비밀번호 표시 사라지기
	function loginform_clearbg(type) {

		var f = document.login_form;

		if (type == "id") {
			f.id.style.background = '#fff';
		}
		else if (type == "pass") {
			f.passwd.style.background = '#fff';
		}
	}


	window.onload = __init;
	function __init() {
		getform();
		setContentsImageResize();
	}

	//-- 게시물 첨부이미지 사이즈 강제 조정
	function setContentsImageResize(){
		var images = document.getElementsByTagName('IMG');
		for( var ig=0 ; ig<images.length ; ig++){
			if( images[ig].src.indexOf('Filedata') > -1 ){
				if( images[ig].width > 550 ) images[ig].width = '550';
			}
		}
	}

	function idSetCookie (name, value, expires) {
		document.cookie = name + "=" + escape (value) + "; domain=.goorm.com; path=/; expires=" + expires.toGMTString();
	}

	function saveform() {
		var expdate = new Date();
		var id = document.getElementById("id").value;

		try {
			if (document.getElementById("save_cnk").checked) {
				expdate.setTime(expdate.getTime() + 1000 * 3600 * 24 * 7); // 7일 ==> 7일동안 보전
			} else {
				expdate.setTime(expdate.getTime() - 1);
			}
			idSetCookie("saveid", id, expdate);
		} catch (e) {

		}
	}
	function getform() {
		try {

			document.getElementById("save_cnk").checked = ((document.getElementById("id").value = getCookie("saveid")) != "");

			if ( document.getElementById("save_cnk").checked ) {
				document.getElementById("id").value = getCookie("saveid");
				loginform_clearbg('id');

			} else {
				document.getElementById("id").value = '';
			}
		} catch (e) {

		}
	}

	function getCookie(Name) {
		var search = Name + "="
		if (document.cookie.length > 0) { // 쿠키가 설정되어 있다면
		    offset = document.cookie.indexOf(search);
			if (offset != -1) { // 쿠키가 존재하면
				offset += search.length
				// set index of beginning of value
				end = document.cookie.indexOf(";", offset)
				// 쿠키 값의 마지막 위치 인덱스 번호 설정
				if (end == -1) end = document.cookie.length

				return unescape(document.cookie.substring(offset, end))
			}
		}
		return "";
	}
	/************* login ******************/

	String.prototype.trim=function(){
		 var str=this.replace(/(\s+$)/g,"");
		 return str;
	}

	 //	링크 클릭시 테두리없애기
	 function autoblur() {
	  if(!document.body){
	   return;
	  }else if(event.srcElement.tagName == "A" && document.body){
	   document.body.focus();
	  }
	 }
	 document.onfocusin = autoblur;

	 /**
	 * Returns the value of the selected radio button in the radio group, null if
	 * none are selected, and false if the button group doesn't exist
	 *
	 * @param {radio Object} or {radio id} el
	 * OR
	 * @param {form Object} or {form id} el
	 * @param {radio group name} radioGroup
	 */
	 function $RF(el, radioGroup) {
		 if($(el).type && $(el).type.toLowerCase() == 'radio') {
			 var radioGroup = $(el).name;
			 var el = $(el).form;
		 } else if ($(el).tagName.toLowerCase() != 'form') {
			 return false;
		 }

		 var checked = $(el).getInputs('radio', radioGroup).find(
				 function(re) {return re.checked;}
		 );
	 	return (checked) ? $F(checked) : null;
	 }


	// 주민번호 체크
	function jumin_check(jumin1, jumin2) {
		var returnMsg = "";

	    jumin1_val = jumin1;
	    jumin2_val = jumin2;
	    jumin_no = jumin1_val + jumin2_val;

	    chk_value = new Array(13);
	    var chk_lastid;
	    var chk_mod;
	    var chk_minus;
	    var chk_last;
	    var chk_id = new String(jumin_no);

	    chk_value[6]  = chk_id.substring(6,7);

	    if ((chk_value[6] != 1) && (chk_value[6] != 2)) {
	        if ((chk_value[6] != 3) && (chk_value[6] != 4)) {
	        returnMsg = "정상적인 주민번호가 아닙니다.";
	        }
	    }

	    chk_lastid = chk_id.substring(12,13);
	    chk_value[0]  = chk_id.substring(0,1)   * 2;
	    chk_value[1]  = chk_id.substring(1,2)   * 3;
	    chk_value[2]  = chk_id.substring(2,3)   * 4;
	    chk_value[3]  = chk_id.substring(3,4)   * 5;
	    chk_value[4]  = chk_id.substring(4,5)   * 6;
	    chk_value[5]  = chk_id.substring(5,6)   * 7;
	    chk_value[6]  = chk_id.substring(6,7)   * 8;
	    chk_value[7]  = chk_id.substring(7,8)   * 9;
	    chk_value[8]  = chk_id.substring(8,9)   * 2;
	    chk_value[9]  = chk_id.substring(9,10)  * 3;
	    chk_value[10] = chk_id.substring(10,11) * 4;
	    chk_value[11] = chk_id.substring(11,12) * 5;

	    chk_value[12] = 0;

	    for (var i=0; i<12; i++)
	        chk_value[12] = chk_value[12] + chk_value[i];

	    chk_mod = chk_value[12] % 11;
	    chk_minus = 11 - chk_mod;
	    chk_last = chk_minus % 10;

	    if (chk_last != chk_lastid) {
	        returnMsg = "주민등록번호가 존재하지 않습니다.";
	    }
		return returnMsg;
	}


	// 외국인등록번호 확인
	function foreignNumber(jumin1, jumin2){

		var returnMsg = "";

		var fgn_reg_no = jumin1 + jumin2;

		if (jumin1 == "" || jumin1 == 0x00 || jumin2 == "" || jumin2 == 0x00 ){
			returnMsg = "외국인등록번호를 입력해 주십시오.";
			return returnMsg;
		} else {
		    if (fgn_reg_no.length != 13) {
		        returnMsg = '외국인등록번호 자리수가 맞지 않습니다.';
		        return returnMsg;
		    }
		    if ((fgn_reg_no.charAt(6) == "5") || (fgn_reg_no.charAt(6) == "6")){
		        birthYear = "19";
		    }else if ((fgn_reg_no.charAt(6) == "7") || (fgn_reg_no.charAt(6) == "8")){
		        birthYear = "20";
		    }else if ((fgn_reg_no.charAt(6) == "9") || (fgn_reg_no.charAt(6) == "0")){
		        birthYear = "18";
		    }else{
		        returnMsg = "등록번호에 오류가 있습니다. 다시 확인하십시오.";
		        return returnMsg;
		    }

		    birthYear += fgn_reg_no.substr(0, 2);
		    birthMonth = fgn_reg_no.substr(2, 2) - 1;
		    birthDate = fgn_reg_no.substr(4, 2);
		    birth = new Date(birthYear, birthMonth, birthDate);

		    if ( birth.getYear() % 100 != fgn_reg_no.substr(0, 2) ||
		         birth.getMonth() != birthMonth ||
		         birth.getDate() != birthDate)
		    {
		        returnMsg = '생년월일에 오류가 있습니다. 다시 확인하십시오.';
		        return returnMsg;
		    }

		    if (fgn_no_chksum(fgn_reg_no) == false)
		    {
		        returnMsg = '외국인등록번호에 오류가 있습니다. 다시 확인하십시오.';
		        return returnMsg;
		    }
		}

		return returnMsg;
	}

	// 외국인 등록번호 유효성 체크
	function fgn_no_chksum(reg_no) {
	    var sum = 0;
	    var odd = 0;

	    buf = new Array(13);
	    for (i = 0; i < 13; i++) buf[i] = parseInt(reg_no.charAt(i));

	    odd = buf[7]*10 + buf[8];

	    if (odd%2 != 0) {
	      return false;
	    }

	    if ((buf[11] != 6)&&(buf[11] != 7)&&(buf[11] != 8)&&(buf[11] != 9)) {
	      return false;
	    }

	    multipliers = [2,3,4,5,6,7,8,9,2,3,4,5];
	    for (i = 0, sum = 0; i < 12; i++) sum += (buf[i] *= multipliers[i]);

	    sum=11-(sum%11);

	    if (sum>=10) sum-=10;

	    sum += 2;

	    if (sum>=10) sum-=10;

	    if ( sum != buf[12]) {
	        return false;
	    }
	    else {
	        return true;
	    }
	}

	// 사업자 등록번호 유효성 체크
	function worknumCheck(strNumb) {
		var returnMsg = '';

	    strNumb = strNumb.replace("-","");
	    if (strNumb.length != 10) {
	        returnMsg = "사업자등록번호가 잘못되었습니다.";
	        return returnMsg;
	    }
	    sumMod = 0;
	    sumMod += parseInt(strNumb.substring(0,1));
	    sumMod += parseInt(strNumb.substring(1,2)) * 3 % 10;
	    sumMod += parseInt(strNumb.substring(2,3)) * 7 % 10;
	    sumMod += parseInt(strNumb.substring(3,4)) * 1 % 10;
	    sumMod += parseInt(strNumb.substring(4,5)) * 3 % 10;
	    sumMod += parseInt(strNumb.substring(5,6)) * 7 % 10;
	    sumMod += parseInt(strNumb.substring(6,7)) * 1 % 10;
	    sumMod += parseInt(strNumb.substring(7,8)) * 3 % 10;
	    sumMod += Math.floor(parseInt(strNumb.substring(8,9)) * 5 / 10);
	    sumMod += parseInt(strNumb.substring(8,9)) * 5 % 10;
	    sumMod += parseInt(strNumb.substring(9,10));
	    if (sumMod % 10 != 0) {
	        returnMsg = "사업자등록번호가 잘못되었습니다.";
	        return returnMsg;
	    }
	    return returnMsg;
	}


	// 주민등록번호를 기반으로 만 나이계산하여 반환
	function calcAge(ssn, curDate){
		var age = 0;

		var birthStr = ssn;
		var birth = new Date();

		if( parseInt(birthStr.substring(6,7)) < 3 ){
			birth.setFullYear(1900 + parseInt(birthStr.substring(0,2)));
		}else{
			birth.setFullYear(2000 + parseInt(birthStr.substring(0,2)));
		}

		birth.setMonth( parseInt(birthStr.substring(2,4))-1 );
		birth.setDate( parseInt(birthStr.substring(4,6)) );


		year = birth.getYear();
		month = birth.getMonth()+1;
		date = birth.getDate();

		age =  (curDate - birth) /1000/24/60/60/365;
		return age;
	}

	// 아이디 유효성 체크
	function useridCheck(id) {
		var count = id.length;
		var userid = id;
		var result = (id.match(/[a-zA-z]{1}[0-9a-zA-Z]+$/)) ? true : false;

		for (var i=0; i<count; i++){
			char_ASCII = userid.charCodeAt(i);

			if(char_ASCII >= 12592){
				 result = false;
				 break;
			}
		}

		return result;
	}

	// 비밀번호 유효성 체크
	function passCheck(pwd) {
		var count = pwd.length;
		var passwd = pwd;
		var result = true;

		for (var i=0; i<count; i++){
			char_ASCII = passwd.charCodeAt(i);

			if(char_ASCII >= 12592){
				 result = false;
				 break;
			}
		}

		return result;
	}

	// 닉네임 유효성 체크
	function nickCheck(nick) {
		var count = nick.length;
		var result = true;

		for (var i=0; i<count; i++){
			char_ASCII = nick.charCodeAt(i);

			if((char_ASCII >= 48 && char_ASCII <= 57) && (count < 2 || count > 20)){
				 result = false;
				 break;
			}else if(((char_ASCII>=65 && char_ASCII<=90) || (char_ASCII>=97 && char_ASCII<=122)) && (count < 2 || count > 20)){
				 result = false;
				 break;
			}else if((nick.char_ASCII >= 12592 || nick.char_ASCII <= 12687) && ( count < 1 || count > 10 )){
				result = false;
				break;
			}
		}
		return result;
	}

	// 이메일 유효성 체크
	function EmailCheck (emailStr) {
		var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
		var emailPat=/^(.+)@(.+)$/;
		var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
		var validChars="\[^\\s" + specialChars + "\]";
		var quotedUser="(\"[^\"]*\")";
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
		var atom=validChars + '+';
		var word="(" + atom + "|" + quotedUser + ")";
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
		var matchArray=emailStr.match(emailPat);

		if (matchArray == null) {
			alert("Email 주소의 형식이 명확하지 않습니다.");
			return false;
		}

		var user   = matchArray[1];
		var domain = matchArray[2];

		if (user.length < 2) {
			alert("이용자 ID는 최소 2문자 이상입니다.");
			return false;
		}

		if (domain.length < 4) {
			alert("Domain 이름은 최소 4문자 이상입니다.");
			return false;
		}

		for (i=0; i<user.length; i++) {

			if (user.charCodeAt(i) > 127) {
				alert("이용자 ID에 유효하지 않은 문자가 있습니다.");
				return false;
		   }
		}

		for (i=0; i<domain.length; i++) {
			if (domain.charCodeAt(i) > 127) {
				alert("Domain 이름에 유효하지 않은 문자가 있습니다.");
				return false;
		   }
		}

		if (user.match(userPat) == null) {
			alert("Email 주소의 형식이 명확하지 않습니다.");
			return false;
		}

		var IPArray = domain.match(ipDomainPat);

		if (IPArray != null) {

			for (var i=1;i<=4;i++) {
				if (IPArray[i] > 255) {
					alert("Domain의 IP가 명확하지 않습니다.");
					return false;
		   		}
			}
			return true;
		}

		var atomPat = new RegExp("^" + atom + "$");
		var domArr  = domain.split(".");
		var len     = domArr.length;

		for (i=0;i<len;i++) {
			if (domArr[i].search(atomPat) == -1) {
				alert("Domain 이름이 정확하지 않습니다.");
				return false;
		   }
		}

		if (domArr[domArr.length-1].length != 2 &&
			domArr[domArr.length-1].search(knownDomsPat) == -1) {
			alert("Email 주소는 알려진 Domain 이름이나, 2문자 이상의 국가Domain(kr,jp,cn..) 이름으로 끝나야 합니다.");
			return false;
		}

		if (len < 2) {
			alert("Domain 형식이 명확하지 않습니다.");
			return false;
		}

		return true;
	}

	// 전화번호체크
	function hp_check(tel1, tel2, tel3, val) {
		tel1_val = tel1.value;
		tel2_val = tel2.value;
		tel3_val = tel3.value;

		switch(val){
			case 1 :
						tel_area_num_array = ["02", "051", "053", "032", "062","042", "052", "031", "033", "043","041", "054", "055", "063", "061","064","0502","0505","0506"];
						break;
			case 2 :
						tel_area_num_array = ["010","011","016","017","018","019"];
						break;
			case 3 :
						tel_area_num_array = ["02", "051", "053", "032", "062","042", "052", "031", "033", "043","041", "054", "055", "063", "061","064","0502","0505","0506","010","011","016","017","018","019"];
						break;
		}

		tel_val = tel1.value + tel2.value + tel3.value;

		var k = 0;
		var i = 0;

	    for (k = 0 ; k <tel1_val.length ; k++ ) {
	        if (isNaN(parseInt(tel1_val.charAt(k)))) {
	            alert("전화번호는 숫자만 입력하셔야 합니다.");
		     	return 0;
		 	}
	    }

	    for (k = 0 ; k <tel2_val.length ; k++ ) {
	        if (isNaN(parseInt(tel2_val.charAt(k)))) {
	            alert("전화번호는 숫자만 입력하셔야 합니다.");
		     	return 0;
		 	}
	    }

	    for (k = 0 ; k <tel3_val.length ; k++ ) {
	        if (isNaN(parseInt(tel3_val.charAt(k)))) {
	            alert("전화번호는 숫자만 입력하셔야 합니다.");
		     	return 0;
		 	}
	    }

	    if (tel1_val == null || tel1_val.length < 2) {
	        alert("전화번호를 정확히 입력해주세요.");
	        return 0;
	    }

		var chk_val = 0;

		for (i=0;i<tel_area_num_array.length;i++) {
			if (tel_area_num_array[i] == tel1_val) {
				chk_val = 1;
			}
		}

		if (chk_val != 1) {
	        alert("전화번호를 유효하지 않습니다.");
	        return 0;
		}

		if(val==1){
			if (tel2_val == null || tel2_val.substring(0, 1) == '0' || tel2_val.length < 3 || tel2_val.length > 4) {
				alert("전화번호를 정확히 입력해주세요.");
				return 0;
			}
		}else{
			if (tel2_val.length < 3 || tel2_val.length > 4) {
				alert("전화번호를 정확히 입력해주세요.");
				return 0;
			}
		}

	    if (tel3_val == null || tel3_val.length != 4) {
	        alert("전화번호를 정확히 입력해주세요.");
	        return 0;
	    }

		return 1;
	}

	//maxlength 만큼 옮기면 다음으로 이동하기....
	function nextFocus(sFormName,sNow,sNext){
		var sForm = 'document.'+ sFormName +'.'
		var oNow = eval(sForm + sNow);
		if (typeof oNow == 'object'){
			if ( oNow.value.length == oNow.maxLength){
				var oNext = eval(sForm + sNext);

				if ((typeof oNext) == 'object')
					oNext.focus();
			}
		}
	}

	//이메일 체크 정규표현식 (true,false 반환)
	function checkEmail(emailValue) {
		 var regEmail = rxEmail =/^[0-9a-zA-Z]([-_\.]?[0-9a-zA-Z])*@[0-9a-zA-Z]([-_\.]?[0-9a-zA-Z])*\.[a-zA-Z]{2,3}$/i;
		 if( !regEmail.test(emailValue) ) return 0;
		 return 1;
	}


	/**
	 * tag 객체의 위치값 및 너비/높이값을 반환한다.
	 * @param {objId} DOM객체 : document.getElementById()
	 * @return {ret} left,top,width,height 를 반환한다.
	 */
	function getBoundsObject(objId){
	    var techbug = new Object();
	    var tag = document.getElementById(objId);

	    if(tag !=null && tag != undefined ){
	        if(tag.getBoundingClientRect){ //IE, FF3
	            var rect = tag.getBoundingClientRect();
	            techbug.left = rect.left + (document.documentElement.scrollLeft || document.body.scrollLeft);
	            techbug.top = rect.top + (document.documentElement.scrollTop || document.body.scrollTop);
	            techbug.width = rect.right - rect.left;
	            techbug.height = rect.bottom - rect.top +1; // +1 = Moz와 맞춤
	        } else  if (document.getBoxObjectFor) { // gecko 엔진 기반 FF3제외
	            var box = document.getBoxObjectFor(tag);
	            techbug.left = box.x;
	            techbug.top = box.y;
	            techbug.width = box.width;
	            techbug.height = box.height;
	        }else {
	            techbug.left = tag.offsetLeft;
	            techbug.top = tag.offsetTop;
	            techbug.width = tag.offsetWidth;
	            techbug.height = tag.offsetHeight  + 3;  // +1 = Moz와 맞춤
	            var parent = tag.offsetParent;
	            if (parent != tag) {
	                while (parent) {
	                    techbug.left += parent.offsetLeft;
	                    techbug.top += parent.offsetTop;
	                    parent = parent.offsetParent;
	                }
	            }
	            // 오페라와 사파리의 'absolute' postion의 경우 body의 offsetTop을 잘못 계산 보정
	            var ua = navigator.userAgent.toLowerCase();
	            if (ua.indexOf('opera') != -1 || ( ua.indexOf('safari') != -1 && getStyle(tag, 'position') == 'absolute' )) {
	                techbug.top -= document.body.offsetTop;
	            }

	        }
	        return techbug;
	    }
	}


	// 지정된 범위의 정수 1개를 랜덤하게 반환하는 함수
	// n1 은 "하한값", n2 는 "상한값"
	function randomRange(n1, n2) {
	  return Math.floor( (Math.random() * (n2 - n1 + 1)) + n1 );
	}

	//-- 게시판 제목 가로크기 재정의를 위한 배열 선언
	var _titleWidthArray = new Array();


	//-- 팝업창 화면 가운데 정렬, Scroll No
	function popWinCenterNoScroll(url, target, intwidth, intheight) {
		var top = 0;
		var left = 0;
		var w_width = intwidth; 	//창 넓이
		var w_height = intheight; 	//창 높이
		if(left == 0){
			var x= screen.width/2 - w_width/2; //화면중앙으로위치
			left = x;
		}
		if(top == 0){
			var y= screen.height/2 - w_height/2;
			top = y;
		}
		window.open(url, target, "top="+top+",left="+left+",width="+intwidth+",height="+intheight+",resizable=0,scrollbars=0");
	}

	//-- 현재일자를 반환한다
	Date.prototype.toYMDString = function(delim) {
		if (delim == undefined) delim = "";
		var year = this.getFullYear().toString();
		var month = this.getMonth() + 1;
		var day = this.getDate();
		month = (month < 10 ? "0" : "") + month;
		day = (day < 10 ? "0" : "") + day;
		return year + delim + month + delim + day;
	}



	//-- 게임소개 탭매뉴 활성화

	// menuOver
	function menuOver() {
		this.src = this.src.replace("off.gif", "on.gif");
	}
	function menuOut() {
		this.src = this.src.replace("on.gif", "off.gif");
	}

	//Tab//

	function initTabMenu(menuElId) {
		var tabMenu = document.getElementById(menuElId).getElementsByTagName("a");
		for(i=0; i<tabMenu.length; i++) {
			thismenu = tabMenu.item(i);
			thismenu.menuContainer = document.getElementById(menuElId) ? document.getElementById(menuElId) : null;
			thismenu.targetEl = document.getElementById(tabMenu.item(i).href.split("#")[1]);
			thismenu.targetEl.style.display = "none";
			thismenu.getElementsByTagName("img").item(0).onmouseover = menuOver;
			thismenu.getElementsByTagName("img").item(0).onmouseout = menuOut;
			thismenu.onclick = tabMenuClick;
		}
		var initmenu = tabMenu.item(0);
		initmenu.targetEl.style.display = "block";
		initmenu.getElementsByTagName("img").item(0).onmouseover();
		initmenu.getElementsByTagName("img").item(0).onmouseover = null;
		initmenu.getElementsByTagName("img").item(0).onmouseout = null;
		initmenu.menuContainer.current = initmenu;
	}

	function tabMenuClick() {
		var currentmenu = this.menuContainer.current;
		if (currentmenu != this) {
			currentmenu.targetEl.style.display = "none";
			currentmenu.getElementsByTagName("img").item(0).onmouseover = menuOver;
			currentmenu.getElementsByTagName("img").item(0).onmouseout = menuOut;
			currentmenu.getElementsByTagName("img").item(0).onmouseout();

			this.targetEl.style.display = "block";
			this.getElementsByTagName("img").item(0).onmouseover = null;
			this.getElementsByTagName("img").item(0).onmouseout = null;
			this.menuContainer.current = this;

	//more check
			var moreChk = document.getElementById(currentmenu.targetEl.id + "_more") ?  document.getElementById(currentmenu.targetEl.id + "_more") : null;
			if (moreChk != null) {
				var currentMoreBtn = document.getElementById(currentmenu.targetEl.id + "_more");
				var thisMoreBtn = document.getElementById(this.targetEl.id + "_more");

				currentMoreBtn.style.display = "none";
				thisMoreBtn.style.display = "block";
			}
		}
		return false;
	}

	function keyboardSecurityCheck() {
		var secuKey = "SECU_KEY";
		var secuKeyCheck = document.getElementById("secuKeyCheck");
		if(secuKeyCheck != undefined) {
			if(secuKeyCheck.checked) {
				popup_setcookie( secuKey, "none", -1 )
			} else {
				popup_setcookie( secuKey, "none", 1 )
			}
		}
		document.location.reload();
	}

	function popDownload(url, attributes){
		if(url == 'neffy'){
			url = "/popup/download/neffyDownloadPop.grm";
		}else{
			url = "/popup/download/ktDownload.grm";
		}
		window.open(url, "_download", attributes);
	}

	// strTarget의 byte길이 구하기 - 자유게시판에 있던 함수 옮김
	function getStringByte(strTarget) {
		var i = 0;
		var intByte = 0;
		for(i=0; i<strTarget.length; i++) {
			strEncode = escape(strTarget.slice(i,(i+1)));

			// 1 : 영어, 숫자
			// 3 : 키보드상의 특수문자
			// 6 : 한글
			if((strEncode.length == 1) || (strEncode.length == 3)) {
				intByte += 1;
			} else {
				intByte += 2;
			}
		}

		return intByte;
	}
	
	// str를 len만큼 자르기 - 자유게시판에 있던 함수 옮김
	function cut(str, len) {
		var l = 0;
		for (var i=0; i<str.length; i++) {
			l += (str.charCodeAt(i) > 128) ? 2 : 1;
			if (l > len) {
				  return str.substring(0,(i-2)); 
			}
		}
		return str;
	}
	
	/**
	 * 필수 항목의 필수 입력 및 공백 특수 문자 사용 체크(godbasic, 2010.01.25)
	 * @param obj : object
	 * @param alt : 항목 명칭
	 * @return
	 */
	function chkMust(obj, alt){
		if($F(obj).trim() == "") {
			alert(alt+"을(를) 입력해주세요." );
			$(obj).value = $(obj).value.replace(/　/gi,"");
			$(obj).focus();
			return false;
		}else if($F(obj).trim().indexOf("　") > -1 ) {
			alert(alt+"에 공백 특수 문자를 사용할 수 없습니다." );
			$(obj).value = $(obj).value.replace(/　/gi,"");
			$(obj).focus();
			return false;
		}else if($F(obj).trim().indexOf("<") > -1 || $F(obj).trim().indexOf(">") > -1) {
			alert(alt+"에 '<' 또는 '>'를 사용할 수 없습니다." );
			$(obj).value = $(obj).value.replace("<","");
			$(obj).focus();
			return false;
		}
		return true;
	}
	