var overFlag;
//document.domain = "dcinside.com";

function toggle(id,no)
{
	obj = document.getElementById(target_div + no);
	if (obj.style.display == 'none'){
		view_comment(id,no);
		obj.style.display = '';
	}else{
		obj.style.display = 'none';
	}
	//parent.resizeCaller();
	
}

function insertNewRow(a,name,memo,date,b_del,face,ad,dctalk) 
{ 

	var oCell = new Array(); 
	ttab = document.getElementById(a);


	//새 행 추가 
	var gRows  = ttab.insertRow(ttab.rows.length); 
	//gRows.onmousedown = function(){selectRow(this)} 
	//gRows.onmouseover = function(){tblMouseOver(this)} 
	//gRows.onmouseout = function(){tblMouseOut(this)} 
	//새 셀(td)추가 
	gRows.onmouseover=function(){this.style.backgroundColor='#F2F0F9'}
	gRows.onmouseout=function(){this.style.backgroundColor=''}

	oCell[0] = gRows.insertCell(0); 
	oCell[1] = gRows.insertCell(1); 
	oCell[2] = gRows.insertCell(2); 
	oCell[3] = gRows.insertCell(3); 
	oCell[4] = gRows.insertCell(4);
	oCell[5] = gRows.insertCell(5);
	oCell[6] = gRows.insertCell(6);
	oCell[7] = gRows.insertCell(7);
	
	oCell[0].vAlign = "top";
	oCell[1].vAlign = "top";
	oCell[2].vAlign = "top";
	oCell[3].vAlign = "top";
	oCell[4].vAlign = "top";
	oCell[5].vAlign = "top";
	oCell[6].vAlign = "top";
	oCell[7].vAlign = "top";

	oCell[0].align = "left";
	oCell[1].align = "left";
	oCell[2].align = "left";
	oCell[3].align = "left";
	oCell[4].align = "left";
	oCell[5].align = "left";
	oCell[6].align = "left";
	oCell[7].align = "left";

	//각셀의 값 입력 

	oCell[0].innerHTML = face; 

	oCell[1].innerHTML = name;

	oCell[3].width = "536";
	oCell[3].innerHTML = memo; 

	oCell[4].innerHTML = dctalk;
	oCell[5].innerHTML = date;
	oCell[6].innerHTML = ad;
	oCell[7].innerHTML = b_del;

	
	//추가된 셀 선택 
	//selectRow(gRows) ; 

}


function new_insertNewRow2(a,name,memo,date,b_del,face,ad,dctalk,ip,aclass)
{ 
	//	alert(a +' ' +name +' ' +memo +' ' +date +' ' +b_del +' ' +face +' ' +ad +' ' +dctalk +' ' +ip +' ' +aclass);
	var oCell = new Array(); 
	var ttab;
	ttab = document.getElementById(a);

	//새 행 추가 
	var gRows  = ttab.insertRow(ttab.rows.length); 
	
	oCell[0] = gRows.insertCell(0); 
	oCell[1] = gRows.insertCell(1); 
	oCell[2] = gRows.insertCell(2); 
	oCell[3] = gRows.insertCell(3); 
	oCell[4] = gRows.insertCell(4); 

	if (ad) {
		oCell[5] = gRows.insertCell(5);
	}

	oCell[0].align = "left";
	oCell[1].align = "left";
	oCell[3].align = "left";
	oCell[4].align = "left";
	
	oCell[0].className = aclass || "com_name";
	oCell[1].className = "com_text";
	oCell[2].className = "com_chat";	
	oCell[3].className = "com_ip";
	oCell[4].className = "com_btn";

	//각셀의 값 입력 
	
	oCell[0].innerHTML = face + " " + name ; 	
	oCell[1].innerHTML = memo;
	oCell[2].innerHTML = " " + dctalk; 
	//alert(oCell[0].innerHTML +'  '  + oCell[1].innerHTML +'  '  + oCell[2].innerHTML);

	if (ip) {
		oCell[1].innerHTML += '<span class="line">|</span><span class="num2">'+ ip +'</span>';
	}

	oCell[3].innerHTML = '<span class="num">'+ date +'</span>'; 
	oCell[4].innerHTML = b_del; 

	if (ad) {
		oCell[5].innerHTML = ad; 
	}
}

function qa_insertNewRow(a,name,memo,date,b_del,face,ad,dctalk,ip,aclass,newmemo,newno)
{ 
	var oCell = new Array(); 
	ttab = document.getElementById(a);

	//새 행 추가 
	var gRows  = ttab.insertRow(ttab.rows.length); 

	oCell[0] = gRows.insertCell(0); 
	oCell[1] = gRows.insertCell(1); 
	oCell[2] = gRows.insertCell(2); 
	oCell[3] = gRows.insertCell(3); 

	if (ad) {
	oCell[4] = gRows.insertCell(4);
	}

	oCell[0].align = "left";
	oCell[1].align = "left";
	oCell[2].align = "left";
	oCell[3].align = "left";


	oCell[0].className = "com_name";
	oCell[1].className = "com_text";
	oCell[2].className = "com_ip";
	oCell[3].className = "com_btn";

	//각셀의 값 입력 
	oCell[0].innerHTML = name + face; 
	oCell[1].innerHTML = newmemo || memo;		//	네이트 타입memo가 있을경우 우선 출력 없을경우 예전방식 memo출력
	oCell[2].innerHTML = '<span class="num">' + date + '</span>'; 
	oCell[3].innerHTML = b_del; 
	if (ad) {
	oCell[4].innerHTML = ad; 
	}
}

function new_insertNewRow(a,name,memo,date,b_del,face,ad,dctalk,ip,aclass)                          //여기임 lhk 
{ 

	var oCell = new Array(); 
	ttab = document.getElementById(a);


	//새 행 추가 
	var gRows  = ttab.insertRow(ttab.rows.length); 
	//gRows.onmousedown = function(){selectRow(this)} 
	//gRows.onmouseover = function(){tblMouseOver(this)} 
	//gRows.onmouseout = function(){tblMouseOut(this)} 
	//새 셀(td)추가 
//	gRows.onmouseover=function(){this.style.backgroundColor='#F2F0F9'}
//	gRows.onmouseout=function(){this.style.backgroundColor=''}

	oCell[0] = gRows.insertCell(0); 
	oCell[1] = gRows.insertCell(1); 
	oCell[2] = gRows.insertCell(2); 
	oCell[3] = gRows.insertCell(3); 

	if (ad) {
		oCell[4] = gRows.insertCell(4);
	}

//	oCell[5] = gRows.insertCell(5);
//	oCell[6] = gRows.insertCell(6);
//	oCell[7] = gRows.insertCell(7);

//	oCell[0].vAlign = "top";
//	oCell[1].vAlign = "top";
//	oCell[2].vAlign = "top";
//	oCell[3].vAlign = "top";
//	oCell[4].vAlign = "top";
//	oCell[5].vAlign = "top";
//	oCell[6].vAlign = "top";
//	oCell[7].vAlign = "top";

	oCell[0].align = "left";
	oCell[1].align = "left";
	oCell[2].align = "left";
	oCell[3].align = "left";
//	oCell[4].align = "left";
//	oCell[5].align = "left";
//	oCell[6].align = "left";
//	oCell[7].align = "left";


	oCell[0].className = aclass || "com_name";
	oCell[1].className = "com_text";
	oCell[2].className = "com_ip";
	oCell[3].className = "com_btn";

//	oCell[0].width = "120px";
//	oCell[1].style = 'word-break:break-all;text-align:left;';

	//각셀의 값 입력 
	oCell[0].innerHTML = name + face; 
    //lhk 110221 테이블 수정 
	oCell[1].innerHTML =memo;

	if (ip) {
		oCell[1].innerHTML += '<span class="line">|</span><span class="num2">'+ ip +'</span></div>';
	}
	if (dctalk) {
		oCell[1].innerHTML += '<span style="font-size:11px;color:#999999">[ '+ dctalk +' ]</span>';
	}


	oCell[2].innerHTML = '<span class="num">'+ date +'</span>'; 
	oCell[3].innerHTML = b_del; 

	if (ad) {
		oCell[4].innerHTML = ad; 
	}

//	oCell[4].innerHTML = ; 
//	oCell[5].innerHTML = dctalk;
//	oCell[6].innerHTML = b_del;
//	oCell[7].innerHTML = ad;

//추가된 셀 선택 
//selectRow(gRows) ; 

}

