
/* Link Read Page */
function readBoard(board_id, board_no){
	document.location.href = "/comm/"+board_id+"/read.asp?no="+board_no;
}

function openGlog(domain){
	var sUrl = "http://"+ domain ;
	window.open(sUrl, getName(domain), "");
}

function openSeries(domain, series_id){
	var sUrl = "http://"+ domain +"/series/list.asp?sid=" + series_id;
	window.open(sUrl, getName(domain), "");
}

function openInstallment(domain, install_id){
	var iUrl = "http://" + domain + "/" + install_id + ".ilog";
	window.open(iUrl, getName(domain), "");
}

function getName(domain){
	return (domain.split("."))[0];
}

function showHelp(help_id){
	var hUrl = "/help/";
	document.location.href = hUrl;
}

function goLogin(rtnUrl){
	document.location.href = '/common/action/login.asp?rtnUrl='+rtnUrl;
}

function goCart(){
	document.location.href = '/book/cart.asp';
}

function sell_popup(book_num){
	if(check_login()){
		win_style = "scrollbars=no, resizable=yes,copyhistory=no, width=500, height=300";

		a_href = "/account/popup_sellbook.asp?book_num="+book_num;
		window.open( a_href , 'SellPopup' , win_style);
	}
}


function showRecomm(show_type){
	document.all.recommlist.style.display = show_type;
	if(show_type == 'none'){
		document.all.showrecomm(0).style.display = 'none';
		document.all.showrecomm(1).style.display = 'block';
	}else{
		document.all.showrecomm(0).style.display = 'block';
		document.all.showrecomm(1).style.display = 'none';
	}
}

function showBoardRecommTextArea(board_item_no, parent_id, board_id, chk_disabled){
	var textAreaString = "<form name=\"recommProcess\" method=\"post\" action=\"/comm/add_comment.asp\" class=\"reply_form\"> ";
		textAreaString += " <input type=\"hidden\" name=\"board_item_no\" value=\""+board_item_no+"\"> ";
		textAreaString += " <input type=\"hidden\" name=\"parent_id\" value=\""+parent_id+"\"> ";
		textAreaString += " <input type=\"hidden\" name=\"board_id\" value=\""+board_id+"\"> ";
		textAreaString += " <table border=\"0\"> ";
		textAreaString += " <tr> ";
		textAreaString += " <td><textarea class=\"form_txt1\" name=\"comment_content\" style=\"width: 430px; height: 50px\" onkeyup=\"check_comment_length(this,'recomment_length')\" ";
		if(chk_disabled)	{	textAreaString += " disabled >·Î±×ÀÎ ÈÄ, ÀÌ¿ëÇØ ÁÖ¼¼¿ä";  }
		else			{	textAreaString += ">"; }
		textAreaString += "</textarea></td> ";
		textAreaString += " <td> <input type=\"Image\" src=\"http://image.barobook.com/ijakga/images/btn_register02.gif\" alt=\"µî·Ï\"></td> ";
		textAreaString += " </tr> ";
		textAreaString += " <tr> ";
		textAreaString += " <td colspan=\"2\">ÇöÀç<span id=\"recomment_length\" class=\"txt_fd600a\">0</span> ";
		textAreaString += " /ÃÖ´ë 400byte (ÇÑ±Û 200ÀÚ, ¿µ¹® 400ÀÚ)</td> ";
		textAreaString += " </tr></table> ";
		textAreaString += "</form>";

	return textAreaString;
}

var temp_comment_no = "";
function showrewriter(board_item_no, board_id, comment_no){

	if (temp_comment_no != "" || temp_comment_no == comment_no){
		document.getElementById("recomm_"+temp_comment_no).innerHTML = "";
		document.getElementById("recomm_"+temp_comment_no).style.display = "none";

		if (temp_comment_no == comment_no){
			temp_comment_no = "";
			return;
		}
	}

	var chk_disabled = document.boardRecomm.comment_content.disabled;
	var showString = showBoardRecommTextArea(board_item_no, comment_no, board_id, chk_disabled);

	temp_comment_no = comment_no;
	document.getElementById("recomm_"+comment_no).innerHTML = showString;
	document.getElementById("recomm_"+comment_no).style.display = "block";

	if(!chk_disabled)	document.recommProcess.comment_content.focus();
}

function delCommentItem(board_id, comment_no){
	document.location.href = "/comm/del_comment.asp?board_id="+board_id+"&comment_no="+comment_no;
}

function deleteBoardItem(board_id, board_item_no, comment_no){
	if (!confirm("´ñ±ÛÀ» »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?"))
	{
		return;
	}else{
	var params;
	params = "board_id="+board_id+"&board_item_no="+board_item_no;
	params += "&comment_no="+comment_no

	getBoardList(params);}
}

function showBoardList(board_id, board_item_no){
	var params;
	params = "board_id="+board_id+"&board_item_no="+board_item_no;

	getBoardList(params);
}

function getBoardList(params) {
	var url = "/comm/board_comment_list.asp";

	var myAjax = null;
	myAjax = new Ajax.Request (
		url, {
			method: 'get',
			parameters: params,
			onSuccess: set_boardlist
		});
}

function set_boardlist(request) {
	document.getElementById("show_comment_list").innerHTML = request.responseText;
}

