if (!path) var path = "";

//check - ÀÔ·Â°ª ¹®ÀÚ¿­°Ë»ç, ÀÚ¸®¼ö°Ë»ç
function Tcheck(target, cmt, astr, lmin, lmax) {
	var i
	var t = trim(target.value);
	if (t.length < lmin || t.length > lmax) {
		if (lmin == lmax) alert(cmt + '´Â ' + lmin + ' ÀÚ¸®¼ýÀÚ ÀÌ¾î¾ß ÇÕ´Ï´Ù');
		else alert(cmt + '´Â ' + lmin + ' ~ ' + lmax + ' ÀÚ¸®¼ö ÀÌ³»·Î ÀÔ·ÂÇÏ¼Å¾ß ÇÕ´Ï´Ù');
		target.focus()
        return true
	}

    if (astr.length > 1) {
		for (i=0; i<t.length; i++)
        if(astr.indexOf(t.substring(i,i+1))<0) {
			alert(cmt + '¿¡ Çã¿ëÇÒ ¼ö ¾ø´Â ¹®ÀÚ°¡ ÀÔ·ÂµÇ¾ú½À´Ï´Ù');
            target.value = "";
            target.focus()
            return true
		}
	}
	target.value = t;
    return false
}


//check - Çã¿ëÇÒ ¼ö ¾ø´Â ¹®ÀÚ¿­ °Ë»ç
function TScheck(target, cmt, astr, lmin, lmax) {
	var i
	var t = trim(target.value);
	if (t.length < lmin || t.length > lmax) {
		if (lmin == lmax) alert(cmt + '´Â ' + lmin + ' ÀÚ¸®¼ýÀÚ ÀÌ¾î¾ß ÇÕ´Ï´Ù');
		else alert(cmt + '´Â ' + lmin + ' ~ ' + lmax + ' ÀÚ¸®¼ö ÀÌ³»·Î ÀÔ·ÂÇÏ¼Å¾ß ÇÕ´Ï´Ù');
		target.focus()
        return true
	}

    if (astr.length > 1) {
		for (i=0; i<t.length; i++)
        if(astr.indexOf(t.substring(i,i+1))>0) {
			alert(cmt + '¿¡ Çã¿ëÇÒ ¼ö ¾ø´Â ¹®ÀÚ°¡ ÀÔ·ÂµÇ¾ú½À´Ï´Ù');
            target.value = "";
			target.focus()
            return true
		}
	}
	target.value = t;
    return false
}


//°ø¹é°Ë»ç
function trim(str) {
	var start, end, i;

	start = 0;
	for(i=0; i<=str.length-1; i++) {
		if(str.substr(i,1) == " ") start++;
		else break;
	}

	end = str.length-1;
	for(i=end; i>=0; i--) {
		if(str.substr(i,1) == " ") end--;
		else break;
	}

	if(end < 0) // " "ÀÏ °æ¿ì¿¡...
		return "";
	else
		return str.substring(start, end+1);
}


//Æû ÀÔ·Â°Ë»ç
function valueChk(obj,msg,f_obj) {
	var objValue = obj.value
	if (!trim(objValue)) {
		alert(msg);
		if (!f_obj) { f_obj = obj; }
		if (f_obj != "none") { f_obj.focus(); }
		return true;
	}
}


//ÁÖ¹Î¹øÈ£check------------------------------------------------------------------------
function juminChk(regnum) {
	var tmp = 0

	var regnum1 = regnum.substring(0,6)
	var regnum2 = regnum.substring(6,13)

	var yy = regnum1.substring(0,2)
	var mm = regnum1.substring(2,4)
    var dd = regnum1.substring(4,6)

	var sex = regnum2.substring(0,1)

	if ((regnum1.length != 6 ) || ( mm < 1 || mm > 16 || dd < 1) ) { return true; }

	if ((sex != 1 && sex !=2 && sex !=3 && sex !=4)|| (regnum2.length != 7 )) { return true; }

	for (var i = 0; i <=5 ; i++)
		tmp = tmp + ((i%8+2) * parseInt(regnum1.substring(i,i+1)))

	for (var i = 6; i <=11 ; i++)
		tmp = tmp + ((i%8+2) * parseInt(regnum2.substring(i-6,i-5)))

	tmp = 11 - (tmp %11)
    tmp = tmp % 10

	if (tmp != regnum2.substring(6,7)) { return true; }

	return false;
}


//eMail Check------------------------------------------------------------------------
function mailChk(in_str) {
   var i;
   var golb_cnt=0;
   var dot_cnt=0;

   for(i=0; i<in_str.length; i++) {
       ch = in_str.charAt(i);
       if(i==0 && ch == '.') return true;
       if(i==in_str.length-1 && ch == '.') return true;

       if(!(ch == '_' ||  ch == '-' || ch == '@' || ch == '.' || ('a' <= ch && ch <= 'z') ||
         ('A' <= ch && ch <= 'Z') || ('0' <= ch && ch <= '9'))) return true;

       if(ch == '@') golb_cnt++;
       if(ch == '.') {
           dot_cnt++;
       }
   }
   strArr1 = in_str.split("@");
   strArr2 = strArr1[1].split(".");

   if (!strArr1[0] || !strArr2[0] || !strArr2[1]) return true;

   if(golb_cnt != 1) return true;
   if(dot_cnt < 1) return true;

	return false;
}