//고소미 이벤트 관련 리플	08.04.22 s.a
function insertNewRow2(a,name,memo,date,b_del,ad) 
	{ 
		var oCell = new Array(); 
		ttab = document.getElementById(a);

		//새 행 추가 
		var gRows  = ttab.insertRow(ttab.rows.length); 

		//새 셀(td)추가 
		gRows.onmouseover=function(){this.style.backgroundColor='#F2F0F9'}
		gRows.onmouseout=function(){this.style.backgroundColor=''}

		oCell[0] = gRows.insertCell(0);	//width=6 blank
		oCell[1] = gRows.insertCell(1); //memo (+b_del)
		oCell[2] = gRows.insertCell(2); //name
		oCell[3] = gRows.insertCell(3); //date (+ad)
		oCell[4] = gRows.insertCell(4); //width=6 blank


		oCell[0].width = "6";

		oCell[1].width = "436";
		oCell[1].align = "left";
		oCell[1].className = "re_css";
		if(b_del)
			oCell[1].innerHTML = memo+" "+b_del;
		else
			oCell[1].innerHTML = memo;

		oCell[2].width = "130";
		oCell[2].align = "center";
		oCell[2].className = "re_css";
		oCell[2].innerHTML = name; 

		oCell[3].width = "78";
		oCell[3].align = "center";
		oCell[3].className = "re_css";
		if(ad)
			oCell[3].innerHTML = date+"<br>"+ad;
		else
			oCell[3].innerHTML = date;

		oCell[4].width = "6";


		var gLines  = ttab.insertRow();
		oLine = gLines.insertCell();
		oLine.colSpan = "5";
		oLine.width = "656"; 
		oLine.height = "1";
		oLine.background = "http://wstatic.dcinside.com/ad/2008/event/080418_gosomi/line_bg.gif"; 
	}

	// 고소미  powero2   lhk
function insertNewRow3(a,name,memo,date,b_del,ad) 
	{ 

 
		var oCell = new Array(); 
		ttab = document.getElementById(a);

		//새 행 추가 
		var gRows  = ttab.insertRow(ttab.rows.length); 

		//새 셀(td)추가 
		

		//oCell[0] = gRows.insertCell(0);	//width=6 blank
		oCell[0] = gRows.insertCell(0); //name
		oCell[1] = gRows.insertCell(1); //memo (+b_del)
		oCell[2] = gRows.insertCell(2); //date (+ad)
		//oCell[4] = gRows.insertCell(4); //width=6 blank


		//oCell[0].width = "6";

		oCell[0].width = "60";
		oCell[0].align = "center";
		oCell[0].className = "re_css3";
		oCell[0].innerHTML = name; 

		oCell[1].width = "274";
		oCell[1].align = "left";
		oCell[1].className = "re_css2";
		if(b_del)
			oCell[1].innerHTML = memo+" "+b_del;
		else
			oCell[1].innerHTML = memo;



		oCell[2].width = "80";
		oCell[2].align = "center";
		oCell[2].className = "re_css3";
		if(ad)
			oCell[2].innerHTML = date+"<br>"+ad;
		else
			oCell[2].innerHTML = date;

		//oCell[4].width = "6";


		var gLines  = ttab.insertRow();
		oLine = gLines.insertCell();
		oLine.colSpan = "5";
		oLine.width = "415"; 
		oLine.height = "1";
		oLine.bgColor = "#022A43";
	}

function insertNewRow4(a,name,memo,date,b_del,ad) 
	{ //lhk 스피드메이트 090630
         
		var oCell = new Array(); 
		ttab = document.getElementById(a);

		var gRows  = ttab.insertRow(ttab.rows.length); 

		
		oCell[0] = gRows.insertCell(0); //name
		oCell[1] = gRows.insertCell(1); //memo (+b_del)
		oCell[2] = gRows.insertCell(2); //date (+ad)

		//oCell[0].width = "6";

		oCell[0].width = "65";
		oCell[0].align = "left";
		oCell[0].className = "id_name";
		oCell[0].innerHTML = name; 

		oCell[1].width = "200";
		oCell[1].align = "left";
		oCell[1].className = "tx_url";
		if(b_del)
			oCell[1].innerHTML = memo+" "+b_del;
		else
			oCell[1].innerHTML = memo;

		oCell[2].width = "65";
		oCell[2].align = "left";
		oCell[2].className = "tx_date";
		if(ad)
			oCell[2].innerHTML = date+"<br>"+ad;
		else
			oCell[2].innerHTML = date;


		var gLines  = ttab.insertRow();
		 oLine = gLines.insertCell();
		oLine.colSpan = "3";
		oLine.width = "300"; 
	
	 
	 
	}
function setPage(id,no,totstr) 
{ 

	tot = document.getElementById("rep_page");
	/*
	preview = document.getElementById(target_tap_page_preview+no);
	next = document.getElementById(target_tap_page_next+no);
	if(p) { 
		preview.href = "javascript:view_comment('"+id+"',"+no+","+p+")"; 
		preview.innerHTML = "<strong>이전</strong>"; 

	}else{ 
		preview.href="#";
		preview.innerHTML = ""; 
	}
	if(n) { 
		next.href = "javascript:view_comment('"+id+"',"+no+","+n+")"; 
		next.innerHTML = "<strong>다음</strong>"; 
	}else*/ 
	if(tot){
		tot.innerHTML = totstr; 
	}else{ 
		next.href = "#";
		next.innerHTML = ""; 
	}
}


function new_setPage(id,no,totstr) 
{ 

	tot = document.getElementById("rep_page");

	if(tot){

		tot.innerHTML = totstr; 
	}else{ 
		next.href = "#";
		next.innerHTML = ""; 
	}
}

function qa_setPage(id,no,totstr) 
{ 

	tot = document.getElementById("rep_page");

	if(tot){

		tot.innerHTML = totstr; 
	}else{ 
		next.href = "#";
		next.innerHTML = ""; 
	}
}



function deleteRow(id){

	var ttab = document.getElementById(id);

 
	trows = ttab.rows.length;

	for(i=0;i<trows;i++){
		ttab.deleteRow(0);		
	}
}



