﻿var xmlHttp;
var isrn;		// 일련번호
var date;		// 등록일
var time;		// 등록시간
var user;		// ID
var titl;		// 제목
var nrsp;		// 답변 건수
var only;		// 내의견만/전체보기
var skey = "";		// 내용검색어
var timeId;		// timeout id
var qseqn;		//질문입력 일련번호
var maxp;		// 총 갯수
var nrec;		// 레코드 갯수
var page;		// 현재 페이지
var cdate;		// 컨텐츠 작성일자
var cnrec;		// 답변 건수(parameter 값)
var loginUser;	// 로그인 사용자 ID
var isLogin;	// 로그인 상태 여부
var cuser;		// 게시물 등록자 ID 정보
var now = new Date();
var month;
var day;

var contents_height=0;
var reComment_height=0;

/*trim()함수 정의(공백제거)*/
String.prototype.trim = function () {
 return this.replace(/^\s*/, "").replace(/\s*$/, "");
}

month = (now.getMonth()+1);
if(month < 10){
	month = "0" + (now.getMonth()+1);
}
day = now.getDate();
if(now.getDate() < 10){
	day = "0" + now.getDate();
}
date = now.getFullYear() + month + day;

// 최초 onload function 
window.onload = function(){
	page = listForm.page.value;
	loadCommentList(listParameterString("0", "", page));		// 초기 리스트 조회 파라미터
}

/* 해당 게시물을 선택했을경우 색깔을 다르게 표현한다. */
function toggleed(trEle){
	//alert(trEle.parentElement.rows)
	//var rows = trEle.parentElement.rows;
	var rows = trEle.parentElement.rows;
	
	for(i = 1; i < rows.length; i++){
		if(rows[i] == trEle){
			trEle.style.backgroundColor = "#f3ebe0"
		}else{
			rows[i].style.backgroundColor = "#FFFFFF"
		}
	}
}

// 게시판 Table List 불러오기
function loadCommentList(para){
	new ajax.xhr.Request("/consult/chuck/commentlist.jsp", para, loadCommentDomList, 'POST');		//(url, params, callback, method)
}

// 게시판  Contents Data 불러오기 
function loadCommentContent(para){
	//new ajax.xhr.Request("commentContent.jsp", "isrn=348&only=Y", loadCommentResult, 'GET');
	new ajax.xhr.Request("/consult/chuck/commentContent.jsp", para, loadCommentResult, 'POST');
}

// 답변글 가져오기 
function reComment(para){
	new ajax.xhr.Request("/consult/chuck/recomment.jsp", para, reCommentResult, 'POST');
	//refresh 영역
	timeId = setTimeout("reComment('" + para + "')", 10000);
}

// 추천하기
function countUpdate(para){
	//alert(para);
	new ajax.xhr.Request("/consult/chuck/FC_ho900410.jsp", para, countUpdateResult, 'POST');
}

// 질문 삭제
function contentDelete(){
	/* 로그인이 되어져 있고 해당 작성자만 해당 게시물을 삭제할 수 있도록 제어 */
	if(loginUser != cuser){
		alert('작성자만 삭제하실 수 있습니다.');
	} else {
		/* 답변 게시물이 없을 경우에만 삭제가 가능하게 한다. */
		if(Number(cnrec) > 0){
			alert("답변글이 없을경우에만 삭제 가능합니다.");
		} else {
			/* 게시물 리스트 정보를 가지고 있는 object 객체를 호출 */
			var commentObj = document.getElementById("commentResult");
			if (commentObj.style.display == "none") {
				alert("게시물 내용이 보여진 상태에서만 삭제 가능합니다.");
			} else {
				/* 해당 게시물을 삭제하기위한 게시물 고유 번호 및 날짜 셋팅(parameter 값) */
				var para = "seqn=" + qseqn + "&date=" + cdate;
				new ajax.xhr.Request("/consult/chuck/FC_ho900401_2_del.jsp", para, deleteContentResult, 'POST');
			}
		}
	}
}