//¿À¸¸¶§¸¸µ¥ ´Ù ¾²ÀÌ´Â ÇÔ¼ö : ¼öÁ¤Æû Select, Checkbox, Radiobox ÀÌÀüÀÔ·Â°ª Ç¥½Ã¸¦ À§ÇÑ ½ºÅ©¸³Æ®
function inputSct(obj,chk_var,act) {
	for(i=0; i < eval(obj+".length"); i++) {
		if (eval(obj+"["+i+"].value") == chk_var) {
			eval(obj+"["+i+"]." + act + " = true");
			break;
		}
	}

	if (!eval(obj+".length")) {
		if (eval(obj+".value") == chk_var) { eval(obj+"." + act + " = true"); }
	}
}


//CookieÁ¦¾îÇÔ¼ö----------------------------------------------------------------------------------
function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
  }
  return null;
}

function SetCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

function DeleteCookie (name,path,domain) {
  if (GetCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "")
  }
}




/*·Î±×¾Æ¿ô½Ã ¸µÅ©Á¦¾î*************************************************************************************************/
function link_chk(obj) {
	var id = GetCookie("ck_user_id");
	if (!id) {
		lnUrl = escape(location.href);
		location.href= path + "../join/join_login.htm?lnUrl=" + lnUrl;
		return false;
	}
	return true;
}


/*·Î±×¾Æ¿ô½Ã ¸µÅ©Á¦¾î*************************************************************************************************/
function logOut() {
	var urlArr = location.href.split("/");

	if (!lnUrl) { var lnUrl = escape(location.href); }
	location.href = path + "../join/login_pro.php3?type=logout&lnUrl=" + lnUrl;
}



/*·Î±×¾Æ¿ô½Ã ¸µÅ©Á¦¾î*************************************************************************************************/
function adult_chk(obj) {
	if (!link_chk(this)) { return false; }

	var chk = GetCookie("ck_user_check");
	if (chk) {
		now = new Date();
		//now_yy = now.getYear(); + 2007-06-14 dodars ³×½ºÄÉÀÌÇÁµµ ÀÎÁõµÇ°Ô

		if (navigator.appName.indexOf('Microsoft') != -1){
			now_yy = now.getYear();
		}else if(navigator.appName.indexOf("Netscape") != -1){
			now_yy = now.getYear() + 1900;
		}else{
			now_yy = now.getYear();
		}

		now_mm = now.getMonth() + 1;
		now_dd = now.getDate();

		var yy	= chk.substring(0,2)
		var mm	= chk.substring(2,4)
		var dd	= chk.substring(4,6)

		yy = 1900 + parseInt(yy);
		age = now_yy - yy;
		
		if (now_mm < mm || (now_mm == mm && now_dd < dd)) { age = age - 1; }

		if (age < 19) {
			alert("¸¸ 19¼¼ÀÌ»ó ¼ºÀÎ¸¸ ÀÌ¿ëÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù");
			return false;
		}
	} else {
		if (obj.href) { lnUrl = obj.href.replace("&","^").replace("&","^"); }
		else { lnUrl = obj.action.replace("&","^").replace("&","^").replace("&","^").replace("&","^"); }

		windowOpen("../join/19_checkID.htm?lnUrl=" + lnUrl,"adultChk",598,320);
		return false;	
	}
	return true;
}




/*ÀÛ°¡¹æÁ¢±Ù½Ã ¸µÅ©Á¦¾î*************************************************************************************************/
function auLink_chk(obj) {
	if (link_chk(this)) {
		var au_id = GetCookie("ck_user_author");
		if (!au_id) {
			windowOpen(path + "../cyAuthor/cyMsg_01.htm","cyMsg",463,130);
		} else {
			location.href = path + "../authorR/auAccess_chk.php3?&au_id=" + au_id;
		}
	}
}


/*ÀÛ°¡µî·Ï ¸µÅ©Á¦¾î***************************************************************************************************/
function auInput_chk(obj) {
	if (!link_chk(this)) { return false; }
	else {
		var au_id = GetCookie("ck_user_author");
		if (au_id) { alert("ÀÌ¹Ì µî·ÏµÈ ÀÛ°¡¹æÀÌ Á¸ÀçÇÕ´Ï´Ù"); return false; }
		else { return true; }
	}
}


function loginChk() {
	if (valueChk("login.id","¾ÆÀÌµð¸¦ ÀÔ·ÂÇÏ¼¼¿ä")) { return false; }
	if (valueChk("login.pass","ÆÐ½º¿öµå¸¦ ÀÔ·ÂÇÏ¼¼¿ä")) { return false; }
}