function view_comment(id,no,page){

	deleteRow(target_tab+no); 

	query = "?id=" + id + "&no=" + no + "&page=" + page;
	xmlhttp = XMLHTTP();
	with(xmlhttp) {
		open("GET", "/comment.php"+query , false);
		//setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		send(null);
		xml = responseXML;
	}

	XML_CNT = xml.getElementsByTagName("TOTALCNT");

	XML_COM = xml.getElementsByTagName("COMMENT");
	//alert(XML_DEL.item(0).getAttribute("RESULT"));
	//alert(XML_DEL.item(0).getAttribute("DEBUG"));

	ipage = XML_CNT.item(0).getAttribute("PAGECNT");

	if(!page)
		nCnt = XML_CNT.item(0).getAttribute("CNT");
	else
		nCnt = XML_CNT.item(0).getAttribute("CNT") - ((page-1)*ipage);
	

	var cnt=0;
	for(i=XML_COM.length-1,j=0;i>-1;i--,j++){

		if(id=="reple_event" && no == '1'){	//고소미 이벤트 관련	08.04.22 s.a
			insertNewRow2(target_tab+no,XML_COM.item(i).getAttribute("NAME"),XML_COM.item(i).getAttribute("MEMO"),XML_COM.item(i).getAttribute("REG_DATE"),XML_COM.item(i).getAttribute("A_DEL"),XML_COM.item(i).getAttribute("AD"));
		} else if(id=="reple_event" && no == '2') { //lhk 파워오투 관련 090407
			insertNewRow3(target_tab+no,XML_COM.item(i).getAttribute("NAME"),XML_COM.item(i).getAttribute("MEMO"),XML_COM.item(i).getAttribute("REG_DATE"),XML_COM.item(i).getAttribute("A_DEL"),XML_COM.item(i).getAttribute("AD"));
		} else if(id=="reple_event" && no == '3') { ////어나더데이 파이널테스트 이벤트
			insertNewRow(target_tab+no,XML_COM.item(i).getAttribute("NAME"),XML_COM.item(i).getAttribute("MEMO"),XML_COM.item(i).getAttribute("REG_DATE"),XML_COM.item(i).getAttribute("A_DEL"),XML_COM.item(i).getAttribute("FACE"),XML_COM.item(i).getAttribute("AD"),XML_COM.item(i).getAttribute("DCTALK"));
		}else if(id=="reple_event" && no == '4') { ////스피드메이트
			insertNewRow4(target_tab+no,XML_COM.item(i).getAttribute("NAME"),XML_COM.item(i).getAttribute("MEMO"),XML_COM.item(i).getAttribute("REG_DATE"),XML_COM.item(i).getAttribute("A_DEL"),XML_COM.item(i).getAttribute("FACE"),XML_COM.item(i).getAttribute("AD"),XML_COM.item(i).getAttribute("DCTALK"));
		} 
		else {	
			//insertNewRow(target_tab+no,XML_COM.item(i).getAttribute("NAME"),XML_COM.item(i).getAttribute("MEMO"),XML_COM.item(i).getAttribute("REG_DATE"),XML_COM.item(i).getAttribute("A_DEL"),XML_COM.item(i).getAttribute("FACE"),XML_COM.item(i).getAttribute("AD"),XML_COM.item(i).getAttribute("DCTALK"),XML_COM.item(i).getAttribute("IP"));
			
			insertNewRow(target_tab+no,XML_COM.item(i).getAttribute("NAME"),XML_COM.item(i).getAttribute("MEMO"),XML_COM.item(i).getAttribute("REG_DATE"),XML_COM.item(i).getAttribute("A_DEL"),XML_COM.item(i).getAttribute("FACE"),XML_COM.item(i).getAttribute("AD"),XML_COM.item(i).getAttribute("DCTALK"),XML_COM.item(i).getAttribute("IP"));
		

			//comment advertisement (20081008 ksa)	
			gall_cat = XML_CNT.item(0).getAttribute("CATEGORY");
			ad_src = XML_CNT.item(0).getAttribute("ADSRC");
			iCnt = nCnt-i;

			if(ipage > XML_COM.length)
				ievent = j+1;
			else
				ievent = iCnt;

			//gall_cat(gallery category)값이 있을 경우 댓글돌이 출력하도록 수정(090227 KSA)
			if((0==iCnt%10) && gall_cat!=0)
			{	
				if(iCnt==10 || (0==iCnt%50))
				{
					if(gall_cat=="18" || gall_cat=="19" || id=="hit" || true)
					{
						strEventMemo = "<table><tr><td><strong>댓글 "+ievent+"개 돌파!!</strong></td><td style='padding-left:5px'><iframe src='http://gall.dcinside.com/ad/rdory_ad.php?strAdComment="+ad_src+"' frameborder='0' marginwidth='0' marginheight='0' topmargin='0' scrolling='no' width='250' height='25' allowtransparency='true'></iframe></td></tr></table>";

						insertNewRow(target_tab+no, "<table><tr></tr><tr><td valign=top><strong>댓글돌이</strong><img src='http://wstatic.dcinside.com/ad/2008/etc/dog.gif' border=0 style='margin-left:4px;'></td></tr></table>", strEventMemo, "", "", "", "", "");
					}
					else
					{
						strEventMemo = "<strong>댓글 "+ievent+"개 돌파!!</strong>";
						insertNewRow(target_tab+no, "<strong>댓글돌이</strong><img src='http://wstatic.dcinside.com/ad/2008/etc/dog.gif' border=0 style='margin-left:4px;'>", strEventMemo, "", "", "", "", "");
					}
				}
			}
		}
		cnt++;
	}

	XML_PAGE = xml.getElementsByTagName("PAGE");
	//if(XML_PAGE.item(0).getAttribute("NEXT")) alert(XML_PAGE.item(0).getAttribute("NEXT"));
	//pp = XML_PAGE.item(0).getAttribute("PREVIEW");
	//pn = XML_PAGE.item(0).getAttribute("NEXT");
	tot = XML_PAGE.item(0).getAttribute("TOTAL");
	//tc = XML_PAGE.item(0).getAttribute("TC");
	//document.getElementById("tc_span").innerHTML = "("+tc+")";
	//alert(tot);
	setPage(id,no,tot);
	//if(XML_DEL.item(0).getAttribute("RESULT")=="1") return XML_DEL.item(0).getAttribute("FINDIMG");
	//	parent.resizeCaller();	
	document.write_com.memo.value ='';
	try{
		if(id=='reple_event' && no==3) iframe_resize();
	}catch(e){}
}



function new_view_comment2(id,no,page){
	var rand_no = Math.round(Math.random()); // 댓글돌이 & 다나와 랜덤 
	
	deleteRow(target_tab+no); 
	query = "?id=" + id + "&no=" + no + "&page=" + page;
	xmlhttp = XMLHTTP();
	with(xmlhttp) {
		open("GET", "/comment_4.php"+query , false);
		//setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		send(null);
		xml = responseXML;
	}


	XML_CNT = xml.getElementsByTagName("TOTALCNT");

	XML_COM = xml.getElementsByTagName("COMMENT");

	ipage = XML_CNT.item(0).getAttribute("PAGECNT");

	if(!page)
		nCnt = XML_CNT.item(0).getAttribute("CNT");
	else
		nCnt = XML_CNT.item(0).getAttribute("CNT") - ((page-1)*ipage);
	

	var cnt=0;
	for(i=XML_COM.length-1,j=0;i>-1;i--,j++){

		if(id=="reple_event" && no == '1'){	//고소미 이벤트 관련	08.04.22 s.a
			insertNewRow2(target_tab+no,XML_COM.item(i).getAttribute("NAME"),XML_COM.item(i).getAttribute("MEMO"),XML_COM.item(i).getAttribute("REG_DATE"),XML_COM.item(i).getAttribute("A_DEL"),XML_COM.item(i).getAttribute("AD"));
		}else if(id=="reple_event" && no == '2') { //lhk 파워오투 관련 090407
			insertNewRow3(target_tab+no,XML_COM.item(i).getAttribute("NAME"),XML_COM.item(i).getAttribute("MEMO"),XML_COM.item(i).getAttribute("REG_DATE"),XML_COM.item(i).getAttribute("A_DEL"),XML_COM.item(i).getAttribute("AD"));
		}
		else {	
			new_insertNewRow2(target_tab+no,XML_COM.item(i).getAttribute("NAME"),XML_COM.item(i).getAttribute("MEMO"),XML_COM.item(i).getAttribute("REG_DATE"),XML_COM.item(i).getAttribute("A_DEL"),XML_COM.item(i).getAttribute("FACE"),XML_COM.item(i).getAttribute("AD"),XML_COM.item(i).getAttribute("DCTALK"),XML_COM.item(i).getAttribute("IP"));

			gall_cat = XML_CNT.item(0).getAttribute("CATEGORY");
			ad_src = XML_CNT.item(0).getAttribute("ADSRC");
			iCnt = nCnt-i;

			if(ipage > XML_COM.length)
				ievent = j+1;
			else
				ievent = iCnt;


			//gall_cat(gallery category)값이 있을 경우 댓글돌이 출력하도록 수정(090227 KSA)
			if((0==iCnt%10))
			{	
				if(iCnt==10 || (0==iCnt%50))
				{
					if(gall_cat=="18" || gall_cat=="19" || id=="hit" || true)
					{
							
							if(rand_no =='0'){
								var danawa_rand = Math.floor( (Math.random() * (3 - 0 + 1)) + 0 ); // 다나와 랜덤
								var title = document.getElementById('hidden_danawa_title_'+danawa_rand).value;
								var link = document.getElementById('hidden_danawa_link_'+danawa_rand).value;
								
								if(id == 'exam_new' || id == 'languageexam' || id == 'societyexam' || id == 'englishexam' || id == 'exam_2004' || id == 'readingroom' || id == 'preparatoryschool' || id == 'ne' || id == 'mathexam' || id == 'mathexam' || id == 'itlecture'){
									strEventMemo= "<div style='float:left;font: normal 13px/1.3 굴림;padding-top:5px'><strong>댓글 "+ievent+"개 돌파!!</strong></div><td style='padding-left:5px'><div style='float:left;padding-left:10px;padding-top:4px;'><strong><a href="+link+" target=_blank>"+title+"</a></strong></div>";
								}else{
									strEventMemo= "<div style='float:left;font: normal 13px/1.3 굴림;padding-top:5px'><strong>댓글 "+ievent+"개 돌파!!</strong></div><td style='padding-left:5px'><div style='float:left;padding-left:10px;padding-top:4px;'><strong><a href="+link+" target=_blank>"+title+"<img src=http://gall.dcinside.com/images/110915_digital.gif style=padding-left:10px;padding-bottom:2px; ></a></strong></div>";
								}

							}else{
								strEventMemo = "<div style='float:left;font: normal 13px/1.3 굴림;padding-top:5px'><strong>댓글 "+ievent+"개 돌파!!!</strong></div><td style='padding-left:5px'><div style='float:left;padding-left:5px'><iframe src='http://gall.dcinside.com/ad/rdory_ad.php?strAdComment="+ad_src+"' frameborder='0' marginwidth='0' marginheight='0' topmargin='0' scrolling='no' width='250' height='25' allowtransparency='true'></iframe></div>";	
							}

							strEventMemo1	=	"<tr>"
														+	"	<td valign=middle style='text-align:left;font: normal 13px/1.2 굴림;color:#000000' class='com_text;' >댓글돌이<img src='http://wstatic.dcinside.com/ad/2008/etc/dog.gif' border=0 style='margin-left:4px;'></td>"
														+	"	<td valign=top style='word-break:break-all' style='text-align:left;'></td>"
														+	"	<td colspan='4'></td>"
														+	"</tr>";

						new_insertNewRow2(target_tab+no, strEventMemo1, strEventMemo, "", "", "", "", "", "", "com_reply");
					}
					else
					{
						strEventMemo = "<strong>댓글 "+ievent+"개 돌파!!</strong>";
						new_insertNewRow2(target_tab+no, "<strong>댓글돌이</strong><img src='http://wstatic.dcinside.com/ad/2008/etc/dog.gif' border=0 style='margin-left:4px;'>", strEventMemo, "", "", "", "", "");
					}
				}
			}
		}
		cnt++;
	}

	XML_PAGE = xml.getElementsByTagName("PAGE");
	tot = XML_PAGE.item(0).getAttribute("TOTAL");
	new_setPage(id,no,tot);
	document.getElementById('write_com').memo.value ='';
}

