var overNum;

$(function() {
	$("a").attr("onfocus", "this.blur()");
	$("#leftUrl li")
	.mouseover(function(){
		var imgLink = $(this).children("a").children("img").attr("src");

		imgLink = imgLink.replace("_a", "_b");
		$(this).children("a").children("img").attr("src", imgLink);
		return;
	})
	.mouseout(function() {
		var imgLink = $(this).children("a").children("img").attr("src");
		var imgID = $(this).children("a").children("img").attr("id");

		if (imgID != "over")
		{
			imgLink = imgLink.replace("_b", "_a");
			$(this).children("a").children("img").attr("src", imgLink);
			return;
		}
	});

	
	$("#menu1 li").mouseover(function(){
		var thisIndex = $("#menu1 li").index(this);
		var Bwidth = document.body.clientWidth;
		var LeftW = $(this).offset().left;

		if (thisIndex == 0) { LeftW = LeftW + 20 } else if(thisIndex == 1) { LeftW = LeftW - 50 } else if(thisIndex == 2) { LeftW = LeftW + 35 } else if(thisIndex == 3) { LeftW = LeftW + 10 } else if(thisIndex == 4) { LeftW = LeftW - 100 }

		$("#subText" + overNum).css("display", "none");
		$("#subText" + thisIndex).css({"display": "inline", "position": "absolute", "left": LeftW + "px"});
		overNum = thisIndex;
	});

	$("#menu2 li").mouseover(function(){
		var thisIndex = $("#menu2 li").index(this);
		var Bwidth = document.body.clientWidth;
		var LeftW = $(this).offset().left;

		if (thisIndex == 0) { LeftW = LeftW + 20 } else if(thisIndex == 1) { LeftW = LeftW - 50 } else if(thisIndex == 2) { LeftW = LeftW + 30 } else if(thisIndex == 3) { LeftW = LeftW + 10 } else if(thisIndex == 4) { LeftW = LeftW - 30 }

		$("#subText" + overNum).css("display", "none");
		$("#subText" + thisIndex).css({"display": "inline", "position": "absolute", "left": LeftW + "px"});
		overNum = thisIndex;
	});
	
	/*
	$(".menu li").mouseover(function(){
		var thisIndex = $(".menu li").index(this);
		var Bwidth = document.body.clientWidth;
		var Dleft;
		var LeftW;
		var SleftW;
		if (thisIndex == 0) { LeftW = 350; SleftW = 180; } else if(thisIndex == 1) { LeftW = 650; SleftW = 330; } else if(thisIndex == 2) { LeftW = 1065; SleftW = 530; } else if(thisIndex == 3) { LeftW = 1300; SleftW = 730; } else if(thisIndex == 4) { LeftW = 1680; SleftW = 730; }
		if (Bwidth > 1000) { Dleft = (Bwidth - 1000 + LeftW) / 2; } else { Dleft = SleftW; }
		$("#subText" + overNum).css("display", "none");
		$("#subText" + thisIndex).css({"display": "inline", "position": "absolute", "left": Dleft + "px"});
		overNum = thisIndex;
	});
	*/

});

function searchStart(obj)
{
	var form = window.document.formBoard;

	form.submit();
	return false;
}

/*
함수명 : View_Bbs_Password(Num)
인식자 : Num
기   능 : 게시물 비밀번호 입력 레이어 보이기..
최종 수정일 : 2010-04-06
*/
function viewBbsPassword(Num, Element)	{
	
	var Ele = document.getElementById;
	var form = document.fromCheckPass;
	var x;
	var y;

	x = Ele(Element).clientWidth;
	y = Ele(Element).clientHeight;

	x = x / 2 - 130
	y = y / 2 - 30

	Ele("Pass_Div").style.top = y + "px";
	Ele("Pass_Div").style.left = x + "px";
	Ele("Pass_Div").style.display = "inline";
	form.strSeq.value = Num;
	form.strPassword.focus();
	return;
}

/*
함수명 : Close_Div(Ele)
인식자 : Ele
기   능 : DIV 닫기
최종 수정일 : 2010-04-06
*/
function closeDiv(Ele)	{
	document.getElementById(Ele).style.display = "none";
	return false;
}

/*
함수명 : Check_Bbs_Password()
인식자 : Num
기   능 : 게시물 비밀번호 체크.
최종 수정일 : 2010-04-06
*/
function checkPassword()	{
	var form = document.fromCheckPass;

	if (form.strPassword.value == "")
	{
		alert("비밀번호를 입력하세요.");
		form.strPassword.focus();
		return false;
	}

	strParams = "strSeq=" + form.strSeq.value;
	strParams += "&strPassword=" + form.strPassword.value;
	url = "/proc/ajax_board_pass_check.asp";
	var loader = new net.ContentLoader(url, checkPasswordResult, null, "POST", strParams);

	return false;
}

