function golist(param)
{
	location.href = "./ArticleList.do?"+param;	
}
function writeBoard(param, bbsIdx, event)
{
	if(isLogin)
	{
		// °æ·Î Ãß°¡ ¼öÁ¤
		location.href = Domain_BBS + gamePath + "/ArticleInsertForm.do?"+param;
	}
	else
	{
		var redirectFrameURL = location.href;		
		//showLoginForm(Domain_WWW + gamePath + "?link=&bbsidx="+bbsIdx, redirectFrameURL);
		//showLoginForm(location.href,"","",[event.clientX,event.clientY]);
		showLoginForm(location.href,"","");

	}
}
function editBoard(param)
{
	location.href = "./ArticleEditForm.do?"+param;
}
function deleteBoard(param)
{
	
	if(confirm("»èÁ¦ÇÏ½Ã°Ú½À´Ï±î?")==1)
	{
		self.location.href = "./ArticleDelete.do?"+param;
	}
	else
	{
		return;
	}
}

function focus_set()
{
	document.getElementById("content").focus();
}

function doSearch()
{
	var KeyWord = document.searchForm.keyword;
	var Column = document.searchForm.search;

	if (Column.value == -1)
	{
		alert("°Ë»öÁ¶°ÇÀ» ¼±ÅÃÇØ ÁÖ¼¼¿ä");
		return;
	}

	document.searchForm.target = "_self";
	document.searchForm.action = "ArticleList.do";
	
	if(Check(KeyWord.value)==0)
	{
		// ½ºÆäÀÌ½º µî °ø¹éÁ¦°Å
		alert("°Ë»ö¾î¸¦ ±âÀÔÇØ ÁÖ¼¼¿ä");
		KeyWord.value = "";
		KeyWord.focus();
		return false;
	}
//	document.searchForm.submit();
	return true;
}


function ImagePreview(param,w,h) {
	window.open(Domain_BBS + gamePath + "/PreviewImage.do?imageURL=" + param +"&width=" + w + "&height=" + h, "_ImagePreview", 'width='+w+', height='+h);
}

function ImagePreviewAll(param, bbsIdx) {
	window.open(Domain_BBS + gamePath + "/PreviewImage.do?bbsidx=" + bbsIdx + "&contentIdx=" + param, "_ImagePreview", "width=300,height=200,status=yes");
}

function opentable()
{
//	window.open(gamePath + "/popup/table_popup.asp","_table","width=400,height=300");
	window.open(gamePath + "/_html/table_popup.html","_table","width=400,height=300");
}


function popupURL(node, file) {
//	return gamePath + "/popup/table_popup.asp";
	return gamePath + "/_html/table_popup.html";
}

function popupDialog(node, url, action, init) {
	Dialog(popupURL(node, url), action, init);
}

function opentable(node) {
//	popupDialog(node, gamePath + "/popup/table_popup.asp", function(param) {
	popupDialog(node, gamePath + "/_html/table_popup.html", function(param) {


			// user must have pressed Cancel
			if (!param) {
			return false;
			}
			var doc = document.getElementById("HTMLEDITOR").contentWindow.document;

			// create the table element
			var table = doc.createElement("table");

			// assign the given arguments
			for (var field in param) {
			var value = param[field];
			if (!value) {
			continue;
			}
			switch (field) {
			case "f_width"   :
			table.style.width = value + param["f_unit"];
			break;
			case "f_align"   :
		table.align	 = value;
	break;
	case "f_border"  :
		table.border	 = parseInt(value);
	break;
	case "f_spacing" :
		table.cellspacing = parseInt(value);
	break;
	case "f_padding" :
		table.cellpadding = parseInt(value);
	break;
			}
			}

			var tbody = doc.createElement("tbody");
			table.appendChild(tbody);
			for (var i = 0; i < param["f_rows"]; ++i) {
				var tr = doc.createElement("tr");
				tbody.appendChild(tr);
				for (var j = 0; j < param["f_cols"]; ++j) {
					var td = doc.createElement("td");
					tr.appendChild(td);
					// Mozilla likes to see something inside the cell.
					if (!isMSIE) {
						var br = doc.createElement("br");
						td.appendChild(br);
					}
				}
			}
			if (isMSIE) {
				var MySelect = HTMLEDITOR.document.selection.createRange();
				if (MySelect.parentElement().all.HTMLEDITOR != null){
					HTMLEDITOR.focus();
					MySelect = HTMLEDITOR.document.selection.createRange();
				}

				MySelect.pasteHTML(table.outerHTML);
				//var range = document.getElementById("HTMLEDITOR").document.selection.createRange();
				//range.pasteHTML(table.outerHTML);
			} else {
				insertNodeAtSelection(document.getElementById("HTMLEDITOR").contentWindow, table);
			}
			return true;
	}, null);
};