//브라운 이벤트 완료후
function new_view_comment3(id,no,page){

	query = "?id=" + id + "&no=" + no + "&page=" + page + "&event=7";
	xmlhttp = XMLHTTP();
	with(xmlhttp) {
		open("GET", "/comment.php"+query , false);
		//setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		send(null);
		txt = responseText;
	}
	document.getElementById('cList').innerHTML = txt;
}

function new_view_comment(id,no,page){

	deleteRow(target_tab+no); 
	query = "?id=" + id + "&no=" + no + "&page=" + page;
	xmlhttp = XMLHTTP();
	with(xmlhttp) {
		open("GET", "/comment_3.php"+query , false);
		//setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		send(null);
		xml = responseXML;
	}


	XML_CNT = xml.getElementsByTagName("TOTALCNT");

	XML_COM = xml.getElementsByTagName("COMMENT");
	//alert(XML_DEL.item(0).getAttribute("RESULT"));
	//alert(XML_DEL.item(0).getAttribute("DEBUG"));

	ipage = XML_CNT.item(0).getAttribute("PAGECNT");

	if(!page)
		nCnt = XML_CNT.item(0).getAttribute("CNT");
	else
		nCnt = XML_CNT.item(0).getAttribute("CNT") - ((page-1)*ipage);
	

	var cnt=0;
	for(i=XML_COM.length-1,j=0;i>-1;i--,j++){

		if(id=="reple_event" && no == '1'){	//고소미 이벤트 관련	08.04.22 s.a
			insertNewRow2(target_tab+no,XML_COM.item(i).getAttribute("NAME"),XML_COM.item(i).getAttribute("MEMO"),XML_COM.item(i).getAttribute("REG_DATE"),XML_COM.item(i).getAttribute("A_DEL"),XML_COM.item(i).getAttribute("AD"));
		}else if(id=="reple_event" && no == '2') { //lhk 파워오투 관련 090407
			insertNewRow3(target_tab+no,XML_COM.item(i).getAttribute("NAME"),XML_COM.item(i).getAttribute("MEMO"),XML_COM.item(i).getAttribute("REG_DATE"),XML_COM.item(i).getAttribute("A_DEL"),XML_COM.item(i).getAttribute("AD"));
		}
		else {	
			new_insertNewRow(target_tab+no,XML_COM.item(i).getAttribute("NAME"),XML_COM.item(i).getAttribute("MEMO"),XML_COM.item(i).getAttribute("REG_DATE"),XML_COM.item(i).getAttribute("A_DEL"),XML_COM.item(i).getAttribute("FACE"),XML_COM.item(i).getAttribute("AD"),XML_COM.item(i).getAttribute("DCTALK"),XML_COM.item(i).getAttribute("IP"));

			//comment advertisement (20081008 ksa)	
			gall_cat = XML_CNT.item(0).getAttribute("CATEGORY");
			ad_src = XML_CNT.item(0).getAttribute("ADSRC");
			iCnt = nCnt-i;

			if(ipage > XML_COM.length)
				ievent = j+1;
			else
				ievent = iCnt;



			//	10주년 인벤트 페이지는 댓글돌이 미노출
		

				//gall_cat(gallery category)값이 있을 경우 댓글돌이 출력하도록 수정(090227 KSA)
				if((0==iCnt%10))
				{	
					if(iCnt==10 || (0==iCnt%50))
					{
						if(gall_cat=="18" || gall_cat=="19" || id=="hit" || true)
						{

	//						insertNewRow(target_tab+no, "<strong>댓글돌이</strong><img src='http://wstatic.dcinside.com/ad/2008/etc/dog.gif' border=0 style='margin-left:4px;'>", strEventMemo, "", "", "", "", "");
	/*
								strEventMemo = "<table class='comment-table1'>"
														+	"	<tr>"
														+	"		<td><strong>댓글 "+ievent+"개 돌파!!</strong></td><td style='padding-left:5px'><iframe src='http://gall.dcinside.com/ad/rdory_ad.php?strAdComment="+ad_src+"' frameborder='0' marginwidth='0' marginheight='0' topmargin='0' scrolling='no' width='250' height='25' allowtransparency='true'></iframe></td>"
														+	"	</tr>"
														+	"</table>";
	*/
								strEventMemo = "<div style='float:left;font: normal 13px/1.3 굴림;padding-top:5px'><strong>댓글 "+ievent+"개 돌파!!</strong></div><td style='padding-left:5px'><div style='float:left;padding-left:5px'><iframe src='http://gall.dcinside.com/ad/rdory_ad.php?strAdComment="+ad_src+"' frameborder='0' marginwidth='0' marginheight='0' topmargin='0' scrolling='no' width='250' height='25' allowtransparency='true'></iframe></div>";	

								strEventMemo1	=	"<tr>"
															+	"	<td valign=middle style='text-align:left;font: normal 13px/1.2 굴림;color:#000000' class='com_text;' >댓글돌이<img src='http://wstatic.dcinside.com/ad/2008/etc/dog.gif' border=0 style='margin-left:4px;'></td>"
															+	"	<td valign=top style='word-break:break-all' style='text-align:left;'></td>"
															+	"	<td colspan='3'></td>"
															+	"</tr>";

							new_insertNewRow(target_tab+no, strEventMemo1, strEventMemo, "", "", "", "", "", "", "com_reply");
						}
						else
						{
							strEventMemo = "<strong>댓글 "+ievent+"개 돌파!!</strong>";
							new_insertNewRow(target_tab+no, "<strong>댓글돌이</strong><img src='http://wstatic.dcinside.com/ad/2008/etc/dog.gif' border=0 style='margin-left:4px;'>", strEventMemo, "", "", "", "", "");
						}
					}
				}
			



		}
		cnt++;
	}

	XML_PAGE = xml.getElementsByTagName("PAGE");
	//if(XML_PAGE.item(0).getAttribute("NEXT")) alert(XML_PAGE.item(0).getAttribute("NEXT"));
	//pp = XML_PAGE.item(0).getAttribute("PREVIEW");
	//pn = XML_PAGE.item(0).getAttribute("NEXT");
	tot = XML_PAGE.item(0).getAttribute("TOTAL");
	//tc = XML_PAGE.item(0).getAttribute("TC");
	//document.getElementById("tc_span").innerHTML = "("+tc+")";
	//alert(tot);
	new_setPage(id,no,tot);
	//if(XML_DEL.item(0).getAttribute("RESULT")=="1") return XML_DEL.item(0).getAttribute("FINDIMG");
	//	parent.resizeCaller();	
	document.getElementById('write_com').memo.value ='';
}