/*
함수명 : Check_Bbs_Password_Result()
인식자 : 
기   능 : 게시물 비밀번호 체크후 이동 및 메세지 출력.
최종 수정일 : 2010-04-06
*/
function checkPasswordResult()	{
	var Ele = document.getElementById;
	var ReqValue;
	ReqValue = this.req.responseText;
	ReqValue = ReqValue.split("^");

	if (ReqValue[0] == "N")
	{
		alert("비밀번호가 일치하지 않습니다.");
		Ele("strPassword").value = "";
		return false;
	}
	else
	{		
		window.location.href="/Board.asp?Board_Id=" + ReqValue[0] + "&Board_Type=" + ReqValue[1] + "&Board_Seq=" + ReqValue[2] + "&PassCheck=" + escape("확인");
		return false;
	}
	return false;
}

/*
함수명 : replyWrite()
인식자 : 
기   능 : 답글 등록폼체크
최종 수정일 : 2010-03-05
*/
function replyWrite()	{
	var form = document.replyForm;
	
	if (form.strBoardReply.value == "")
	{
		alert("내용을 입력하세요");
		form.strBoardReply.focus();
		return;
	}
	
	strParams = "R_Seq=" + form.strRseq.value;
	strParams += "&R_Board_Id=" + escape(form.strRboardID.value);
	strParams += "&Board_Reply=" + escape(form.strBoardReply.value);
	url = "/proc/ajax_reply_write.asp";
	var loader = new net.ContentLoader(url, replyWriteResult, null, "POST", strParams);
	return false;
}

/*
함수명 : replyWriteResult()
인식자 : 
기   능 : 답글 등록후 이동 및 메세지 출력.
최종 수정일 : 2010-03-05
*/
function replyWriteResult()	{
	var Ele = document.getElementById;
	var ReqValue;

	ReqValue = this.req.responseText;
	ReqValue = ReqValue.split("^");


	window.location.href="/Board.asp?Board_Id=" + ReqValue[0] + "&Board_Type=" + ReqValue[1] + "&Board_Seq=" + ReqValue[2];
	return false;
}

/*
함수명 : replyDelete()
인식자 : 
기   능 : 답글 삭제
최종 수정일 : 2010-03-03
*/
function replyDelete(R_Seq, Seq, Board_ID)	 {
	var Qconfirm = confirm("삭제하시겠습니까?");

	if (Qconfirm)
	{
		window.location.href = "/proc/Proc_Reply_Delete.asp?R_Seq=" + R_Seq + "&Seq=" + Seq + "&Board_ID=" + Board_ID;		
	}
	return;	
}

/*
함수명 : checkForm()
인식자 : 
기   능 : 게시판 글 쓰기 폼체크
최종 수정일 : 2010-04-06
*/
function checkForm()
{
	var form = document.formBoard;

	if (form.strBoardName.value == "")
	{
		alert("글쓴이를 입력해주세요");
		form.strBoardName.focus();
		return false;
	}

	if (form.strBoardTitle.value == "")
	{
		alert("제목을 입력해주세요");
		form.strBoardTitle.focus();
		return false;
	}
	
	form.strBoardCont.value = ed2.getHtml();
	form.method = "post";
	form.action = "/proc/proc_board_write.asp";
	form.submit();
	return false;
}

/*
함수명 : fnFileDown()
인식자 : 
기   능 : 파일 다운
최종 수정일 : 2010-04-06
*/
function fnFileDown(strFileName, strOFileName, strBoardID)
{
	window.location.href = '/lib/file.asp?File=' + escape(strFileName) + "&Name=" + escape(strOFileName) + "&Board_ID=" + strBoardID;
	return;
}

/*
함수명 : Delete_Proc()
인식자 : 
기   능 : 게시판 삭제
최종 수정일 : 2010-04-06
*/
function Delete_Proc(keyword, searchtype, pagenum, top, left)
{
	var form = document.formView;

	if (confirm("삭제하시겠습니까?"))
	{
		form.method = "post";
		form.action = "/proc/Proc_Board_Delete.asp?keywordOfSearch=" + escape(keyword) + "&typeOfSearch=" + searchtype + "&page=" + pagenum + "&top=" + top + "&left=" + left;
		form.submit()
	}
	return;
}


/*
함수명 : divView()
인식자 : 
기   능 : 겔러리 게시판 원본이미지 DIV
최종 수정일 : 2010-04-06

function divView(ID, FName, X, Y)
{
	//document.getElementById("ImageView").innerHTML = "<img src='/boardfile/" + ID +  "/" + FName + "' width='" + X + "' height='" + Y + "'>";
	//document.getElementById("divBbsPass").style.display = "inline";

	var form = document.formView;

	window.open('','imgPopup', 'width=' + X + 'px, height=' + Y + 'px, scrollbars=no');
	form.method="post";
	form.target = "imgPopup";
	form.action="/skin/img_popup.asp";
	form.submit();
	return;
}
*/

function colorChartPop(code)
{
	window.open('/colorPopup.asp?code=' + code,'colorCahrt11','width=620px, height=842px','scrollbars=no');
	return;
}