/*
	¼±ÅÃº¸±â
*/
var Readidx = '';
function MultiRead(param) {
	if(Readidx!="")
	{
		Reading(Readidx.substr(0, (Readidx.length-1)), param);
	}
}
function Reading(idx, param)
{
	self.location.href = 'bbs_read.asp?idx='+idx+'&'+param;
}
function SelectOneBoard(obj, b_idx)
{
	if(obj.src==Domain_SImage+'/img/img_check_02.gif')
	{
		obj.src = Domain_SImage+'/img/img_check_01on.gif'
		Readidx += b_idx+",";
	}
	else
	{
		obj.src = Domain_SImage+'/img/img_check_02.gif'
		Readidx = Readidx.searchReplace(b_idx+",", "");
	}
}

function SelectAllBoard()
{
	Readidx = '';
	var obj = document.all.designCheckbox;
	
	if(typeof(obj)!="undefined")
	{
		if(typeof(obj.length)=="undefined")
		{
			obj.src=Domain_SImage+'/img/img_check_01on.gif';
			Readidx = document.all.b_idx.value+",";
		}
		else
		{
			for (i=0;i<obj.length ;i++ )
			{
				if(obj[i].src==Domain_SImage+'/img/img_check_02.gif')
				{
					obj[i].src = Domain_SImage+'/img/img_check_01on.gif';
					Readidx += document.all.b_idx[i].value+",";
				}
				else
				{
					obj[i].src = Domain_SImage+'/img/img_check_02.gif';
				}
			}
		}
	}
	else
	{
		return;
	}
}

function SetClipBoardData(StrText)
{
	window.clipboardData.setData('Text',StrText);
	alert("URLÀÌ º¹»çµÇ¾ú½À´Ï´Ù.\nºÙ¿©³Ö±â(Ctrl+V)¸¦ ÀÌ¿ëÇÏ¿© URLÀ» º¹»çÇÏ¼¼¿ä.");
}

function myDoc(flag, key, bbsidx) {

	f = document.searchForm;

	if(isLogin)
	{
		if(flag<0)
		{
			alert("ÁË¼ÛÇÕ´Ï´Ù.\n°ÔÀÓ³»¿¡¼­ Ä³¸¯¸¦ »ý¼ºÇÏ¼Å¾ß ÀÌ¿ëÀÌ °¡´ÉÇÕ´Ï´Ù.");
			return false; 
		}

		f.keyword.value = key;
		f.search.value = 3;
		f.submit();
	}
	else
	{
		var redirectFrameURL = location.href;
		
		//showLoginForm(Domain_WWW + gamePath + "/?link=&bbsidx="+bbsidx, redirectFrameURL);
		showLoginForm(location.href,"","");
	}

}
function pilotDoc(key, bbsidx, bbstype) {
	var url = gamePath  + "/ArticleList.do?bbsidx=" + bbsidx + "&search=3&keyword=" + key;
	openNewWindow(url, "_blank", "yes");
}

function pilotDoc_b2(key, bbsidx, bbstype) {
	if(bbstype != 1 && bbstype != 8)
	{
		f = document.searchForm;		
	}else{
		f = parent.document.searchForm;
	}

	f.action = "ArticleList.do";
	f.target = "_blank";
	f.keyword.value = key;
	f.search.value = 3;
	f.submit();
}

function pilotDoc_b(key, bbsidx, bbstype) {
	if(bbstype != 1)
	{
		f = document.searchForm;		
	}else{
		f = parent.document.searchForm;
	}
	
	url = Domain_WWW + gamePath + "/?link=&bbsidx=" + bbsidx + "&search=3&keyword=" + key;
	window.open(url,"");	
}


function showPilotForm_shot(image_domain) {

	var ie_value = 0;

	if(navigator.userAgent.indexOf("MSIE 7") != -1){
		ie_value = 5;
	}
	if(parent.flag)
	{
		self.resizeTo(document.body.scrollWidth , document.body.scrollHeight+ie_value);
		document.getElementById("btn_to").src = image_domain+"/real/images/board/btn_myboard_on.gif";
		document.getElementById("btn_to").title = "´Ý±â";
		document.getElementById("btn_to").alt = "´Ý±â";
		parent.flag=false;
	}else{
		self.resizeTo(document.body.scrollWidth , 35);
		document.getElementById("btn_to").src = image_domain+"/real/images/board/btn_myboard_off.gif";
		document.getElementById("btn_to").title = "¿­±â";
		document.getElementById("btn_to").alt = "¿­±â";	
		parent.flag=true;
	}	
}