// 질문 등록 처리영역
function addComment(){
	var title = addForm.title.value;
	var contents = addForm.content.value;

contents = contents.trim();

	if(title == ""){
		alert("질문의 제목을 입력 하신후 등록하세요");
		return;
	}

	// 제목에 대한 글자수 제한
	if(title.length > 1000){
		alert("[제목]영문1000, 한글500자로 제한됩니다.!");  
		title = title.substring(0,1000);
		return;
	}

	if(contents == ""){
		alert("질문의 내용을 입력 하신후 등록하세요");
		return;
	}

	// 내용에 대한 글자수 제한
	if(contents.length > 3000) {
		alert("[내용]영문3000, 한글1500자로 제한됩니다.!");  
		contents = contents.substring(0,3000);
		return;
	}

	var tagString = "<div><font style='font-size:10pt; font-family:굴림;' color='#000000'></font><font style='font-size:10pt;font-family:굴림;' color='#000000'>";
	var title = tagString + addForm.title.value + "</font></div>";
	contents = replaceDiv(contents, "\r\n","</div><div>");
	var data = title + contents;
	var para = contentsParameterString("2", "", date, addForm.not_show[addForm.not_show.selectedIndex].value, data);	// 질문입력 , 자료일련번호,날짜,  공개여부, data(답변 입력)

	//alert(para);
	new ajax.xhr.Request("/consult/chuck/FC_ho900401_2.jsp", para, addCommentResult, 'POST');
}

// 질문하기 입력 form 초기화 세팅 
function initComment(){
	addForm.title.value = "";
	addForm.content.value = "";
	addForm.not_show.selectedIndex = 0;
}

//----------------------------------------
// 입력 컨텐츠 <Div> 세팅
//----------------------------------------
function replaceDiv(str, oStr, nStr){
	var flag = true;
	str = "<div>" + str;

	while(flag){
		if(str.indexOf(""+ oStr +"") > 0){
			str = str.replace(oStr,nStr);
		}else{flag = false;}
	}

	str = str + "</div>";
	return str;
}

// List parameter String
// 전체보기,내용검색어,페이지번호, 한페이지당 레코드 갯수
function listParameterString(only, skey, page){
	var queryString = "only=" + only + "&skey=" + escape(encodeURIComponent(skey)) + "&page=" + page + "&nrec=5";
	return queryString;
}

// contents parameter String
// 내용조회 , 자료일련번호, 공개여부, data(답변 입력)
function contentsParameterString(func, seqn, date, not_show, data){
	var queryString = "func=" + func + "&date=" + date + "&seqn=" + seqn + "&webx=1&show=" + not_show + "&data=" + escape(encodeURIComponent(data));
	return queryString;
}

// 추천하기 파라미터
// 추천 , 질문입력 일련 번호, 답변자일련번호
function countUpdateParameterString(func, date, qseqn , rseqn){
	var queryString = "func=" + func + "&qdate=" + date + "&qseqn=" + qseqn + "&rseqn=" + rseqn;
	return queryString;
}

// 페이지 이동 처리 
function goThisListPage(pageNum) {
	// 질문등록 버튼을 눌렀을 경우 내용 보기, 답변 창이 띄어져 있으면 해당 내용 보기, 답변 창을 닫는다
	closeView();

	page = pageNum;
	loadCommentList(listParameterString(only, skey, page));
}

//paging 처리 영역
function loadPaging(page, nrec, maxp){
	if(nrec <= 0){nrec = 1;}
	if(maxp <= 0){maxp = 1;}
	if(page <= 0){page = 1;}

	var para = "rowsPerPage=" + nrec + "&currentPage=" + page + "&totalCount=" + maxp;

	new ajax.xhr.Request("/common/jsp/paging.jsp", para, pagingResult, 'GET');
}

// paging innerHTML
function pagingResult(req){
	if (req.readyState == 4) {
			if (req.status == 200) {
				// setTimeout() 해제 		###절대 지우지 말것..####
				if(timeId != ""){
					clearTimeout(timeId);
					// 기존 Data 삭제 처리 후 새로 추가(답변 영역)
					var reNode = document.getElementById("recommentList");
					while(reNode.childNodes.length > 0) {
						reNode.removeChild(reNode.childNodes[0]);
					}
				}

				var htmlDoc = req.responseText;

				// 기존 Data 삭제 처리 후 새로 추가
				var pageNode = document.getElementById("paging");

				while(pageNode.childNodes.length > 0){
					pageNode.removeChild(pageNode.childNodes[0]);
				}

				pageNode.innerHTML = htmlDoc;
		} else {
			alert("paging error :"+req.status);
		}
	}
}

