var textSize = 12;

function sendMail(oname, omail) {
	var cmail = "";

	for(i = omail.length; i >= 0; i--) {
		var cmail = cmail + omail.substr(i, 1);
	}

	location.replace("mailto:" + oname + "<" + unescape(cmail) + ">");
}
function imgResize(obj, mw, mh, iw, ih) {
	var cs = [mw, mh];

	if (mw > 0 && mh > 0) {
		if (iw > mw || ih > mh) {
			var rw = iw / mw;
			var rh = ih / mh;

			if (rw > rh) {
				cs[0] = mw;
				cs[1] = Math.ceil(ih * mw / iw);
			} else {
				cs[0] = Math.ceil(iw * mh / ih);
				cs[1] = mh;
			}
		} else {
				cs[0] = iw;
				cs[1] = ih;
		}
	} else if (mw > 0) {
		if (iw > mw) {
			cs[0] = mw;
			var rw = mw / iw;
		} else {
			cs[0] = iw;
			var rw = 1;
		}

		cs[1] = Math.ceil(ih * rw);
	} else if (mh > 0) {
		if (ih > mh) {
			cs[1] = mh;
			var rh = mh / ih;
		} else {
			cs[1] = ih;
			var rh = 1;
		}

		cs[0] = Math.ceil(iw * rh);
	}

	obj.width = cs[0];
	obj.height = cs[1];
}
function setTextSize(val) {
	if ((val > 0 && textSize >= 16) || (val < 0 && textSize <= 8)) {
		return;
	}

	textSize = val == 0 ? 12 : textSize + val;
	lib.object("article").style.fontSize = textSize;
}
function setTextCopy(id){
	var doc = document.body.createTextRange();

	doc.moveToElementText(lib.object(id));
	doc.select();
	doc.execCommand('copy');
	window.alert('ÇØ´ç ³»¿ëÀÌ º¹»çµÇ¾ú½À´Ï´Ù.');

	return false;
}
function showMessage(oid, val, msg) {
	var obj = lib.object(oid);

	obj.innerHTML = msg;
	obj.style.posTop = event.clientY + document.body.scrollTop;
	obj.style.posLeft = event.clientX;
	obj.style.display = val ? '' : 'none';
}
function setMagazine(frm) {
	var xml;
	var val = frm._email_.value;
	var act = lib.radio(frm._action_, 1);

	if (val == "" || val == "ÀÌ¸ÞÀÏÀ» ÀÔ·ÂÇÏ¼¼¿ä") {
		window.alert("ÀÌ¸ÞÀÏÀ» ÀÔ·ÂÇÏ¼¼¿ä.");
		frm._email_.focus();
		return;
	} else if (act == "") {
		window.alert("½ÇÇàÁ¾·ù°¡ Á¸ÀçÇÏÁö ¾Ê½À´Ï´Ù.");
		return;
	} else if (confirm(act == "ins" ? "¸ÞÀÏ ¸Å°ÅÁøÀ» ½ÅÃ»ÇÏ½Ã°Ú½À´Ï±î?" : "¸ÞÀÏ ¸Å°ÅÁøÀ» ÇØÁöÇÏ½Ã°Ú½À´Ï±î?") == false) {
		return;
	}

	xml = new XmlHttp("GET", lib.topDir + "/member.php?m=magazine&a=" + act + "&v=" + val, []);
	xml.init();

	if (xml.msg) {
		window.alert(xml.msg);
	} else {
		window.alert("¸Å°ÅÁø " + (act == "ins" ? "½ÅÃ»ÀÌ" : "ÇØÁö°¡") + " ¿Ï·áµÇ¾ú½À´Ï´Ù.");
		frm.reset();
	}
}