function check_comment_length(obj, len_id) {
	var length = get_byte_length(obj);
	document.getElementById(len_id).innerHTML = length;

	if (length > 400) {
		alert("´ñ±ÛÀº ÇÑ±Û 200ÀÚ(400bytes)¸¦ ³ÑÀ» ¼ö ¾ø½À´Ï´Ù.");
		obj.focus();
	}
}


// ¹ÙÀÌÆ® ±æÀÌ¸¦ ¸®ÅÏ
function get_byte_length(input) { 
	var byte_length = 0; 
	for (var i = 0; i < input.value.length; i++) { 
		var one_char = escape(input.value.charAt(i)); 
		if (one_char.length == 1) byte_length ++; 
		else if (one_char.indexOf("%u") != -1) byte_length += 2; 
		else if (one_char.indexOf("%") != -1) byte_length += one_char.length / 3; 
	}
	return byte_length; 
} 


function recomm_glog(tab_name, list_name){
	document.getElementById('series_tab').className 	= "";
	document.getElementById('book_tab').className 		= "";
	document.getElementById('tag_tab').className 		= "";
	document.getElementById('series_tabList').style.display = "none";
	document.getElementById('book_tabList').style.display 	= "none";
	document.getElementById('tag_tabList').style.display 	= "none";

	document.getElementById(list_name).style.display = "block";
	document.getElementById(tab_name).className = "current";
}


function seriesRecent(tab_num){

	for(i=0; i<5; i++){
		document.getElementById('series_recent_tab_'+i).className 		= "";
		document.getElementById('seriesRecent_'+i).style.display 	= "none";
	}
	document.getElementById('series_recent_tab_'+tab_num).className 	= "current";
	document.getElementById('seriesRecent_'+tab_num).style.display 	= "block";
}


function boardRecent(tab_name, list_name){
	document.getElementById('bbs_tab').className 		= "";
	document.getElementById('pds_tab').className 		= "";
	document.getElementById('discuss_tab').className 	= "";
	document.getElementById('qna_tab').className 		= "";
	document.getElementById('right_bbs_list').style.display 	= "none";
	document.getElementById('right_pds_list').style.display 	= "none";
	document.getElementById('right_discuss_list').style.display = "none";
	document.getElementById('right_qna_list').style.display 	= "none";

	document.getElementById(list_name).style.display = "block";
	document.getElementById(tab_name).className = "current";
}


function lank_glog(tab_name, list_name){
	document.getElementById('author_point_tab').className 	= "";
	document.getElementById('view_point_tab').className 	= "";
	document.getElementById('pop_point_tab').className 		= "";
	document.getElementById('author_point_list').style.display = "none";
	document.getElementById('view_point_list').style.display = "none";
	document.getElementById('pop_point_list').style.display = "none";

	document.getElementById(list_name).style.display = "block";
	document.getElementById(tab_name).className = "current";
}


function mainRecent(tab_num){

	for(i=0; i<5; i++){
		document.getElementById('series_recent_tab_'+i).className 		= "";
		document.getElementById('series_recent_'+i).style.display 	= "none";
	}
	document.getElementById('series_recent_tab_'+tab_num).className 	= "current";
	document.getElementById('series_recent_'+tab_num).style.display 	= "block";
}


function todayBest(tab_num){

	for(i=0; i<5; i++){
		document.getElementById('todayBest_'+i).className 		= "";
		document.getElementById('todayList_'+i).style.display 	= "none";
	}
	document.getElementById('todayBest_'+tab_num).className 	= "current";
	document.getElementById('todayList_'+tab_num).style.display 	= "block";
}


function weekBestBook(tab_num){

	for(i=0; i<5; i++){
		document.getElementById('weekBestBook_'+i).className 		= "";
		document.getElementById('weekBestBook_con'+i).style.display 	= "none";
	}
	document.getElementById('weekBestBook_'+tab_num).className 	= "current";
	document.getElementById('weekBestBook_con'+tab_num).style.display 	= "block";
}


function weekLankGlog(tab_num){

	for(i=1; i<=3; i++){
		document.getElementById('weekGlogRank_'+i).className 		= "";
		document.getElementById('weekGlogRank_con'+i).style.display 	= "none";
	}
	document.getElementById('weekGlogRank_'+tab_num).className 	= "current";
	document.getElementById('weekGlogRank_con'+tab_num).style.display 	= "block";
}

function detailBookInfoTab(tab_num, tab_cnt){
	for(i=0; i<tab_cnt; i++){
		document.getElementById('bookdetail_tab'+i).className 		= "";
	}
	document.getElementById('bookdetail_tab'+tab_num).className 	= "current";

	if(tab_num == 0){
		for(i=1; i<tab_cnt; i++){
			document.getElementById('bookdetail_con'+i).style.display 	= "block";
		}
	}else{
		for(i=1; i<tab_cnt; i++){
			document.getElementById('bookdetail_con'+i).style.display 	= "none";
		}
		document.getElementById('bookdetail_con'+tab_num).style.display 	= "block";
	}

}


function myIjakgaTab(tab_num){

	for(i=0; i<3; i++){
		document.getElementById('myList_Tab'+i).className 		= "";
		document.getElementById('myList_Con'+i).style.display 	= "none";
	}
	document.getElementById('myList_Tab'+tab_num).className 	= "current";
	document.getElementById('myList_Con'+tab_num).style.display 	= "block";

}