function showPilotForm(id, image_domain) {
	div=document.getElementById(id);

	if(div.style.display == "none") {
		div.style.display = "";
		document.getElementById("btn_to").src = image_domain+"/real/images/board/btn_myboard_on.gif";
		document.getElementById("btn_to").title = "´Ý±â";
		document.getElementById("btn_to").alt = "´Ý±â";
	} else {
		div.style.display = "none";
		document.getElementById("btn_to").src = image_domain+"/real/images/board/btn_myboard_off.gif";
		document.getElementById("btn_to").title = "¿­±â";
		document.getElementById("btn_to").alt = "¿­±â";		
	}	
}

function openMYInfo(userIDIdx)
{
	var myhp_width = "510";
	var myhp_height = "505";
	var myhp_left = (screen.availWidth / 2) - (myhp_width / 2);
	var myhp_top = (screen.availHeight / 2) - (myhp_height / 2);

	var url = Domain_THLogin + "/myinfo/individual.do?siteCode=40&UserIDIndex=" + userIDIdx;
	var _OtherhpOpen =window.open(url,userIDIdx+"_AN");	
	_OtherhpOpen.focus();
}
function setPng24(obj) { 
    obj.width=obj.height=1; 
    obj.className=obj.className.replace(/\bpng24\b/i,''); 
    obj.style.filter = 
    "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');" 
    obj.src='';  
    return ''; 
}
function recommendCheck(params)
{
	var f = document.getElementById("recommendForm");
	var checkCount = 0;
	
	for(i=0;i<f.recommendValue.length;i++){
		if(f.recommendValue[i].checked){
			checkCount++;
		}
	}

	if(isLogin)
	{
		if(checkCount < 1)
		{
			alert("ÃßÃµÁ¡¼ö¸¦ ¼±ÅÃÇØÁÖ¼¼¿ä.");
			return false;
		}
		
		f.method = 'post';
		f.action = gamePath + "/RecommendCheck.do?" + params;		
		f.submit();
	}else{		
		showLoginForm(location.href,"","");
	}
}

//////////////////// Tip BBS ////////////////////
function selectCategory_1(categoryIdx) {
	f = document.all;
	if(categoryIdx == -1 && f.categoryIdx_1[0].checked == true) {
		for(var i=1; i < f.categoryIdx_1.length; i++) {
			f.categoryIdx_1[i].checked = false;
		}
	} else {
		f.categoryIdx_1[0].checked = false;
	}
	
	
	var checkedCount=0;
	for(var i=1; i < f.categoryIdx_1.length; i++) {
		if(f.categoryIdx_1[i].checked) {
			checkedCount ++;
		}
	}	
	
	if(checkedCount == 0) {
		f.categoryIdx_1[0].checked = true;
		document.searchForm.contentKind_1.value = "";
	}
	

			
}


function selectCategory_2(categoryIdx) {
	f = document.all;
	if(categoryIdx == -1 && f.categoryIdx_2[0].checked == true) {
		for(var i=1; i < f.categoryIdx_2.length; i++) {
			f.categoryIdx_2[i].checked = false;
		}
	} else {
		f.categoryIdx_2[0].checked = false;
	}
	
	var checkedCount=0;
	for(var i=1; i < f.categoryIdx_2.length; i++) {
		if(f.categoryIdx_2[i].checked) {
			checkedCount ++;
		}
	}
	
	if(checkedCount == 0) {
		f.categoryIdx_2[0].checked = true;
		document.searchForm.contentKind_2.value = "";
	}		
}

function insertContentKindIdx()
{
	f = document.all;
	
	document.searchForm.contentKind_1.value = "";
	document.searchForm.contentKind_2.value = "";
	
	for(var i=1; i < f.categoryIdx_1.length; i++) {
		if(f.categoryIdx_1[i].checked) {
			if(document.searchForm.contentKind_1.value == ""){
				document.searchForm.contentKind_1.value += f.categoryIdx_1[i].value;
			}else{
				document.searchForm.contentKind_1.value += "," + f.categoryIdx_1[i].value;
			}
		}
	}

	for(var i=1; i < f.categoryIdx_2.length; i++) {
		if(f.categoryIdx_2[i].checked) {
			if(document.searchForm.contentKind_2.value == ""){
				document.searchForm.contentKind_2.value += f.categoryIdx_2[i].value;
			}else{
				document.searchForm.contentKind_2.value += "," + f.categoryIdx_2[i].value;
			}
		}
	}				
}


