﻿// ?u u?
function checkPost(frm, kind) {
	if (kind == "2") {
		if (!frm.name.value) {
			window.alert("Input Your Name.");
			frm.name.focus();
			return false;
		} else if (!frm.pass.value) {
			window.alert("Input Your Password.");
			frm.pass.focus();
			return false;
		}
	}

	try {
		if (frm.cate.options[frm.cate.selectedIndex].value.length == 0) {
			window.alert("Select Category.");
			return false;
		}
	} catch(e) {
	}

	if (!frm.title.value) {
		window.alert("Input Subject.");
		frm.title.focus();
		return false;
	} else if (!frm.body.value) {
		window.alert("Input Content.");
		frm.body.focus();
		return false;
	}

	return true;
}

// ?? u?
function checkMemo(frm, kind) {
	if (kind == "2") {
		if (!frm.name.value) {
			window.alert("Input Your Name.");
			frm.name.focus();
			return false;
		} else if (!frm.pass.value) {
			window.alert("Input Your Password.");
			frm.pass.focus();
			return false;
		}
	}
	if (!frm.body.value) {
		window.alert("Input Content.");
		frm.body.focus();
		return false;
	}

	return true;
}

// ?
function sendMail(omail) {
	var cmail = "";

	for(i = omail.length; i >= 0; i--) {
		var cmail = cmail + omail.substr(i, 1);
	}
	window.location = "mailto:" + unescape(cmail);
}

// ? u?
function checkSearchForm(frm) {
	if (!frm.q.value) {
		window.alert("Input Keyword.");
		frm.q.focus();
		return false;
	} else {
		return true;
	}
}

// ???  
function changeTextareaSize() {
	var txt = document.getElementById("body").value.split("\n");

	document.getElementById("body").style.height = 40 + (txt.length - 1) * 18;
	document.getElementById("submit").style.height = 40 + (txt.length - 1) * 18;

	return;
}

// ? ?
function imgView(src, w, h) {
	if (screen.width > parseInt(w)) {
		var ww = parseInt(w) + 16;
	} else {
		var ww = screen.width;
	}

	if (screen.height - 80 > parseInt(h)) {
		var hh = h;
	} else {
		var hh = screen.height;
	}

	var mm = window.open("", "imgview", "width=" + ww + ", height=" + hh + ", scrollbars=yes, top=0, left=0");

	var doc = "<html><head><title>View Image</title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=euc-kr\" /></head><body style=\"margin:0; cursor:pointer;\" onclick=\"self.close();\"><img src=\"" + src + "\"></body></html>";

	mm.document.write(doc);
}

// ?
function viewMedia(n, s, m, w, h) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;

	window.open("?n=" + n + "&m=" + m + "&s=" + s, m, "left=" + winl + ", top=" + wint + ", scrollbars=no, resizable=no, width=" + w + ", height=" + h);
}

// ?
function chgImage(cid, chg) {
	var obj = document.getElementById(cid);

	if (chg) {
		obj.src = chg;
	}
}