function qa_view_comment(id,no,page){


	document.getElementById("repleTotal").innerHTML		=	"0";

	try
	{
		if (document.getElementById("nate_chk").value == "true")
		{
			document.getElementById("memo").style.background	=	"url(http://wstatic.dcinside.com/gallery/skin/skin_qa/images/qna/bg_form1.gif) #fff no-repeat 3px 3px";
		}
		document.getElementById("memo").style.height			=	"100px";
	}
	catch (e)
	{
	}

	deleteRow(target_tab+no); 
	query = "?id=" + id + "&no=" + no + "&page=" + page;
	xmlhttp = XMLHTTP();
	with(xmlhttp) {
		open("GET", "/comment_3_qa.php"+query , false);
		send(null);
		xml = responseXML;
	}

	XML_CNT		= xml.getElementsByTagName("TOTALCNT");
	XML_COM		= xml.getElementsByTagName("COMMENT");

	ipage = XML_CNT.item(0).getAttribute("PAGECNT");

	if(!page)
		nCnt = XML_CNT.item(0).getAttribute("CNT");
	else
		nCnt = XML_CNT.item(0).getAttribute("CNT") - ((page-1)*ipage);
	
	var cnt=0;

	for(i=XML_COM.length-1,j=0;i>-1;i--,j++){
		
		XML_MEMO	= xml.getElementsByTagName("NEWMEMO").item(i).firstChild.nodeValue;
		XML_NNO		= xml.getElementsByTagName("NEWNO").item(i).firstChild.nodeValue;

		qa_insertNewRow(target_tab+no,XML_COM.item(i).getAttribute("NAME"),XML_COM.item(i).getAttribute("MEMO"),XML_COM.item(i).getAttribute("REG_DATE"),XML_COM.item(i).getAttribute("A_DEL"),XML_COM.item(i).getAttribute("FACE"),XML_COM.item(i).getAttribute("AD"),XML_COM.item(i).getAttribute("DCTALK"),XML_COM.item(i).getAttribute("IP"),'',XML_MEMO, XML_NNO);

		gall_cat = XML_CNT.item(0).getAttribute("CATEGORY");
		ad_src = XML_CNT.item(0).getAttribute("ADSRC");
		iCnt = nCnt-i;

		if(ipage > XML_COM.length)
			ievent = j+1;
		else
			ievent = iCnt;

		if((0==iCnt%10))
		{	
			if(iCnt==10 || (0==iCnt%50))
			{
				strEventMemo = "<div style='float:left;font: normal 13px/1.3 굴림;padding-top:5px'><strong>댓글 "+ievent+"개 돌파!!</strong></div><td style='padding-left:5px;border-bottom:0px solid #FFFFFF'><div style='float:left;padding-left:5px'><iframe src='http://gall.dcinside.com/ad/rdory_ad.php?strAdComment="+ad_src+"' frameborder='0' marginwidth='0' marginheight='0' topmargin='0' scrolling='no' width='250' height='25' allowtransparency='true'></iframe></div>";	

				strEventMemo1	=	"<tr>"
											+	"	<td valign=middle style='text-align:left;font: normal 13px/1.2 굴림;color:#000000;border-bottom:0px solid #FFFFFF' class='com_text;' ><strong>댓글돌이</strong><img src='http://wstatic.dcinside.com/ad/2008/etc/dog.gif' border=0 style='margin-left:4px;'></td>"
											+	"	<td valign=top style='word-break:break-all' style='text-align:left;border-bottom:0px solid #FFFFFF'></td>"
											+	"	<td colspan='3' style='border-bottom:0px solid #FFFFFF'></td>"
											+	"</tr>";

				qa_insertNewRow(target_tab+no, strEventMemo1, strEventMemo, "", "", "", "", "", "", "com_reply");
			}
		}
		cnt++;
	}

	XML_PAGE = xml.getElementsByTagName("PAGE");
	tot = XML_PAGE.item(0).getAttribute("TOTAL");
	qa_setPage(id,no,tot);
	document.getElementById('write_com').memo.value ='';
}


function write_comment(id,no,tform,type){
	if(document.getElementById("rName") != null&&!tform.name.value) {alert('이름을 입력해 주십시오.');tform.name.focus();return false;}
	if(document.getElementById("rPwd") != null&&!tform.password.value) {alert('비밀번호를 입력해 주십시오.');tform.password.focus();return false;}
	if(!tform.memo.value) {alert('내용을 입력해 주십시오.');tform.memo.focus();return false;}

	var filters = checkfilter();

	
	tform.method = "POST";		
	tform.action = "/comment_ok.php";
	tform.target = "rWriteForm";
	tform.submit();
	//tform.memo.value = "";
}


var onlyOneHit = false; // 중복 변수


function new_write_comment(id,no,tform,type){

	if(document.getElementById("name") != null && !document.getElementById("name").value) {
		alert('이름을 입력해 주십시오.');
		document.getElementById("name").focus();
		return false;
	}
	else if(document.getElementById("password") != null&&!document.getElementById("password").value) {
		alert('비밀번호를 입력해 주십시오.');
		document.getElementById("password").focus();
		return false;
	}
	else if(!document.getElementById("memo").value) {
		alert('내용을 입력해 주십시오.');
		document.getElementById("memo").focus();
		return false;
	}
	else {
         if(document.getElementById("name")) {
        document.getElementById("name").value = document.getElementById("name").value.replace(/\s/g, "");
        }
        return true;
	}
}

function new_write_comment_hk(id,no,tform,type){        //lhk 110318

	if(document.getElementById("name") != null && !document.getElementById("name").value) {
		alert('이름을 입력해 주십시오.');
		document.getElementById("name").focus();
		return false ;
	} else if(document.getElementById("password") != null&&!document.getElementById("password").value) {
		alert('비밀번호를 입력해 주십시오.');
		document.getElementById("password").focus();
		return false;
	} else if(!document.getElementById("memo").value) {
		alert('내용을 입력해 주십시오.');
		document.getElementById("memo").focus();
		return false;
	} else {
		if(onlyOneHit){
		// alert('이미전송했습니다.');
			return false;
		}
		
		document.getElementById("memo").blur();
		document.getElementById("memo").value = document.getElementById("memo").value.replace("\r\n", "");
		
		if(document.getElementById("name")) {
			document.getElementById("name").value = document.getElementById("name").value.replace(/\s/g, "");
		}
		
		onlyOneHit = true;
		return true;
		//document.write_com.submit();

	}
}