// 게시판 List DOM Data 처리 영역
function loadCommentDomList(req){
	if (req.readyState == 4) {
		if (req.status == 200) {
			var xmlDoc = req.responseXML;
			var code = xmlDoc.getElementsByTagName("code").item(0).firstChild.nodeValue;
			maxp = xmlDoc.getElementsByTagName("maxp").item(0).firstChild.nodeValue;
			nrec = xmlDoc.getElementsByTagName("nrec").item(0).firstChild.nodeValue;

			loadPaging(page, nrec, maxp);	// ajax page 처리

			// 기존 Data 삭제 처리 후 새로 추가
			var listNode = document.getElementById("commentList");

			while(listNode.childNodes.length > 0) {
				listNode.removeChild(listNode.childNodes[0]);
			}

			makeCommentListTitle();

			if (code == 'success') {
				// data 태그의 값을 객체로 변환
				var commentList = eval( "(" + xmlDoc.getElementsByTagName('data').item(0).firstChild.nodeValue + ")" );

				// 목록 처리 부분
				// var listDiv = document.getElementById('commentList');

				for (var i = 0 ; i < commentList.length ; i++) {
					makeCommentListView(commentList[i]);
					// listDiv.appendChild(commentDiv);
				}
			} else if (code == 'error') {
				var message = xmlDoc.getElementsByTagName('message').item(0).firstChild.nodeValue;
				alert("리스트 에러 발생:"+message);
			}
		} else {
			alert("리스트  목록 로딩 실패:"+req.status);
		}
	}
}

// 게시판 내용  처리 영역
function loadCommentResult(req) {
	if (req.readyState == 4) {
		if (req.status == 200) {
			// 내용보기 버튼을 눌렀을 경우 질문하기 창이 띄어져 있으면 해당 질문하기 폼을 닫는다
			//document.addForm.eflag.value = "N";
			//document.getElementById("commentAdd").style.display = "none";
			closeView();
			var xmlDoc = req.responseXML;
			var code = xmlDoc.getElementsByTagName("code").item(0).firstChild.nodeValue;

			// 기존 Data 삭제 처리 후 새로 추가
			var cNode = document.getElementById("commentResult");

			while(cNode.childNodes.length > 0) {
				cNode.removeChild(cNode.childNodes[0]);
			}

			if (code == 'success') {
				// data 태그의 값을 객체로 변환
				var commentResult = eval( "(" + xmlDoc.getElementsByTagName('data').item(0).firstChild.nodeValue + ")" );
				/* 로그인 여부를 판단한다(Y : 로그인 되어있는 상태, N : 로그인 되지 않은 상태) */
				isLogin = xmlDoc.getElementsByTagName("islogin").item(0).firstChild.nodeValue;
				/* 사용자 ID 값이 있는지 여부룰 확인한다. */
				if (xmlDoc.getElementsByTagName("userid").item(0).firstChild == null) {
					loginUser = "...";
				} else {
					loginUser = xmlDoc.getElementsByTagName("userid").item(0).firstChild.nodeValue;
				}
				for (var i = 0 ; i < commentResult.length ; i++) {
					makeCommentResultView(commentResult[i]);
					
				}
			} else if (code == 'error') {
				var message = xmlDoc.getElementsByTagName('message').item(0).firstChild.nodeValue;
				alert("내용 에러 발생:"+message);
			}
		} else {
			alert("내용 목록 로딩 실패:"+req.status);
		}
	}
	
	contents_height = document.getElementById("offsetTable").offsetHeight;	
	
	popResize();//resize
}