var NewImg = new Array ();
var NewText = new Array ();

var ImgNum = 0;
var TextNum = 0;
	
var tempImg = "";
var tempText = "";
var aHref = "";

var delay = 4000;
var lock;
var run;

function ReqStrategyContents(recommend)
{
	locationString="/strategy/getTopData.do?recommend=" + recommend;
	var REQ = new clsReqXML(locationString,"",RecvStrategyContents);
	REQ.send();
}

function RecvStrategyContents(XMLResult)
{	
	strategyXML = new clsParseXML();
	strategyXML.setXML(XMLResult);
	strategyXML.setXMLName("XMLDATA");

	var recommend = locationString.substring(locationString.lastIndexOf("recommend=")+10);

	switch(recommend){
		case '0': 
		case '1':
		case '2':	
			break;
		default :
			recommend = 3;
			break;
	}
		
	for(i = 0; i <= recommend; i++){
		strategyXML.setElementName("strategy" + i);	
		
		var count = strategyXML.getElementCount();
		
		var link;
		var contentKind;
		var title;
		var commentCount;
		var commentStr = "";
		var recommendCount, recommendKind;
		var nickName;
		var filePath;
	
		var level;	
		var numberImg;
		var imaPath;
		var titleLength;
		var contents = new Array();
		var j = 0;
		
		
		for(strategyXML.cursor = 0; strategyXML.cursor < count; strategyXML.cursor++)
		{
			link = strategyXML.BindCol("link");
			contentKind = strategyXML.BindCol("contentKind");
			title = strategyXML.BindCol("title");
			commentCount = strategyXML.BindCol("comment");
			recommendCount = strategyXML.BindCol("recommendCount");
			recommendKind = strategyXML.BindCol("recommendKind");	
			nickName = strategyXML.BindCol("nickName");
			filePath = strategyXML.BindCol("imgPath");

			if(recommendKind == 2){
				level = "drillrecom";		
			}else if(recommendKind == 1){
				if(recommendCount < 10){
					level = "silver";
				}else{
					level = "gold";			
				}
			}else{
				level = "gray";
			}
			
			titleLength = 16;			
			title = title.replace("<", "&lt;").replace(">", "&gt;");
			
			if(commentCount > 0){
				commentStr = "<span class='coment_num'>[" + commentCount + "]</span>";
				titleLength = titleLength - 3;
			}else{
				commentStr = "";
			}

			if(title.length > titleLength){				
				titleStr = title.cut_strlen2(titleLength);
			}else{
				titleStr = title;
			}
			
			
			
			if(recommend == 0){
				if(strategyXML.cursor == 0){
					contents = contents + "<table class='left'>";
				}else if(strategyXML.cursor == 5){
					contents = contents + "<table class='right'>";
				}			
				
				contents = contents + "<tr><td class='ico_num'><img src='" + Domain_SImage + "/images/bbs/board/ico_" + level + ".gif' /></td></td><td>" + contentKind + " <a href='" + link + "&recommend=" + recommend + "' title='" + title + "'>" + titleStr + "</a>" + commentStr + "</td></tr>";
				
				if(strategyXML.cursor == 4){
					contents = contents + "</table>";
				}
			}else if(recommend == 1 || recommend == 2){

				if(i == 0){
					titleLength = 27;
				}else{
					titleLength = 10;
				}
				if(title.length > titleLength){
					titleStr = title.cut_strlen2(titleLength);
				}else{
					titleStr = title;
				}	
				// TEXT
				if(i == 0){
					aHref = "<a href='" + link + "&recommend=" + recommend + "' onmouseover='javascript:rotate();' onmouseout='javascript:rotate();' title='" + title + "'>";
					tempText += "<tr><th><img src='" + Domain_SImage + "/images/bbs/board/ico_" + level + ".gif' /></th><td>" + contentKind + " " + aHref + titleStr + "</a>" + commentStr + "</td></tr>";
	
					if((strategyXML.cursor+1) % 5 == 0 || (strategyXML.cursor+1) == count){
						NewText[j] = "<table>" + tempText + "</table>";
						tempText = "";
						j++;
					}
				}else{	// IMAGE
					aHref = "<a href='" + link + "&recommend=" + recommend + "' onmouseover='javascript:rotate();' onmouseout='javascript:rotate();' title='" + title + "'>";
					imaPath = Domain_UImage.substring(0,Domain_UImage.indexOf("an")) + filePath.substring(0, filePath.lastIndexOf("/")) + "/thumbnail" + filePath.substring(filePath.lastIndexOf("/"));
					tempImg = "<div class='image'>" + aHref + "<img src='" + imaPath + "' width='101' height='74' alt='" + title + "' /></a></div><div class='caption'>" + aHref + titleStr + "</a></div>";
					NewImg[j] = tempImg;
					j++;
				}

			}else{
				if(strategyXML.cursor == 0){
					contents = contents + "<table>";
				}
				
				if(i == 0 || i == 1){
					contents = contents + "<tr><th><img src='" + Domain_SImage + "/images/bbs/board/ico_" + level + ".gif' /></th><td>" + contentKind + " <a href='" + link + "&recommend=" + recommend + "' title='" + title + "'>" + titleStr + "</a>" + commentStr + "</td></tr>";
				}else{
					numberImg = (strategyXML.cursor+1);

					if(numberImg < 4){
						numberImg = numberImg + "hot";

					}
					contents = contents + "<tr><td class='rank'><img src='" + Domain_SImage + "/images/bbs/board/ico_" + numberImg + ".gif' /></td><td class='title' style='word-break:break-all;'><a href='" + link + "&recommend=0' title='" + title + "'>" + titleStr + "</a></td><td class='pilot' style='word-break:break-all'>" + nickName + "</td></tr>";
				}

			}
				
		}
		
		if(recommend == 0){
			contents = contents + "</table>";
		}else if(recommend == 1){
			if(i == 0){
				contents = contents + "</table></div>";
			}else{
				contents = contents + "</div>";
			}
		}else if(recommend == 2){
		}else{
			contents = contents + "</table>";
		}
		if(count > 0){
			SafeInnserHTML("top"+i,contents);
		}else{
			SafeInnserHTML("top"+i,"<div style='text-align:center'><table><tr style='height:80px;'><td style='text-align:center;vertical-align:middle;'>°Ë»öµÈ ±ÛÀÌ ¾ø½À´Ï´Ù.</td></tr></table></div>");
		}
	}
	if(recommend == 1 || recommend == 2){
		ImgLength = NewImg.length - 1;
		TextLength = NewText.length - 1;
		lock = false;
		initChgImg();
		rotate();
	}
}

