var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);
var agt=navigator.userAgent.toLowerCase();
var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie3    = (is_ie && (is_major < 4));
var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
var is_ie4up  = (is_ie && (is_major >= 4));
var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);
var category = 0;

function close_win() {
	this.close();
}

function resize_win(width, height) {
	this.moveTo(0, 0);
	this.resizeTo(width, height);
}

function create_popup(path, name, feature) {
	var win = window.open(path, name, feature);
	win.focus();
}

function trim(str) {
	return str.replace(/(^\s*)|(\s*$)/g, "");
}

function goto_admin() {
	category = 0;
	if (parent) {
		var frame = document.getElementById("content_frame");
		frame.src = "/admanager/default.asp";
	}
}

function goto_write() {
	if (parent) {
		var frame = document.getElementById("content_frame");
		frame.src = "/Write.asp?category=" + category;
	}
}

function resize_frame(frm) {
	var pFrame = eval(frm + ".document.body;");
	var iFrame = eval("document.all." + frm + ";");

	iFrame.style.height = pFrame.scrollHeight + (pFrame.offsetHeight - pFrame.clientHeight);
}


function edit_category() {
	category = 0;
	if (parent) {
		var frame = document.getElementById("content_frame");
		frame.src = "/admanager/Category.asp";
	}
}

function goto_category(c) {
	if (parent) {
		var frame = document.getElementById("content_frame");
		if (parseInt(c) == 0)
			frame.src = "/PostList.asp?mode=all";
		else
			frame.src = "/PostList.asp?mode=category&category=" + c;
		category = c;
	}
}

function view_image(url) {
	window.open("/Popup/ImageViewer.asp?url=" + url, "img_win", "width=100,height=100");
}

function show_comment(id) {
	var cmt = document.all["child_comment_" + id];
	var tb = document.all["child_tb_" + id];

	tb.style.display = "none";

	if (cmt.style.display == "") {
		cmt.style.display = "none";
	} else {
		cmt.style.display = "";
		cmt.src = "/CommentList.asp?id=" + id;
	}
}

function show_trackback(id) {
	var cmt = document.all["child_comment_" + id];
	var tb = document.all["child_tb_" + id];

	cmt.style.display = "none";

	if (tb.style.display == "")
		tb.style.display = "none";
	else {
		tb.style.display = "";
		tb.src = "/TrackbackList.asp?id=" + id;
	}
}

function update_post(id) {
	location.href = "/UpdatePost.asp?id=" + id;
}

function remove_post(id) {
	if (confirm("ÀÌ Æ÷½ºÆ®¸¦ »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?"))
		location.href = "/RemovePost.asp?id=" + id;
}

function check_length(max, obj) {
	var d = document.forms[0];
	var temp;	
	var len = obj.value.length;
	
	for (i=0;i<len;i++) {
		temp = obj.value.charAt(i);
	
		if (escape(temp).length > 4)
			max -= 2;
		else
			max --;
	}

	if (max < 0)
		return true;
	else
		return false;
}

function update_comment(num) {
	window.open("/Popup/UpdateComment.asp?num=" + num, "update_cmt_win", "width=10,height=10");
}

function remove_comment(num) {
	window.open("/Popup/RemoveComment.asp?num=" + num, "remove_cmt_win", "width=10,height=10");
}

function remove_trackback(num) {
	if (confirm("ÀÌ Æ®·¢¹é Æ÷½ºÆ®¸¦ Á¤¸» »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?"))
		window.open("/Popup/RemoveTrackback.asp?num=" + num, "remove_tb_win", "width=100,height=100");
}
function signin() {
	category = 0;
	window.open("/admanager/SignIn.asp", "sign_window", "width=10,height=10");
}

function signout() {
	category = 0;
	window.open("/admanager/SignOut.asp", "sign_window", "width=10,height=10");
}
function copy_trackback(obj) {
	if(is_ie) {
		if(confirm("Æ®·¢¹é ÁÖ¼Ò¸¦ Å¬¸³º¸µå¿¡ º¹»çÇÏ½Ã°Ú½À´Ï±î?"))
			window.clipboardData.setData("Text", obj.innerHTML);
	}
}
function isIntKeyDownCode() {
   if (event.keyCode==32||(event.keyCode>57&&event.keyCode<95)||event.keyCode>105)
      event.returnValue=false;
}
function isIntKeyPressCode() {
   if (!(event.keyCode>47&&event.keyCode<58))
      event.returnValue=false;
}