// 추천하기 처리 
function countUpdateResult(req) {
	if (req.readyState == 4) {
		if (req.status == 200) {
			var xmlDoc = req.responseXML;
			var code = xmlDoc.getElementsByTagName("code").item(0).firstChild.nodeValue;

			if (code == 'success') {
				// data 태그의 값을 객체로 변환
				var commentResult = eval( "(" + xmlDoc.getElementsByTagName('data').item(0).firstChild.nodeValue + ")" );
				for (var i = 0 ; i < commentResult.length ; i++) {
					alert(commentResult[i].msg);		// 처리 결과 alert 
				}
			} else if (code == 'error') {
				var message = xmlDoc.getElementsByTagName('message').item(0).firstChild.nodeValue;
				alert("질문 입력 처리 오류:"+message);
			}
		} else {
			alert("질문 입력 처리 페이지 검색 실패:"+req.status);
		}
	}
}

/* 삭제 하기 처리 결과 메시지 표현 */
function deleteContentResult(req) {
	/* 삭제 처리시 이하 보여지는 창을 닫는다. */
	closeView();
	if (req.readyState == 4) {
		if (req.status == 200) {
			var xmlDoc = req.responseXML;
			var code = xmlDoc.getElementsByTagName("code").item(0).firstChild.nodeValue;

			if (code == 'success') {
				// data 태그의 값을 객체로 변환
				var commentResult = eval( "(" + xmlDoc.getElementsByTagName('data').item(0).firstChild.nodeValue + ")" );
				for (var i = 0 ; i < commentResult.length ; i++) {
					alert(commentResult[i].msg);		// 처리 결과 alert 
				}
				if(skeyForm.only[0].checked == true){
					only = "1";
				}else{
					only = "0";
				}

				loadCommentList(listParameterString(only, "", page));		// 초기 리스트 조회 파라미터
			} else if (code == 'error') {
				var message = xmlDoc.getElementsByTagName('message').item(0).firstChild.nodeValue;
				alert("질문 삭제 처리 오류:"+message);
			}
		} else {
			alert("질문 삭제 처리 페이지 검색 실패:"+req.status);
		}
	}
}

// 질문 입력 결과 처리 
function addCommentResult(req) {
	if (req.readyState == 4) {
		if (req.status == 200) {
			var xmlDoc = req.responseXML;
			var code = xmlDoc.getElementsByTagName("code").item(0).firstChild.nodeValue;

			if (code == 'success') {
				// data 태그의 값을 객체로 변환
				var commentResult = eval( "(" + xmlDoc.getElementsByTagName('data').item(0).firstChild.nodeValue + ")" );
				for (var i = 0 ; i < commentResult.length ; i++) {
					alert(commentResult[i].msg);		// 처리 결과 alert 
				}
				if(skeyForm.only[0].checked == true){
					only = "1";
				}else{
					only = "0";
				}

				loadCommentList(listParameterString(only, "", page));		// 초기 리스트 조회 파라미터
			} else if (code == 'error') {
				var message = xmlDoc.getElementsByTagName('message').item(0).firstChild.nodeValue;
				alert("질문 입력 처리 오류:"+message);
			}
		} else {
			alert("질문 입력 처리 페이지 검색 실패:"+req.status);
		}
	}
}

// 게시판 답변 처리  영역
function reCommentResult(req) {
	if (req.readyState == 4) {
		if (req.status == 200) {
			var xmlDoc = req.responseXML;
			var code = xmlDoc.getElementsByTagName("code").item(0).firstChild.nodeValue;

			// 기존 Data 삭제 처리 후 새로 추가
			var reNode = document.getElementById("recommentList");
			while(reNode.childNodes.length > 0) {
				reNode.removeChild(reNode.childNodes[0]);
			}

			if (code == 'success') {
				// data 태그의 값을 객체로 변환
				var commentResult = eval( "(" + xmlDoc.getElementsByTagName('data').item(0).firstChild.nodeValue + ")" );

				for (var i = 0 ; i < commentResult.length ; i++) {
					makeReCommentResultView(commentResult[i]);
				}
			} else if (code == 'error') {
				var message = xmlDoc.getElementsByTagName('message').item(0).firstChild.nodeValue;
				alert("답변에러 발생:"+message);
			}
		} else {
			alert("답변 목록 로딩 실패:"+req.status);
		}
	}

	reComment_height = document.getElementById("recommentList").offsetHeight;
	
		popResize();//resize

}