function new_write_comment_hk2(id,no,tform,type){       //lhk 110318

	if(document.getElementById("name") != null && !document.getElementById("name").value) {
		alert('이름을 입력해 주십시오.');
		document.getElementById("name").focus();
		return false;
	}
	else if(document.getElementById("password") != null&&!document.getElementById("password").value) {
		alert('비밀번호를 입력해 주십시오.');
		document.getElementById("password").focus();
		return false ;
	}
	else if(!document.getElementById("memo").value) {
		alert('내용을 입력해 주십시오.');
		document.getElementById("memo").focus();
		return false ;
	}
	else {

        if(onlyOneHit){
        return false ;
        }

   document.getElementById("memo").blur();
        document.getElementById("memo").value = document.getElementById("memo").value.replace("\r\n", "");
        if(document.getElementById("name")) {
        document.getElementById("name").value = document.getElementById("name").value.replace(/\s/g, "");
        }
  		document.write_com.method = "POST";
		document.write_com.action = "/comment_ok.php";
		document.write_com.target = "rWriteForm";
	    document.write_com.submit();

	}
}
function new_write_comment_hk_recomm(id,no,tform,type){         //lhk 110318

	if(document.getElementById("name") != null && !document.getElementById("name").value) {
		alert('이름을 입력해 주십시오.');
		document.getElementById("name").focus();
		return false;
	}
	else if(document.getElementById("password") != null&&!document.getElementById("password").value) {
		alert('비밀번호를 입력해 주십시오.');
		document.getElementById("password").focus();
		return false;
	}
	else if(!document.getElementById("memo").value) {
		alert('내용을 입력해 주십시오.');
		document.getElementById("memo").focus();
		return false;
	}
	else {
        
        if(onlyOneHit){
        return false ;
        }

        join_recommend();
        document.getElementById("memo").blur();
        document.getElementById("memo").value = document.getElementById("memo").value.replace("\r\n", "");
        if(document.getElementById("name")) {
        document.getElementById("name").value = document.getElementById("name").value.replace(/\s/g, "");
        }

  		document.write_com.method = "POST";
		document.write_com.action = "/comment_ok.php";
		document.write_com.target = "rWriteForm";
	    document.write_com.submit();
        

	}
}

function nextSubmit() {             //lhk 110428 연속등록 방지
	setTimeout("onlyOneHit = false", 2000); 
}



function new_write_height_fire() {

  
        
        var cnt	=	$("#memo").val().length || 0;

        if(cnt > 400  ) {
   
         
             $('#memo').blur();
            ls_str2 = $('#memo').val().substr(0, 400); 
            $("#memo").val(ls_str2);
            $('#memo').focus();
             return false;
            
        }
        else {
            temp	=	$("#memo").val();
            oldCnt	=	cnt;
            return true;
        }


}
function new_write_height() {
var temp	= "";
var oldCnt	= "";
		$('#memo').css('height', '40px');
     
				if (($('#memo').attr('scrollHeight') *1) > 45   ) {
					$('#memo').css('height', $('#memo').attr('scrollHeight')) ;

				}
  
        
				var cnt	=	$("#memo").val().length || 0;


				if(cnt > 400 ) {
                   if(event.keyCode!="13"){
					 alert("글자수 제한이 있습니다.");
                   }
					 $('#memo').blur();
                    ls_str2 = $('#memo').val().substr(0, 400); 
					$("#memo").val(ls_str2);
                    $('#memo').focus();
 
                    
				}
				else {
					temp	=	$("#memo").val();
					oldCnt	=	cnt;
            
				}


/*
 var tar = document.getElementsByTagName('textarea');
       var obj = document.getElementById("memo");   
       var maxLength = obj.getAttribute('maxlength');
    

    if(obj.style.height < obj.scrollHeight) 
    { alert(obj.style.height);
        if( obj.scrollHeight > 40){
        obj.style.height = obj.scrollHeight+20; 
        }

    }
    

       
     if(obj.value.length > maxLength) {
       alert( maxLength + " 글자를 초과 입력할수 없습니다."); 
       obj.value= obj.value.substring(0,maxLength);
        
        }
*/
/*
      var tar = document.getElementsByTagName('textarea');
       var obj = document.getElementById("memo");   
       var ari_max = obj.getAttribute('maxlength');
    
  var ls_str    = obj.value; // 이벤트가 일어난 컨트롤의 value 값 
  var li_str_len =ls_str.length; 
  var aro_name = document.getElementById("memo");   

    if(obj.clientHeight < obj.scrollHeight) 
    { 
        if( obj.scrollHeight > 40){
        obj.style.height = obj.scrollHeight+20; 
        }

    }

      
  var li_max      = ari_max; // 제한할 글자수 크기 
  var i          = 0;  // for문에 사용 
  var li_byte    = 0;  // 한글일경우는 2 그밗에는 1을 더함 
  var li_len      = 0;  // substring하기 위해서 사용 
  var ls_one_char = ""; // 한글자씩 검사한다 
  var ls_str2    = ""; // 글자수를 초과하면 제한할수 글자전까지만 보여준다. 

  for(i=0; i< li_str_len; i++) 
  { 
      // 한글자추출 
      ls_one_char = ls_str.charAt(i); 

      // 한글이면 2를 더한다. 
      if (escape(ls_one_char).length > 4) 
      { 
        li_byte = li_byte+2; 
      } 
      // 그외의 경우는 1을 더한다. 
      else 
      { 
        li_byte++; 
      } 

      // 전체 크기가 li_max를 넘지않으면 
      if(li_byte <= li_max) 
      { 
        li_len = i + 1; 
      } 
  } 
  
  // 전체길이를 초과하면 li_byte 

  if(li_byte > li_max) 
  { 
      aro_name.value=li_byte; 
    //  alert( li_max + " 글자를 초과 입력할수 없습니다."); 
      aro_name.blur();
      ls_str2 = ls_str.substr(0, li_len); 
      aro_name.value = ls_str2; 
  } 
  aro_name.focus();  
 
*/

 
}

function qa_write_comment(id,no,tform,type){

	if(document.getElementById("name") != null && !document.getElementById("name").value) {
		alert('이름을 입력해 주십시오.');
		document.getElementById("name").focus();
		return false;
	}
	else if(document.getElementById("password") != null&&!document.getElementById("password").value) {
		alert('비밀번호를 입력해 주십시오.');
		document.getElementById("password").focus();
		return false;
	}
	else if(!document.getElementById("memo").value) {
		alert('내용을 입력해 주십시오.');
		document.getElementById("memo").focus();
		return false;
	}
	else {
		document.getElementById("repleTotal").innerHTML	=	"0";
		document.getElementById("memo").style.height = "100px";
		return true;
	}
}


function filterling( memo,filter ){
	var objRegExp = new RegExp(filter,"gi"); 
	if(objRegExp.test(memo)) {return true;}
	else {return false;}
}


//고소미 이벤트(dc_reple/_reple2.php 에서 사용)
function write_comment_event(mem_no,id,no,tform,type){
	if(document.getElementById("rName") != null&&!tform.name.value) {alert('이름을 입력해 주십시오.');tform.name.focus();return false;}
	if(document.getElementById("rPwd") != null&&!tform.password.value) {alert('비밀번호를 입력해 주십시오.');tform.password.focus();return false;}
	if(!tform.memo.value) {alert('내용을 입력해 주십시오.');tform.memo.focus();return false;}

	if(mem_no!=""){	//고소미 이벤트 회원일 경우
		tform.method = "POST";
		tform.action = "/comment_ok.php";
		tform.target = "rWriteForm";
		tform.submit();
		tform.memo.value = "";
	}else{ //고소미 이벤트 비회원 배송정보 입력 관련 부분
		if(document.getElementById("namecheck_pass").value!="namecheck_pass" && document.getElementById("chk_ukey").value==""){
			alert("실명 인증을 하셔야 합니다."); return false;
		}else{
			if(id=="reple_event"){
				if(document.getElementById("rSendFlag").value != "Y" )
				{
					alert('비회원이신 경우 배송정보를 입력해 주셔야 합니다');
					window.open("http://gall.dcinside.com/revent_etcInfo.php", "", "width=370,height=270,top=50,left=80,status=no,scrollbars=no,resizable=no,location=no,menubar=no,toolbar=no");
				}
			}
		}
	}
}

