var frm = document.mainsearch;
var bar_bool = false;
var body_bool = false;
var select_text = document.getElementById("select_text");
var text_tbl = document.getElementById("text_tbl");
var open_tbl = document.getElementById("open_tbl");
var bar = document.getElementById("open_bar");
var line_color = "#dddddd"; //선 색상
var roll_color = "#7fbb37"; //롤 오버 색상
var roll_font_color = "#ffffff"; //롤로버시 폰트 색상

function open_select() {
	if (bar_bool == false) {
		bar.style.display = "block";
		bar_bool = true;
		body_bool = true;
	} else {
		close_bar();
	}
}

function close_bar() {
	if (bar_bool == true) {
		bar.style.display = "none";
		bar_bool = false;
		body_bool = false;
	}
}

function select_menu (group_id,group_subject,num) {
	select_text.innerHTML = group_subject;
	frm.gr_id.value = group_id;
	close_bar();
}

bar.width = open_tbl.width;
tds = bar.getElementsByTagName("td");
for (i=0; i<tds.length; i++) {
	tds[i].width = open_tbl.width;
	tds[i].onmouseover = function() {
		this.style.cursor = "hand";
		this.style.cursor = "pointer";
		this.style.backgroundColor = roll_color;
		this.style.color = roll_font_color;
	}

	tds[i].onmouseout = function() {
		this.style.backgroundColor = "";
		this.style.color = "";
	}
}

function fsearch_check() {

	partten = /[ /}{"[,.~<>!@#$%^&*()\-=+_']/gi;
	frm.stx.value = frm.stx.value.replace(partten,"");

	if (!frm.stx.value) {
		alert("검색어를 입력하세요");
		return;
	}

	frm.action = g4_path + "/bbs/search.php";
	frm.submit();
}

document.body.onclick = function() {
	if (body_bool == false) {
		close_bar();
	} else {
		open_select();
	}
}