<!--#include virtual="/common/file/inc_head.asp"-->	
<%
Dim bdm_idx, info_url, bdm_depth, bdm_code, bdm_ref, bdm_menuname, bdm_t_clr, bdm_ro_clr, bdm_chk, bdm_type, bdm_target, bdm_bbs, bdm_editor, bdm_url, bdm_wdate, bdm_id
Dim orderby_sel
Dim prepage

orderby_sel = InputValue( request("orderby_sel") )
If orderby_sel = "" Then orderby_sel = "bdm_menuname asc"
prepage = NOWPAGE

set ST = New SelectTable

r_fields_s	= "(select count(*) from bd_address_page where bdm_idx = a.bdm_idx) as cnt, bdm_idx, info_url, bdm_depth, bdm_code, bdm_ref, bdm_menuname, bdm_t_clr, bdm_ro_clr, bdm_chk, bdm_type, bdm_target, bdm_bbs, bdm_editor, bdm_url, bdm_wdate, bdm_id, bdm_color"
table		= "bd_address a"
Where		= " where bdm_id = '" & session("ss_m_id") & "'"
Orderby		= " order by " & orderby_sel

sql = "select " & r_fields_s & " from " & table & Where & Orderby
'Response.write sql
list_data = ST.selectQueryTable( sql )
%>
<script type="text/javascript">
//<![CDATA[

function sendit(eForm){
	//var eForm = document.frm;
	if(!valueChk(eForm.bdm_menuname, "그룹명")){return false;}
	//alert("OK");
}
function valueChk(obj, objName){	//text필드
	if(obj.value.split(" ").join("") == ""){
		alert(objName+"을(를) 입력하세요");
		try{
			obj.focus();
			return false;
		}catch(e){
			return false;
		}
	}else{
		return true;
	}
}


function checkAll(){
	var eForm = document.getElementById('frm_grp');
	if(eForm.chk_all.value == "") {
		eForm.chk_all.value="Y";
		checkboxChk(eForm.bdm_idx, true);
	}else {
		eForm.chk_all.value="";
		checkboxChk(eForm.bdm_idx, false);
	}
}

function checkboxChk(chkObj, type){
	var field = chkObj;//buseo_mem.document.mem_list.check;
	if(field.length == null){
		field.checked = type;
	}else{
		for (i = 0; i < field.length; i++){
			field[i].checked = type;
		}
	}
}

//삭제
function DelOk(){
	if (confirm("주소록 그룹을 삭제하면 하위 주소록까지 삭제됩니다.\n\n삭제하시겠습니까?")){
		document.getElementById("frm_grp").submit();
	}return;
}


function delCount( num ){
	$("input[name='bdm_idx']").attr("checked", false);
	$("#bdm_idx_"+num).attr("checked", true);
	if(confirm("주소록 그룹을 삭제하면 하위 주소록까지 삭제됩니다.\n\n해당 그룹을 삭제하시겠습니까?")){
		document.getElementById("frm_grp").submit();
	}else{
		$("#bdm_idx_"+num).attr("checked", false);
	}
}


//수정
function groupModify(bdm_idx){
	var url = "ajax_addr_grp_modify.asp?bdm_idx="+bdm_idx;
	$("#detaillayer13 div.popct").load( url );
}

//구성원보기
function groupMemberList(bdm_idx){
	var url = "ajax_addr_memlist.asp?bdm_idx="+bdm_idx;
	$("#detaillayer12 div.popct").load( url );
}
//]]>
</script>


<!-- 타이틀 -->
<div id="cont_head">
	<h2>그룹관리</h2>
</div>
<!-- //타이틀 -->
<!-- 내용 -->
<div id="cont_wrap">
	<!-- 그룹관리 -->
	<div class="s0202">
		<div class="h_board">
			<div class="float_l">
				<select id="orderby_sel" class="select_basic" style="width:140px;" onchange="location.href='?orderby_sel='+this.value">
					<option value="bdm_menuname asc" <%=chkSelect(orderby_sel, "bdm_menuname asc")%>>가나다순</option>
					<option value="bdm_idx desc" <%=chkSelect(orderby_sel, "bdm_idx desc")%>>등록순</option>
				</select>
			</div>
			<div class="float_r">
				<a href="javascript:;" onclick="clickArea(detaillayer11,0);" class="c_gray">그룹등록</a>
			</div>
		</div>

		<form id="frm_grp" name="frm_grp" method="post" action="addr_grp_delete_ok.asp">
		<div>
		<input type="hidden" name="chk_all" value="" />
		<input type="hidden" name="table" value="<%=table%>" />
		<input type="hidden" name="prepage" value="<%=prepage%>" />
		</div>
		<div class="group_section">
			<ul>
