function reverse(f){
	var i;

	for(i = 0; i < f.length; i++){
		if(f[i].type == "checkbox"){
			if(f[i].checked){ f[i].checked = false; } else { f[i].checked = true; }
		}
	}
}

function listaction(f, act){
	var i, cnt = 0;

	for(i = 0; i < f.length; i++){
		if(f[i].checked){ cnt++; }
	}

	if(cnt < 1){
		alert("¿øÇÏ´Â Ç×¸ñÀ» ¼±ÅÃÇÏ¼¼¿ä");
	} else {
		if(act == 100){
			if(confirm("ÇÑ¹ø »èÁ¦ÇÑ µ¥ÀÌÅÍ´Â ´Ù½Ã º¹±¸ÇÒ ¼ö ¾ø½À´Ï´Ù.\nÁ¤¸» »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?")){
				f.actkey.value = act;
				f.submit();
			}
		} else {
			f.actkey.value = act;
			f.submit();
		}
	}
}

function imagePreview(src, target, W, H){
	var imgsrc = document.getElementById(src).value;
	if(imgsrc != ""){
		nImg = new Image();
		nImg.src = imgsrc;
		if(nImg.width != W || nImg.height != H){
			alert("¼±ÅÃÇÏ½Å ÀÌ¹ÌÁö : " + nImg.width + "*" + nImg.height + "\nÈ¨ÆäÀÌÁö ÀÌ¹ÌÁö´Â " + W + "*" + H + " ÀÌ¾î¾ß ÇÕ´Ï´Ù.");
		} else {
			document.getElementById(target).innerHTML = "<img src='" + nImg.src + "' border='0' width='" + W + "' height='" + H + "'>";
		}
	} else {
		document.getElementById(target).innerHTML = "<table border='0' width='100%' height='100%'><tr><td align='center' style='color:#aaaaaa; font-weight:bold;'>No Image</td></tr></table>";
	}
}

function SiteRedirect(sid){
	var URL = "/dirsearch/goto.php?sid=" + sid;
	window.open(URL);
}

function SearchWord(word){
	if(word != ""){
		document.sform.query.value = word;
		document.sform.submit();
	}
}

function cc(field, type) {
	if (field.value == field.defaultValue && type)
	field.value = '';
	field.className='consult_input';
}

function cb(field, type) {
	if (!field.value && type) field.value = field.defaultValue;
	field.className='consult_input';
	if(type==2&&field.value=='') 	field.className = "pwd1";
	if(type==1&&field.value=='') 	field.className = "id1";
}

function showhide(id) {
	var item = eval("document.all.site"+id);
	var msg = eval("document.all.txt"+id);
	if(item.style.display=="none") {
		item.style.display="inline";
		msg.innerHTML = "close"
	}else if(item.style.display=="inline") {
		item.style.display="none";
		msg.innerHTML = "open"
	}
}

function flipflop(f) {
	var control = eval(f);
	if(control.style.display=="none") {
		control.style.display="inline";
	}else if(control.style.display=="inline") {
		control.style.display="none";
	}
}

function openWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function openCenter(nfile, id) {

   var height = screen.height;
   var width = screen.width;
   var leftpos = width / 2 - 200;
   var toppos = height / 2 - 150;

    openWindow(nfile + '.php?id='+id,'window_Recharge','width=400,height=300,left='+leftpos+',top='+toppos+',scrollbars=0');

}

function naver_string_cut(text,cnt)
{
	var text2 = "";
	cnts = text.length;
	for(i=1;i<=cnt;i++)
	{
		text2 = text.substring( 0, cnt );
	}
	if(cnt<cnts)text2 += "...";
	return text2;
}
function updateChar(length_limit, seq)
{
	var comment='';
	comment = eval("document.joinForm.fm"+seq);
	var form = document.joinForm;
	var length = calculate_msglen(comment.value);
	document.getElementById("textlimit"+seq).innerHTML = length;
	if (length > length_limit) {
		alert("±â·Ï °¡´ÉÇÑ " + length_limit + "¹ÙÀÌÆ®¸¦ ÃÊ°úÇÏ¿´½À´Ï´Ù.\nÃÊ°úµÈ ³»¿ëÀº »èÁ¦µË´Ï´Ù.");
		comment.value = comment.value.replace(/\r\n$/, "");
		comment.value = assert_msglen(comment.value, length_limit, "textlimit"+seq);
	}
}
function updateCharComment(length_limit, text_obj, info_obj) {
	var comment='';
	comment = document.getElementById(text_obj);
	var form = document.bbsForm;
	var length = calculate_msglen(comment.value);
	document.getElementById(info_obj).innerHTML = length;
	if (length > length_limit) {
		alert("±â·Ï °¡´ÉÇÑ " + length_limit + "¹ÙÀÌÆ®¸¦ ÃÊ°úÇÏ¿´½À´Ï´Ù.");
		comment.value = comment.value.replace(/\r\n$/, "");
		comment.value = assert_msglen(comment.value, length_limit, info_obj);
	}
}
function calculate_msglen(message)
{
	var nbytes = 0;

	for (i=0; i<message.length; i++) {
		var ch = message.charAt(i);
		if(escape(ch).length > 4) {
			nbytes += 2;
		} else if (ch == '\n') {
			if (message.charAt(i-1) != '\r') {
				nbytes += 1;
			}
		} else if (ch == '<' || ch == '>') {
			nbytes += 4;
		} else {
			nbytes += 1;
		}
	}

	return nbytes;
}
function assert_msglen(message, maximum, textlimit)
{
	var inc = 0;
	var nbytes = 0;
	var msg = "";
	var msglen = message.length;

	for (i=0; i<msglen; i++) {
		var ch = message.charAt(i);
		if (escape(ch).length > 4) {
			inc = 2;
		} else if (ch == '\n') {
			if (message.charAt(i-1) != '\r') {
				inc = 1;
			}
		} else if (ch == '<' || ch == '>') {
			inc = 4;
		} else {
			inc = 1;
		}
		if ((nbytes + inc) > maximum) {
			break;
		}
		nbytes += inc;
		msg += ch;
	}
	document.getElementById(textlimit).innerHTML = nbytes;
	return msg;
}