function write_comment_event2(mem_no,id,no,tform,type){  // 파워오투 lhk 090406

	if(document.getElementById("rPwd") != null&&!tform.password.value) {alert('비밀번호를 입력해 주십시오.');tform.password.focus();return false;}
	if(!tform.memo.value) {alert('내용을 입력해 주십시오.');tform.memo.focus();return false;}
    
	if(mem_no!=""){	//고소미 이벤트 회원일 경우
		tform.method = "POST";
		tform.action = "/comment_ok.php";
		tform.target = "rWriteForm";
		tform.submit();
		tform.memo.value = "";
	}else{ //고소미 이벤트 비회원 배송정보 입력 관련 부분
		if(document.getElementById("namecheck_pass").value!="namecheck_pass" && document.getElementById("chk_ukey").value==""){
			alert("실명 인증을 하셔야 합니다."); return false;
		}else{
			if(id=="reple_event"){
				if(document.getElementById("rSendFlag").value != "Y" )
				{
					alert('배송정보를 입력해 주셔야 합니다');
					window.open("http://gall.dcinside.com/revent_etcInfo.php", "", "width=370,height=270,top=50,left=80,status=no,scrollbars=no,resizable=no,location=no,menubar=no,toolbar=no");
				}
			}
		}
	}
}

function write_comment_event3(id,no,tform,type){  // 스피드메이트 090626
	if(document.getElementById("name") != null&&!tform.name.value) {alert('이름을 입력해 주십시오.');tform.name.focus();return false;}
	if(document.getElementById("rEmail1") != null&&!tform.rEmail1.value) {alert('이메일주소를 입력해 주십시오.');tform.rEmail1.focus();return false;}
	if(!tform.memo.value) {alert('내용을 입력해 주십시오.');tform.memo.focus();return false;}

	var filters = checkfilter();

	
	tform.method = "POST";		
	tform.action = "/comment_ok.php";
	tform.target = "rWriteForm";
	tform.submit();
	//tform.memo.value = "";
}

function write_comment_event4(id,no,tform,type){  // 브라운 면도기 091029
	if(document.getElementById("name") != null&&!tform.name.value) {alert('닉네임을 입력해 주십시오.');tform.name.focus();return false;}
	if(document.getElementById("rPhone1") != null&&!tform.rPhone1.value) {alert('전화번호를 입력해 주십시오.');tform.rPhone1.focus();return false;}
	if(isNaN(tform.rPhone1.value)) {alert('전화번호는 숫자만 입력가능합니다. (하이픈(-), 띄어쓰기 불가. 숫자만 허용)');tform.rPhone1.focus();return false;}
	if(document.getElementById("memo") != null&&!tform.memo.value) {alert('응모내용을 입력해 주십시오.');tform.memo.focus();return false;}

	var filters = checkfilter();

	tform.method = "POST";		
	tform.action = "/comment_ok.php";
	tform.target = "rWriteForm";
	tform.submit();
	tform.memo.value = "";
}

// 숫자만 입력
function fnCheckNum(str) { 
	var reg = /[^0-9]/g; 
	document.getElementById("rPhone1").value = String(str).replace(reg,''); 
} 

//고소미 이벤트(비회원이 배송정보를 입력 한 후에 처리 됨)
function pro_comment(){
	mForms = document.write_com;

	mForms.method = "POST";
	mForms.action = "/comment_ok.php";
	mForms.target = "rWriteForm";
	mForms.submit();
	mForms.memo.value = "";
	mForms.repleReal_name.value = "";
	mForms.rAddr.value = "";
	mForms.rHp.value = "";
	mForms.rEmail.value = "";
	mForms.rSendFlag.value = "N";
}




//채팅방을 만드는 곳으로 이동
function chat_write_comment(id,no,tform,type){
//	alert('');
	if(document.getElementById("rName") != null&&!tform.name.value) {alert('이름을 입력해 주십시오.');tform.name.focus();return false;}
	if(document.getElementById("rPwd") != null&&!tform.password.value) {alert('비밀번호를 입력해 주십시오.');tform.password.focus();return false;}
	if(!tform.memo.value) {alert('내용을 입력해 주십시오.');tform.memo.focus();return false;}

	var filters = checkfilter();

	for(i=0;i<filters.length;i++){
		if(filterling(tform.memo.value,filters[i])){
			alert(filters[i]+"은(는) 등록하기에 적합한 단어가 아닙니다");
			return false;
		}
	}

	
		tform.method = "POST";		
		tform.action = "/comment_ok_chat.php";
		tform.target = "rWriteForm";
		tform.submit();
		tform.memo.value = "";
}


// 코멘트 - 메세지 창 출력시 내용란의 글이 사라지는 것을 방지
function write_comment_chk(id,no,tform,type,filter){
	if(document.getElementById("rName") != null&&!tform.name.value) {alert('이름을 입력해 주십시오.');tform.name.focus();return false;}
	if(document.getElementById("rPwd") != null&&!tform.password.value) {alert('비밀번호를 입력해 주십시오.');tform.password.focus();return false;}
	if(!tform.memo.value) {alert('내용을 입력해 주십시오.');tform.memo.focus();return false;}

	//욕설체크
	var FilterSplit = filter.split(",");
	var text_check = tform.memo.value;
	for(i=0;i<FilterSplit.length;i++){
		r_chk = text_check.search(FilterSplit[i]);
		if(r_chk!=-1){alert(text_check + ' 은(는) 등록하기에 적합한 단어가 아닙니다');tform.memo.focus();return false;}
	}

	tform.method = "POST";
	tform.action = "/comment_ok.php";
	tform.target = "rWriteForm";
	tform.submit();

	tform.memo.value="";
			
}

function write_comment2(id,no,tform,type){
	//070918 roach 폐기
	if(!tform.memo.value) {alert('내용을 입력하세요');tform.memo.focus();return false;}
	try{

		query = "?id=" + id + "&no=" + no +  "&memo=" + encodeURIComponent(memo) + "&type=" + type + 
			"&nologin=" + ((document.getElementById("nologin") == null) ? "" : document.getElementById("nologin").checked ) +
			"&nolog=" + ((document.getElementById("nolog") == null) ? "" : document.getElementById("nolog").checked )
		xmlhttp = XMLHTTP();
		with(xmlhttp) {
			open("GET", "/comment_ok.php"+query, false);
			setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			send(query);
			xml = responseXML;
		}

		XML_RES = xml.getElementsByTagName("COMMENTOK");


			if(XML_RES.item(0).getAttribute("RESULT")=="1"){
				tform.memo.value = "";
				view_comment(id,no,1);
			}else if(XML_RES.item(0).getAttribute("RESULT")=="11"){

				alert(XML_RES.item(0).getAttribute("ALERT"));
			}
	}catch(e){
		return false;
	}
}


  function show_delbox(c_no){
	 //디시태그 패스워드박스 임시 getMousePosition 호출
	document.getElementById("del_form").c_no.value=c_no;
	document.getElementById("del_form").del_password.value="";
	dbox = document.getElementById("delbox");
	dbox.style.left = _x-220+"px";
	if(navigator.appName !="Netscape") {
		if(GEID('GalleryMainDiv')){
			if(GEID('GalleryMainDiv').scrollTop) _y = _y + parseInt(GEID('GalleryMainDiv').scrollTop);	
		}
	}
	dbox.style.top  = _y+"px";
	dbox.style.visibility='visible';
  }

  function show_delbox_braunEvt(c_no){
	document.getElementById("del_form").c_no.value=c_no;
	document.getElementById("del_form").del_password.value="";
	dbox = document.getElementById("delbox");
	dbox.style.left = _x-120+"px";
	if(navigator.appName !="Netscape") {
		if(GEID('GalleryMainDiv')){
			if(GEID('GalleryMainDiv').scrollTop) _y = _y + parseInt(GEID('GalleryMainDiv').scrollTop);	
		}
	}
	dbox.style.top  = _y+"px";
	dbox.style.visibility='visible';
  }

   function show_delbox1(c_no){
	document.getElementById("del_form").c_no.value=c_no;
	document.getElementById("del_form").del_password.value="";
	dbox = document.getElementById("delbox");
	dbox.style.left = _x-220+"px";	
	dbox.style.top  = _y+"px";
	dbox.style.visibility='visible';
  }

  //고소미 이벤트, 리플 삭제 비번 입력 창 부분	08.04.29 s.a
  function show_delbox_rEvent(c_no){
	document.getElementById("del_form").c_no.value=c_no;
	document.getElementById("del_form").del_password.value="";
	dbox = document.getElementById("delbox");
	dbox.style.left = _x+"px";
	dbox.style.top  = _y+"px";
	dbox.style.visibility='visible';
  }


  function delComment(dform){
//	alert(dform.del_password.value+" "+dform.no.value+" "+dform.depth.value);
	if(!dform.del_password.value) {
		dform.del_password.focus();
		alert("비밀번호를 입력해 주십시오.");
		return;
	}
	try{
		query = "?no=" + dform.no.value + "&id=" + dform.id.value + "&password=" + dform.del_password.value + "&c_no=" + dform.c_no.value;
		xmlhttp = XMLHTTP();
		with(xmlhttp) {
			open("GET", "/delcomment_ok.php"+query, false);
			setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			send(query);
			xml = responseXML;
		}

		XML_RES = xml.getElementsByTagName("DELCOMMENTOK");
		//dform.depth.value = "";
		//dform.no.value = "";
		//dform.password.value = "";
		document.getElementById("delbox").style.visibility='hidden';

		if(XML_RES.item(0).getAttribute("RESULT")=="1"){
			view_comment(dform.id.value,dform.no.value,0);
		}else {
			alert(XML_RES.item(0).getAttribute("ALERT"));
		}
	}catch(e){
		return false;
	}
}