// 척척 박사 리스트 Title Row 세팅처리 
function makeCommentListTitle(){
	var titleRow = commentList.insertRow();
		titleRow.style.backgroundColor = "#f9f8f6";
		
	var tCell_1 = titleRow.insertCell();
		tCell_1.setAttribute("height", "25");
		tCell_1.setAttribute("width", "70");
		tCell_1.setAttribute("align", "center");
		tCell_1.setAttribute("className", "text_12");
		tCell_1.innerHTML = "번호";
	var tCell_2 = titleRow.insertCell();
		tCell_2.setAttribute("width", "230");
		tCell_2.setAttribute("align", "center");
		tCell_2.setAttribute("className", "text_12");
		tCell_2.innerHTML = "제목";
	var tCell_3 = titleRow.insertCell();
		tCell_3.setAttribute("width", "70");
		tCell_3.setAttribute("align", "center");
		tCell_3.setAttribute("className", "text_12");
		tCell_3.innerHTML = "작성자";
	var tCell_4 = titleRow.insertCell();
		tCell_4.setAttribute("width", "98");
		tCell_4.setAttribute("align", "center");
		tCell_4.setAttribute("className", "text_12");
		tCell_4.innerHTML = "등록일";
	var tCell_5 = titleRow.insertCell();
		tCell_5.setAttribute("width", "72");
		tCell_5.setAttribute("align", "center");
		tCell_5.setAttribute("className", "text_12");
		tCell_5.innerHTML = "응답건수";
	var tCell_6 = titleRow.insertCell();
		tCell_6.setAttribute("width", "60");
		tCell_6.setAttribute("align", "center");
		tCell_6.setAttribute("className", "text_12");
		tCell_6.innerHTML = "조회수";
	var tCell_7 = titleRow.insertCell();
		tCell_7.setAttribute("width", "79");
		tCell_7.setAttribute("align", "center");
		tCell_7.setAttribute("className", "text_12");
		tCell_7.innerHTML = "공개여부";
	var lineRow = commentList.insertRow();
		lineRow.style.backgroundColor = "#c1b898";
	var lCell_1 = lineRow.insertCell();
		lCell_1.setAttribute("height", "1");
		lCell_1.setAttribute("colSpan", "7");
}

// 척척 박사 Table List Setting
function makeCommentListView(comment) {
	// 척척 박사 Table Data
	var newRowObject = commentList.insertRow();
	var isrnCell = newRowObject.insertCell();
	isrnCell.setAttribute("align","center");
	isrnCell.setAttribute("height","25");
	isrnCell.setAttribute("className","text_black");
	isrnCell.style.bgcolor = "#000000";
	var titlCell = newRowObject.insertCell();
	titlCell.setAttribute("className","text_black");
	var userCell = newRowObject.insertCell();
	userCell.setAttribute("align","center");
	userCell.setAttribute("className","text_black");
	var dateCell = newRowObject.insertCell();
	dateCell.setAttribute("align","center");
	dateCell.setAttribute("className","text_black");
	var nrspCell = newRowObject.insertCell();
	nrspCell.setAttribute("align","center");
	nrspCell.setAttribute("className","text_black");
	var cntxCell = newRowObject.insertCell();
	cntxCell.setAttribute("align","center");
	cntxCell.setAttribute("className","text_black");
	var onlyCell = newRowObject.insertCell();
	onlyCell.setAttribute("align","center");
	onlyCell.setAttribute("className","text_black");
	titlCell.setAttribute("width", "310");
	titlCell.style.cursor = "hand";		// style 적용

	//onclick Event 처리
	var para = contentsParameterString("9", comment.isrn, comment.date, comment.only, "") // 내용조회 , 자료일련번호, 공개여부, data
	titlCell.onclick = function() {
		loadCommentContent(para);		// 내용 보기 영역 script
		toggleed(newRowObject);					// 게시물을 클릭했을겨우 색깔 처리를 한다.

	}

	isrnCell.innerHTML = comment.seqNum;
	titlCell.innerHTML = "<nobr style='text-overflow:ellipsis; overflow:hidden; width:280'>" + comment.titl + "</nobr>";
	userCell.innerHTML = comment.user;
	dateCell.innerHTML = comment.date;
	nrspCell.innerHTML = comment.nrsp;
	cntxCell.innerHTML = comment.cntx;
	onlyCell.innerHTML = comment.only;

	var newRowObject1 = commentList.insertRow();
	var lineCell = newRowObject1.insertCell();
	lineCell.setAttribute("height", "1");
	lineCell.setAttribute("colSpan", "7");
	lineCell.style.backgroundColor = "#e2e2e2";
}