<%
If Not( isnull( list_data ) ) Then
	For i = 0 To Ubound(list_data)
		ST.arr2Value( list_data(i) )
%>
				<li>
					<div class="g_box">
						<dl class="g<%=bdm_color%>">
							<dt><%=bdm_menuname%></dt>
							<dd>등록 주소록 <span><a href="javascript:;" onclick="groupMemberList('<%=bdm_idx%>');"><%=cnt%></a>건</span></dd>
						</dl>
						<div class="btnarea">
							<input type="checkbox" class="vam" id="bdm_idx_<%=bdm_idx%>" name="bdm_idx" value="<%=bdm_idx%>" />
							<div class="btngroup">
								<ul class="btn_sm">
									<li><a href="#modify" onclick="groupModify('<%=bdm_idx%>');" class="sm1">수정</a></li>
									<li><a href="#del" onclick="delCount( '<%=bdm_idx%>' )" class="sm2">삭제</a></li>
								</ul>
							</div>
						</div>
					</div>
				</li>
<%
	next
End if
%>
			</ul>
		</div>
		</form>
		<div class="paginate">
			&nbsp;
		</div>
		<div class="f_board">
			<div class="btngroup">
				<ul class="btn_nrm_bor column2">
					<li><a href="#chk" onclick="checkAll();" >전체선택/해제</a></li>
					<li><a href="#del" onclick="DelOk();">선택삭제</a></li>
				</ul>
			</div>
			<div class="search_frm">
				<!-- <ul>
					<li class="s_word">
						<select style="width:100px;">
							<option>검색</option>
						</select>
						<input type="text" class="w_text" placeholder="검색어를 입력하세요." />
						<input type="image" src="/img/sub/btn_search.png" title="검색" class="btn_search" />
					</li>
				</ul> -->
			</div>
		</div>

		</form>
	</div>
	<!-- //그룹관리 -->
</div>
<!-- //내용 -->

<!-- 그룹등록 -->
<div id="detaillayer11" class="maskpopbox" style="display:none;">
	<div class="popbox">
		<div class="poptit">
			<h4>그룹등록</h4>
			<span class="popcls"><img src="/img/sub/btn_popcls.gif" alt="닫기" /></span>
		</div>
		<div class="popct">
		<form id="frm_write" name="frm_write" method="post" action="addr_grp_write_ok.asp" onsubmit="return sendit(this);">
		<input type="hidden"  name="prepage" value="<%=prepage%>" />
			<input type="text" name="bdm_menuname" class="inp_basic" placeholder="그룹명" maxlength="50" />
			<div class="group_color">
				<ul>
					<li><input type="radio" id="radio-2-1" name="bdm_color" value="1" checked="checked" /><label for="radio-2-1"></label></li>
					<li><input type="radio" id="radio-2-2" name="bdm_color" value="2" /><label for="radio-2-2"></label></li>
					<li><input type="radio" id="radio-2-3" name="bdm_color" value="3" /><label for="radio-2-3"></label></li>
					<li><input type="radio" id="radio-2-4" name="bdm_color" value="4" /><label for="radio-2-4"></label></li>
					<li><input type="radio" id="radio-2-5" name="bdm_color" value="5" /><label for="radio-2-5"></label></li>
				</ul>
			</div>
			<div class="btngroup">
				<ul class="btn_nrm column2">
					<li><input type="submit" value="저장" class="nrm1" style="width:160px;" /></li>
					<li><a href="#close" onclick="closeArea();" class="nrm2">취소</a></li>
				</ul>
			</div>
		</form>
		</div>
	</div>
</div>
<!-- //그룹등록 -->



<!-- 그룹수정 -->
<div id="detaillayer13" class="maskpopbox" style="display:none;">
	<div class="popbox">
		<div class="poptit">
			<h4>그룹수정</h4>
			<span class="popcls"><img src="/img/sub/btn_popcls.gif" alt="닫기" /></span>
		</div>
		<form id="frm_modify" name="frm_modify" method="post" action="addr_grp_write_ok.asp" onsubmit="return sendit(this);">
		<input type="hidden"  name="prepage" value="<%=prepage%>" />
		<div class="popct">
			&nbsp;
		</div>
		</form>
	</div>
</div>
<!-- //그룹수정 -->


<!-- 그룹주소록 -->
<div id="detaillayer12" class="maskpopbox" style="display:none;">
	<div class="popbox">
		<div class="poptit">
			<h4>그룹 주소록</h4>
			<span class="popcls"><img src="/img/sub/btn_popcls.gif" alt="닫기" /></span>
		</div>
		<div class="popct">
			&nbsp;
		</div>
	</div>
</div>
<!-- //그룹주소록 -->

<!--#include virtual="/common/file/bottom.asp"-->