function new_delComment(dform){
//	alert(dform.del_password.value+" "+dform.no.value+" "+dform.depth.value);
	if(!dform.del_password.value) {
		dform.del_password.focus();
		alert("비밀번호를 입력해 주십시오.");
		return;
	}
	try{
		query = "?no=" + dform.no.value + "&id=" + dform.id.value + "&password=" + dform.del_password.value + "&c_no=" + dform.c_no.value;
		xmlhttp = XMLHTTP();
		with(xmlhttp) {
			open("GET", "/delcomment_ok.php"+query, false);
			setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			send(query);
			xml = responseXML;
		}

		XML_RES = xml.getElementsByTagName("DELCOMMENTOK");
		//dform.depth.value = "";
		//dform.no.value = "";
		//dform.password.value = "";
		document.getElementById("delbox").style.visibility='hidden';

		if(XML_RES.item(0).getAttribute("RESULT")=="1"){
			new_view_comment(dform.id.value,dform.no.value,0);
		}else {
			alert(XML_RES.item(0).getAttribute("ALERT"));
		}
	}catch(e){
		return false;
	}
}

function new_delComment2(dform){

	if(!dform.del_password.value) {
		dform.del_password.focus();
		alert("비밀번호를 입력해 주십시오.");
		return;
	}
	try{
		query = "?no=" + dform.no.value + "&id=" + dform.id.value + "&password=" + dform.del_password.value + "&c_no=" + dform.c_no.value;
		xmlhttp = XMLHTTP();
		with(xmlhttp) {
			open("GET", "/delcomment_ok.php"+query, false);
			setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			send(query);
			xml = responseXML;
		}

		XML_RES = xml.getElementsByTagName("DELCOMMENTOK");
		document.getElementById("delbox").style.visibility='hidden';

		if(XML_RES.item(0).getAttribute("RESULT")=="1"){
			new_view_comment2(dform.id.value,dform.no.value,0);
		}else {
			alert(XML_RES.item(0).getAttribute("ALERT"));
		}
	}catch(e){
		return false;
	}
}


//브라운 면도기 이벤트
function new_delComment_EvtBraun(dform){
//	alert(dform.del_password.value+" "+dform.no.value+" "+dform.depth.value);
	if(!dform.del_password.value) {
		dform.del_password.focus();
		alert("전화번호를 입력해 주십시오.");
		return;
	}
	try{
		query = "?no=" + dform.no.value + "&id=" + dform.id.value + "&password_evt=" + dform.del_password.value + "&c_no=" + dform.c_no.value + "&e_no=7";
		xmlhttp = XMLHTTP();
		with(xmlhttp) {
			open("GET", "/delcomment_ok.php"+query, false);
			setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			send(query);
			xml = responseXML;
		}

		XML_RES = xml.getElementsByTagName("DELCOMMENTOK");
		//dform.depth.value = "";
		//dform.no.value = "";
		//dform.password.value = "";
		document.getElementById("delbox").style.visibility='hidden';
		if(XML_RES.item(0).getAttribute("RESULT")=="1"){
			new_view_comment3(dform.id.value,dform.no.value,0);
		}else {
			alert(XML_RES.item(0).getAttribute("ALERT"));
		}
	}catch(e){
		return false;
	}
}


function qa_delComment(dform){
//	alert(dform.del_password.value+" "+dform.no.value+" "+dform.depth.value);
	if(!dform.del_password.value) {
		dform.del_password.focus();
		alert("비밀번호를 입력해 주십시오.");
		return;
	}
	try{
		query = "?no=" + dform.no.value + "&id=" + dform.id.value + "&password=" + dform.del_password.value + "&c_no=" + dform.c_no.value;
		xmlhttp = XMLHTTP();
		with(xmlhttp) {
			open("GET", "/delcomment_ok.php"+query, false);
			setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			send(query);
			xml = responseXML;
		}

		XML_RES = xml.getElementsByTagName("DELCOMMENTOK");
		//dform.depth.value = "";
		//dform.no.value = "";
		//dform.password.value = "";
		document.getElementById("delbox").style.visibility='hidden';

		if(XML_RES.item(0).getAttribute("RESULT")=="1"){
			qa_view_comment(dform.id.value,dform.no.value,0);
		}else {
			alert(XML_RES.item(0).getAttribute("ALERT"));
		}
	}catch(e){
		return false;
	}
}

function qa_delComment2(dform){

	if(!dform.del_password.value) {
		dform.del_password.focus();
		alert("비밀번호를 입력해 주십시오.");
		return;
	}
	try{
		query = "?no=" + dform.no.value + "&id=" + dform.id.value + "&password=" + dform.del_password.value + "&c_no=" + dform.c_no.value;
		xmlhttp = XMLHTTP();
		with(xmlhttp) {
			open("GET", "/delcomment_ok.php"+query, false);
			setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			send(query);
			xml = responseXML;
		}

		XML_RES = xml.getElementsByTagName("DELCOMMENTOK");
		document.getElementById("delbox").style.visibility='hidden';

		if(XML_RES.item(0).getAttribute("RESULT")=="1"){
//			qa_view_comment2(dform.id.value,dform.no.value,0);
			qa_view_comment(dform.id.value,dform.no.value,0);
		}else {
			alert(XML_RES.item(0).getAttribute("ALERT"));
		}
	}catch(e){
		return false;
	}
}

var isNchkLoad = false;
function nameChk(){
	try{
		document.getElementById('nchkIFrame').src = nameChkUrl;
		document.getElementById('nchkIframeDiv_script').style.display="";
		isNchkLoad=true;
	}catch(e){
		alert(e);
	}

}




function subStrKor2(str, len, tail){
		if(tail == null) tail = "";
		var count = 0;
		var strC = 0;
		for ( var i=0; i < str.length; i++ ) {
			if( str.charCodeAt(i) < 127 )
				count++;
			else
				count = count + 2;

			strC++;
			if(count > len) {
				strC--;
				return str.substr(0, strC) + tail;
			}
		}
		
		return str;
}


function detail_view(type,e){							//와글 상세보기
	if(type=='1'){
		document.getElementById("detail_pop").style.right=e.clientX+"px";
		document.getElementById("detail_pop").style.top=e.clientY+(document.documentElement.scrollTop+document.body.scrollTop)+20+"px";
		document.getElementById("detail_pop").style.display ="";
	}else if(type=='2'){
		document.getElementById("detail_pop").style.display ="none";
	}
}