function questBox(msg,url) {
	ans = confirm(msg);
	if (ans == true) { location.replace(url); }
}



/*È­¸é °¡¿îµ¥ »õÃ¢¿­±â *************************************************************************************************/
function windowOpen(url, name, width, height, option) {
  var str = "height=" + height + ",innerHeight=" + height;
  str += ",width=" + width + ",innerWidth=" + width;
  if (window.screen) {
    var ah = screen.availHeight - 30;
    var aw = screen.availWidth - 10;

    var xc = (aw - width) / 2;
    var yc = (ah - height) / 2;


	if (option == 'exc'){ /*2006-09-16 »õÃ¢¿¡¼­ .... ¸Ó ±×·±°Ô ÀÖ´Ù.*/
		xc = xc + 50;
		yc = yc + 50;
		str += ",left=" + xc + ",screenX=" + xc;
		str += ",top=" + yc + ",screenY=" + yc;		
		str += "," + 'scrollbars=no';
	}else{
		str += ",left=" + xc + ",screenX=" + xc;
		str += ",top=" + yc + ",screenY=" + yc;
		if (option) str += "," + option;
	}
  }
  window.open(url, name, str);
}

/*È­¸é °¡¿îµ¥ ÀÛÀºÃ¢À¸·Î »õÃ¢¿­±â *************************************************************************************************/
function windowOpen2(url, name, width, height, option) {
  var str = "height=" + height;
  str += ",width=" + width;
  if (window.screen) {
    var ah = screen.availHeight - 30;
    var aw = screen.availWidth - 10;

    var xc = (aw - width) / 2;
    var yc = (ah - height) / 2;


	if (option == 'exc'){ /*2006-09-16 »õÃ¢¿¡¼­ .... ¸Ó ±×·±°Ô ÀÖ´Ù.*/
		xc = xc + 50;
		yc = yc + 50;
		str += ",left=" + xc + ",screenX=" + xc;
		str += ",top=" + yc + ",screenY=" + yc;		
		str += "," + 'scrollbars=no';
	}else{
		str += ",left=" + xc + ",screenX=" + xc;
		str += ",top=" + yc + ",screenY=" + yc;
		if (option) str += "," + option;
	}
  }
  window.open(url, name, str);
}




/*»çÀÌ¹öÀÛ°¡ ±Û¾²±â Check *********************************************************************************************/
function cyAuthorWriteChk(mode) {
	if (au_id = GetCookie("ck_user_author")) {
		var board = (GetCookie("ck_user_board")) ? GetCookie("ck_user_board") : "";
		
		if (mode == "nover") {
			if (board.substr(0,1) == 1) location.href = "../authorR/auAccess_chk.php3?action=write&mode=nover&au_id=" + au_id;
			else windowOpen("cyMsg_02.htm","cyMsg",463,130);

		} else if (mode == "essay") {
			if (board.substr(2,1) == 1) location.href = "../authorR/auAccess_chk.php3?action=write&mode=essay&au_id=" + au_id;
			else windowOpen("cyMsg_02.htm","cyMsg",463,130);

		} else if (mode == "photo") {
			if (board.substr(4,1) == 1) location.href = "../authorR/auAccess_chk.php3?action=write&mode=photo&au_id=" + au_id;
			else windowOpen("cyMsg_02.htm","cyMsg",463,130);
		}
	

	} else {
		windowOpen("cyMsg_01.htm","cyMsg",463,130);

	}
}





function DivAlign(theDiv){
var obj,fun,dw,lw,x;
fun = (document.all) ? "document.getElementById" : "MM_findObj";
obj = (document.all) ? document.getElementById(theDiv) : MM_findObj(theDiv);
if(obj){if(document.all){dw = document.body.clientWidth;}
else{dw = innerWidth;}
if(document.layers){lw = obj.clip.width;}
else{lw = obj.style.width.replace("px","");}
x = (document.layers) ? ".left" : ".style.left";
eval(fun+"('"+theDiv+"')"+x+"="+dw+"/2-"+lw+"/2");
}
}

function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}


//2006-04-17 ÇÃ·¡½Ã Ãâ·Â°ü·Ã(¼Ò½ºÀ§Ä¡, °¡·Î, ¼¼·Î, ºÎ°¡);
function flashShow(src, width, height, etc){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="'+width+'" height="'+height+'">');
	document.write('<param name=movie value="'+src+'">');
	document.write('<param name=quality value=high>');
	if(etc) document.write(etc);
	document.write('<param name="FlashVars" VALUE="m=1&s=1">');
	document.write('<param name=wmode value="transparent">');
	document.write('<embed src="'+src+'" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'"></embed>');
	document.write('</object>');
}
/*
' ------------------------------------------------------------------
' Function    : chAction
' ------------------------------------------------------------------
*/
function chAction(id){
	document.write(id.text);
	id.id='';
}