// 척척 박사 Table Content
function makeCommentResultView(comment) {	
	// setTimeout() 해제 		###절대 지우지 말것..####
	if(timeId != ""){
		clearTimeout(timeId);
		// 기존 Data 삭제 처리 후 새로 추가(답변 영역)
		var reNode = document.getElementById("recommentList");
		while(reNode.childNodes.length > 0) {
			reNode.removeChild(reNode.childNodes[0]);
		}
	}

	/* 비공개 게시글 일경우 해당 내용을 본인만 보여지도록 제한한다. */
	if(comment.only == '비공개' && loginUser != comment.user){
		alert('비공개 게시물입니다. 작성자만 로그인후 보실 수 있습니다.');
	} else {
		qseqn = comment.isrn;		// 질문 일련 번호
		cdate = comment.date;		// 질문 날짜
		cuser = comment.user		// 게시물 작성자
		cnrec = comment.nrec		// 답변건수

		// 제목 영역 row 
		var newRowObject2 = commentResult.insertRow();
		var titlCellTitle = newRowObject2.insertCell();
		var titlCell = newRowObject2.insertCell();	
		titlCellTitle.style.backgroundColor = "#f9f9f9";
		titlCellTitle.setAttribute("width", "120");
		titlCellTitle.setAttribute("align", "center");
		titlCellTitle.setAttribute("height", "23");
		titlCellTitle.setAttribute("className", "td_r_text_666666__12");
		titlCellTitle.innerHTML = "제  목";
		titlCell.setAttribute("className", "td_text_black");
		titlCell.setAttribute("colSpan", "5");
		titlCell.innerHTML = "&nbsp;" + comment.titl;

		// 작성자 영역 row
		var newRowObject3		= commentResult.insertRow();
		var userCellTitle	= newRowObject3.insertCell();
		var userCell			= newRowObject3.insertCell();
		userCellTitle.style.backgroundColor = "#f9f9f9";
		userCellTitle.setAttribute("className", "td_r_text_666666__12");
		userCellTitle.setAttribute("width", "120");
		userCellTitle.setAttribute("height", "23");
		userCellTitle.setAttribute("align", "center");
		userCellTitle.innerHTML = "작성자";
		userCell.setAttribute("width", "240");
		userCell.setAttribute("className", "td_text_black");
		userCell.innerHTML = "&nbsp;" + comment.user != null ? comment.user.substring(0,3) + "*****" : "";

		// 등록 일시
		var dateCellTitle	= newRowObject3.insertCell();	
		var dateCell			= newRowObject3.insertCell();
		dateCellTitle.style.backgroundColor = "#f9f9f9";
		dateCellTitle.setAttribute("className", "td_text_666666__12");
		dateCellTitle.setAttribute("width", "83");
		dateCellTitle.setAttribute("align", "center");
		dateCellTitle.innerHTML = "등록일시";
		dateCell.setAttribute("width", "120");
		dateCell.setAttribute("className", "td_text_black");
		dateCell.innerHTML = "&nbsp;" + comment.date;

		// 공개 여부
		var onlyCellTitle		= newRowObject3.insertCell();
		var onlyCell			= newRowObject3.insertCell();
		onlyCellTitle.style.backgroundColor = "#f9f9f9";
		onlyCellTitle.setAttribute("className", "td_text_666666__12");
		onlyCellTitle.setAttribute("width", "83");
		onlyCellTitle.setAttribute("align", "center");
		onlyCellTitle.innerHTML = "공개여부";
		onlyCell.setAttribute("width", "60");
		onlyCell.setAttribute("className", "td_text_black");
		onlyCell.innerHTML = "&nbsp;" + comment.only;	

		// 내용 영역 row
		var newRowObject4		= commentResult.insertRow();
		var contentCellTitle	= newRowObject4.insertCell();
		var contentCell			= newRowObject4.insertCell();
		contentCellTitle.style.backgroundColor = "#f9f9f9";
		contentCellTitle.setAttribute("className", "td_r_text_666666__12");
		contentCellTitle.setAttribute("width", "120");
		contentCellTitle.setAttribute("height", "120");
		contentCellTitle.setAttribute("align", "center");
		contentCellTitle.innerHTML = "내  용";
		contentCell.setAttribute("className", "td_text_black");
		contentCell.setAttribute("colSpan", "4");
		contentCell.innerHTML = "&nbsp" + comment.content;


		var newRowObject5 = commentResult.insertRow();
		var lineCell000 = newRowObject5.insertCell();
		lineCell000.setAttribute("height", "1");
		lineCell000.setAttribute("colSpan", "6");
		lineCell000.style.backgroundColor = "#e2e2e2";

		// content Visibility
		document.getElementById("commentResult").style.display = "";
		//document.getElementById("commentLine").style.display = "";		// commentLine
		//re para	답변 처리 영역
		var rePara = contentsParameterString("1", comment.isrn, comment.date, "", "")	// 답변조회 , 자료일련번호, 날짜,  공개여부, data(답변입력)

		// 답변 갯수가 있을경우 답변 처리 호출
		if(comment.nrec > 0){
			reComment(rePara);
		}

	}
}