function chgImg(direction) {
	if (document.images) {
		ImgNum = ImgNum + direction;
		TextNum = TextNum + direction;
		
		if (ImgNum > ImgLength) {
			ImgNum = 0;
		}			
		if (TextNum > TextLength) {
			TextNum = 0;
		}			
	
		if (ImgNum < 0) {
			ImgNum = ImgLength;
		}
		if (TextNum < 0) {
			TextNum = TextLength;
		}
		if(NewImg[ImgNum] != undefined){
			document.getElementById("slideshow").innerHTML = NewImg[ImgNum];
		}
		if(NewText[TextNum] != undefined){
			document.getElementById("text").innerHTML = NewText[TextNum];
		}				
	}
}
function rotate() {	
    if (lock == true) {
        lock = false;
        window.clearInterval(run);
    }
    else if (lock == false) {
        lock = true;
        run = setInterval("chgImg(1)", delay);
   }
}
function initChgImg()
{
	if(NewImg[0] != undefined){	
		document.getElementById("slideshow").innerHTML = NewImg[0];
	}else{
		document.getElementById("slideshow").innerHTML = "<div align='center'><table border=0 style='width:100px;height:80px;'><tr><td style='text-align:center;vertical-align:middle;'>°Ë»öµÈ ±ÛÀÌ<br>¾ø½À´Ï´Ù.</td></tr></table></div>";//<div style='text-align:center'><table border='0'><tr style='height:80px;'><td style='text-align:center;vertical-align:middle;'>±ÛÀÌ ¾ø½À´Ï´Ù.</td></tr></table></div>";
	}
	if(NewText[0] != undefined){	
		document.getElementById("text").innerHTML = NewText[0];
	}else{
		document.getElementById("text").innerHTML = "<div style='text-align:center'><table border='0'><tr style='height:80px;'><td style='text-align:center;vertical-align:middle;'>°Ë»öµÈ ±ÛÀÌ ¾ø½À´Ï´Ù.</td></tr></table></div>";
	}		
}
//////////////////// Tip BBS ////////////////////