// 척척 박사 답변 Table Content
function makeReCommentResultView(comment) {
	// 답변 첫 라인 
	var newRowObject1 = recommentList.insertRow();
	var cell = newRowObject1.insertCell();
	cell.setAttribute("width","5");
	var reUser = newRowObject1.insertCell();
	reUser.setAttribute("width", "693");
	reUser.innerHTML = "<span class='text_black_bold_12'>" + comment.reUser + "</span><span class='text_666666__12'>( " + comment.reCity + ", " + comment.reDate + " )</span>";

	// 추천하기
	var countPara = countUpdateParameterString("3", cdate,  qseqn, comment.reId);
	var cCell = newRowObject1.insertCell();
	cCell.setAttribute("align","center");
	cCell.setAttribute("width","43");

	var cellHtml = "<img src=\"/images/consult/chuck/images/btn_chuck_04.gif\" width=\"43\" height=\"19\" onclick=\"countUpdate('" + countPara + "')\" style=\"cursor:hand\"/>";

	cCell.innerHTML = cellHtml;

	// 라인 
	var newRowObject3		= recommentList.insertRow();
	var reLine	= newRowObject3.insertCell();
	reLine.setAttribute("colSpan", "3");
	reLine.innerHTML = "<img src='/images/consult/chuck/images/bg_dot_chuck.gif' width='693' height='1' />";

	// 답변 내용  영역 row
	var newRowObject2		= recommentList.insertRow();
	var cell2 = newRowObject2.insertCell();
	cell2.setAttribute("width","5");
	var reContent	= newRowObject2.insertCell();
	reContent.setAttribute("colSpan", "2");
	reContent.setAttribute("height", "20");
	reContent.setAttribute("width", "693");
	reContent.setAttribute("className", "text_666666__12");
	reContent.innerHTML = "<br><div style='margin-right:20px'>" + comment.reContent + "</div><br>";

	// 라인 
	var newRowObject4		= recommentList.insertRow();
	var reLine_b	= newRowObject4.insertCell();
	reLine_b.setAttribute("colSpan", "3");
	reLine_b.setAttribute("height","1");
	reLine_b.setAttribute("width","693");
	reLine_b.style.backgroundColor = "#e2e2e2";

	// content Visibility
	document.getElementById("recommentList").style.display = "";
}

// 질문 하기 Form Visibility
function addEditFormVisibility(){
	// setTimeout() 해제 		###절대 지우지 말것..####
	if(timeId != ""){
		clearTimeout(timeId);

		// 기존 Data 삭제 처리 후 새로 추가(답변 영역)
		var reNode = document.getElementById("recommentList");
		while(reNode.childNodes.length > 0) {
			reNode.removeChild(reNode.childNodes[0]);
		}
	}

	var eflag = document.addForm.eflag.value;

	if(eflag == "N"){
		// 질문등록 버튼을 눌렀을 경우 내용 보기, 답변 창이 띄어져 있으면 해당 내용 보기, 답변 창을 닫는다
		closeView();

		document.addForm.eflag.value = "Y";
		document.getElementById("commentAdd").style.display = "";
	}else{
		//document.addForm.eflag.value = "N";
		//document.getElementById("commentAdd").style.display = "none";
		closeView();
	}
}

// 검색 리스트 처리
function searchList(){
	// 질문등록 버튼을 눌렀을 경우 내용 보기, 답변 창이 띄어져 있으면 해당 내용 보기, 답변 창을 닫는다
	closeView();

	// setTimeout() 해제 		###절대 지우지 말것..####
	if(timeId != ""){
		clearTimeout(timeId);

		// 기존 Data 삭제 처리 후 새로 추가(답변 영역)
		var reNode = document.getElementById("recommentList");

		while(reNode.childNodes.length > 0) {
			reNode.removeChild(reNode.childNodes[0]);
		}
	}

	skey = skeyForm.skey.value;

	if(skey == ""){
		alert("검색할 단어를 입력하세요");
		return;
	}

	if(skeyForm.only[0].checked == true){
		only = "1";
	}else{
		only = "0";
	}

	// 전체보기,내용검색어,페이지번호
	//loadCommentList(listParameterString(only, skey, page));		// 초기 리스트 조회 파라미터
	loadCommentList(listParameterString(only, skey, 1));		// 초기 리스트 조회 파라미터
}

// 전체, 나만보기 페이지 리스트 호출
function rePage(){
	// 질문등록 버튼을 눌렀을 경우 내용 보기, 답변 창이 띄어져 있으면 해당 내용 보기, 답변 창을 닫는다
	closeView();

	// setTimeout() 해제 		###절대 지우지 말것..####
	if(timeId != ""){
		clearTimeout(timeId);

		// 기존 Data 삭제 처리 후 새로 추가(답변 영역)
		var reNode = document.getElementById("recommentList");

		while(reNode.childNodes.length > 0) {
			reNode.removeChild(reNode.childNodes[0]);
		}
	}

	if(skeyForm.only[0].checked == true){
		only = "1";
	}else{
		only = "0";
	}

	// 전체보기,내용검색어,페이지번호
	//loadCommentList(listParameterString(only, skey, page));		// 초기 리스트 조회 파라미터
	loadCommentList(listParameterString(only, skey, 1));		// 초기 리스트 조회 파라미터
}

// 질문 등록 및 답변 내용 창을 닫는다.
function closeView() {
	// 질문등록 버튼을 눌렀을 경우 내용 보기, 답변 창이 띄어져 있으면 해당 내용 보기, 답변 창을 닫는다
	document.addForm.eflag.value = "N";
	document.getElementById("commentResult").style.display = "none";
	document.addForm.eflag.value = "N";
	document.getElementById("recommentList").style.display = "none";
	document.addForm.eflag.value = "N";
	document.getElementById("commentAdd").style.display = "none";
}


/****** 팝업창 리사이즈 **************************************************************/
function popResize() {

	var thisY = document.getElementById("offsetTable").offsetHeight;

	thisY = thisY + document.getElementById("recommentList").offsetHeight;
	
	var marginY = 470;
	
	window.document.body.scroll = "no";
	
	var iFrame = parent.document.getElementById("iFrame");
	iFrame.width = 700;
	iFrame.height = reComment_height+contents_height+marginY;
	
	//window.resizeTo(700,reComment_height+contents_height+marginY);

	//alert(reComment_height+contents_height);
}
