﻿//<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

var client_pop_menu_htm="";
client_pop_menu_htm +="<div id='client_pop_menu' style='width:140;height:175;position:absolute;display:none;border:1px solid'>";
client_pop_menu_htm +="<table width='140' border='0' cellpadding='0' cellspacing='1' bgcolor='#C4C4C4'><tr>";
client_pop_menu_htm +="  <td align='center' bgcolor='#f2f2f2'><table width='125' border='0' cellspacing='0' cellpadding='2'>";
client_pop_menu_htm +="    <tr><td height='5'></td></tr>";
client_pop_menu_htm +="    <tr><td height='16' style='padding-left:5px;' onclick='bizCallToUser_PopMenu(\"get_pcs\")' style='cursor:hand' onmouseover='this.style.backgroundColor=\"#C4C4C4\";'  onmouseout='this.style.backgroundColor=\"\";'>휴대폰에 전화걸기</td></tr>";
client_pop_menu_htm +="    <tr><td height='16' style='padding-left:5px;' onclick='bizCallToUser_PopMenu(\"get_phone\")' style='cursor:hand' onmouseover='this.style.backgroundColor=\"#C4C4C4\";'  onmouseout='this.style.backgroundColor=\"\";'>유선전화에 전화걸기</td></tr>";
client_pop_menu_htm +="    <tr><td height='16' style='padding-left:5px;' onclick='bizCallToUser_PopMenu(\"uid\")' style='cursor:hand' onmouseover='this.style.backgroundColor=\"#C4C4C4\";'  onmouseout='this.style.backgroundColor=\"\";'>아이엠텔에 전화걸기</td></tr>";
client_pop_menu_htm +="    <tr><td height='8'><img src='http://img.imtel.com/images/biz/pop/s_01.gif' width='125' height='2'></td></tr>";
client_pop_menu_htm +="    <tr><td height='16' style='padding-left:5px;' onclick='bizAddFriend_PopMenu();' style='cursor:hand' onmouseover='this.style.backgroundColor=\"#C4C4C4\";'  onmouseout='this.style.backgroundColor=\"\";'>친구 추가</td></tr>";
client_pop_menu_htm +="    <tr><td height='8'><img src='http://img.imtel.com/images/biz/pop/s_01.gif' width='125' height='2'></td></tr>";
client_pop_menu_htm +="    <tr><td height='16' style='padding-left:5px;' onclick='bizVoiceMsg_PopMenu();' style='cursor:hand' onmouseover='this.style.backgroundColor=\"#C4C4C4\";'  onmouseout='this.style.backgroundColor=\"\";'>음성쪽지 보내기</td></tr>";
client_pop_menu_htm +="    <tr><td height='16' style='padding-left:5px;' onclick='bizChrMsg_PopMenu();' style='cursor:hand' onmouseover='this.style.backgroundColor=\"#C4C4C4\";'  onmouseout='this.style.backgroundColor=\"\";'>문자쪽지 보내기</td></tr>";
client_pop_menu_htm +="    <tr><td height='16' style='padding-left:5px;' onclick='bizSmsMsg_PopMenu();'style='cursor:hand' onmouseover='this.style.backgroundColor=\"#C4C4C4\";'  onmouseout='this.style.backgroundColor=\"\";'>SMS 보내기</td></tr>";
client_pop_menu_htm +="    <tr><td><img src='http://img.imtel.com/images/biz/pop/s_01.gif' width='125' height='2'></td></tr>";
client_pop_menu_htm +="    <tr><td height='16' style='padding-left:5px;' onclick='bizInfoView_PopMenu();' style='cursor:hand' onmouseover='this.style.backgroundColor=\"#C4C4C4\";'  onmouseout='this.style.backgroundColor=\"\";'>사용자 정보보기</td></tr>";
client_pop_menu_htm +="    <tr><td height='4'></td></tr>";
if( GetCookie("key") == 9){	//관리자 메뉴 
	client_pop_menu_htm +="    <tr><td height='25' valign='top' onclick='bizAdminMenu_PopMenu();' style='cursor:hand' style='padding-left:10px;' onmouseover='this.style.backgroundColor=\"#C4C4C4\";'  onmouseout='this.style.backgroundColor=\"\";'>관리하기</td></tr>";
}
client_pop_menu_htm +="  </table></td>";
client_pop_menu_htm +="</tr></table>";
client_pop_menu_htm +="</div>";
document.write( client_pop_menu_htm );

var group_pop_menu_htm = "";
group_pop_menu_htm +="<div id='group_pop_menu' style='width:140;height:67;position:absolute;display:none;border:1px solid'>";
group_pop_menu_htm +="<table width='140' border='0' cellpadding='0' cellspacing='1' bgcolor='#C4C4C4'><tr>";
group_pop_menu_htm +="  <td align='center' bgcolor='#f2f2f2'><table width='125' border='0' cellspacing='0' cellpadding='2'>";
group_pop_menu_htm +="    <tr><td height='5'></td></tr>";
group_pop_menu_htm +="    <tr><td height='16' style='padding-left:5px;' onclick='bizGroupVoiceMsg_PopMenu();' style='cursor:hand' onmouseover='this.style.backgroundColor=\"#C4C4C4\";'  onmouseout='this.style.backgroundColor=\"\";'>부서 음성쪽지 보내기</td></tr>";
group_pop_menu_htm +="    <tr><td height='16' style='padding-left:5px;' onclick='bizGroupChrMsg_PopMenu();' style='cursor:hand' onmouseover='this.style.backgroundColor=\"#C4C4C4\";'  onmouseout='this.style.backgroundColor=\"\";'>부서 문자쪽지 보내기</td></tr>";
group_pop_menu_htm +="    <tr><td height='16' style='padding-left:5px;' onclick='bizGroupSmsMsg_PopMenu();' style='cursor:hand' onmouseover='this.style.backgroundColor=\"#C4C4C4\";'  onmouseout='this.style.backgroundColor=\"\";'>부서 SMS 보내기</td></tr>";
group_pop_menu_htm +="    <tr><td><img src='http://img.imtel.com/images/biz/pop/s_01.gif' width='125' height='2'></td></tr>";
group_pop_menu_htm +="    <tr><td height='16' style='padding-left:5px;' onclick='bizGroupView_PopMenu();' style='cursor:hand' onmouseover='this.style.backgroundColor=\"#C4C4C4\";'  onmouseout='this.style.backgroundColor=\"\";'>부서원 보기</td></tr>";
group_pop_menu_htm +="    <tr><td height='4'></td></tr>";
if( GetCookie("key") == 9){	//관리자 메뉴 
	group_pop_menu_htm +="    <tr><td><img src='http://img.imtel.com/images/biz/pop/s_01.gif' width='125' height='2'></td></tr>";
	group_pop_menu_htm +="    <tr><td height='16' style='padding-left:5px;' onclick='bizGroupAdminMenu_PopMenu();' style='cursor:hand' onmouseover='this.style.backgroundColor=\"#C4C4C4\";'  onmouseout='this.style.backgroundColor=\"\";'>관리하기</td></tr>";
}
group_pop_menu_htm +="   </table></td>";
group_pop_menu_htm +="</tr></table>";
group_pop_menu_htm +="</div>";
document.write( group_pop_menu_htm );
var NS4;
var IE4;
NS4 = (document.layers);
IE4 = (document.all);

var pop_menu_client_id="";
var pop_menu_client_uid="";
var pop_menu_group_uid="";

if (NS4) {
	document.captureEvents(Event.CLICK)
	document.onclick = MouseDown;
	} 
else if (IE4) {
	document.onclick = MouseDown;
}

function MouseDown(e) {
	event_target = event.srcElement;
	personImage = event_target;
	event_target = event_target.toString();
	
	if(event_target=="[object]"){
		if( client_pop_menu.style.display == "inline" && personImage.name!= "pop_menu" ){
			select_box_view();
			client_pop_menu.style.display = "none";
			pop_menu_client_id="";
			pop_menu_client_uid="";
		}
		
		if( group_pop_menu.style.display == "inline" && personImage.name!= "pop_menu" ){
			select_box_view();
			group_pop_menu.style.display = "none";
			pop_menu_group_uid=""
		}
	}
	return;
}	

function select_box_hidden(){
	if(document.all.div_pop_menu_hidden){
		if(typeof(document.all.div_pop_menu_hidden.options)!="undefined"){
			document.all.div_pop_menu_hidden.style.display = "none"
		} else {
			for( var i=0; i<document.all.div_pop_menu_hidden.length ; i++){
				document.all.div_pop_menu_hidden[i].style.display = "none"
			}
		}
	}
}

function select_box_view(){
	if(document.all.div_pop_menu_hidden){
		if(typeof(document.all.div_pop_menu_hidden.options)!="undefined"){
			document.all.div_pop_menu_hidden.style.display = "inline"
		} else {
			for( var i=0; i<document.all.div_pop_menu_hidden.length ; i++){
				document.all.div_pop_menu_hidden[i].style.display = "inline"
			}
		}
	}
}

function group_menu(group_uid){
	pop_menu_postion('group_pop_menu');
	
	if(client_pop_menu.style.display == "inline"){
		client_pop_menu.style.display = "none";
		pop_menu_client_uid ="";
		pop_menu_client_id = "";
	}
	
	if( pop_menu_group_uid == group_uid){
		group_pop_menu.style.display = "none";
		select_box_view();
		pop_menu_group_uid = "";
	} else {
		select_box_hidden();
		group_pop_menu.style.display = "inline";
		pop_menu_group_uid = group_uid;
	}
	
	return;
}

function person_menu(client_id, client_uid){
	pop_menu_postion('client_pop_menu');
	
	if(group_pop_menu.style.display == "inline"){
		group_pop_menu.style.display = "none"
		pop_menu_group_uid = "";
	}
	
	if( pop_menu_client_uid == 	client_uid ){
		client_pop_menu.style.display = "none";
		select_box_view();
		pop_menu_client_uid ="";
		pop_menu_client_id = "";
	} else {
		select_box_hidden();
		pop_menu_client_uid =client_uid;
		pop_menu_client_id = client_id;
		client_pop_menu.style.display = "inline";
	}
	
	return;
}


function pop_menu_postion(div_name){
	var menu_pos_x=0, menu_pos_y=0
	var mouse_top = event.y;
	var mouse_left = event.x;
	var menu_width_size, menu_height_size;
	
	var screen_height = window.document.body.scrollHeight;
	var screen_width = window.document.body.scrollWidth;
	var screen_top = window.document.body.scrollTop;
	var screen_left = window.document.body.scrollLeft;
	
	//alert("screen_height="+ screen_height +"|screen_width="+screen_width);
	//alert("screen_top="+ screen_top +"|screen_left="+screen_left);
	//alert("mouse_left="+ mouse_left +"|mouse_top="+mouse_top);
	
	if(div_name=="client_pop_menu"){
		menu_width_size = 140;
		menu_height_size = 175;
	} else {
		menu_width_size = 140;
		menu_height_size = 70;
	}
	
	if(eval(screen_height-mouse_top-menu_height_size)<0 ){
		menu_pos_y = mouse_top - menu_height_size;
	} else {
		menu_pos_y = mouse_top;
	}
	
	if(eval(screen_width-mouse_left-menu_width_size)<0 ){
		menu_pos_x = mouse_left-menu_width_size;
	} else {
		menu_pos_x = mouse_left;
	}
	
	if(menu_pos_y>screen_height) menu_pos_y = screen_height-menu_height_size;
	if(menu_pos_x>screen_width) menu_pos_x = screen_width-menu_width_size;
	if(menu_pos_y<0) menu_pos_y=0;
	if(menu_pos_x<0) menu_pos_x=0;
	
	eval(div_name+".style.top = menu_pos_y+screen_top");
	eval(div_name+".style.left = menu_pos_x+screen_left");
	
	return;
}

function client_info_view(client_uid){
	var sUrl = "/biz/member/info_view.jsp";
		sUrl +="?client_uid="+ client_uid;

	if(location.href.indexOf("/client/")>=0 || location.href.indexOf("/client_")>=0 ){
		sUrl +="&flag=client";
		ifrm_common_location(sUrl);
	} else {
		open_win_center(sUrl, "","404","200");
	}
	return;
}

function bizAddFriend_PopMenu(){
	addFriend(pop_menu_client_uid+"|"+pop_menu_client_id);
	return;
}
function bizVoiceMsg_PopMenu(){
	SendVoiceMsg(pop_menu_client_uid,pop_menu_client_id );
	return;
}
function bizChrMsg_PopMenu(){
	SendCharMsg(pop_menu_client_uid,pop_menu_client_id );
	return;
}
function bizSmsMsg_PopMenu(){
	SendSmsMsg('biz','','',pop_menu_client_uid, 'client_uid');
	return;
}
function bizInfoView_PopMenu(){
	client_info_view(pop_menu_client_uid)
	return;
}
function bizCallToUser_PopMenu( flg ){
	CallToUser(pop_menu_client_uid, flg);
	return;
}


function bizGroupVoiceMsg_PopMenu(){
	var str = getGroupMemberList(pop_menu_group_uid)
	if(str=="") { return;}

	var strClient_Uid = getTagValue(str,"client_uid")
	var strClient_Id = getTagValue(str,"client_id")

	if(strClient_Uid.indexOf("|")>=0){
		var arrClient_Uid = strClient_Uid.split("|");
		var arrClient_Id = strClient_Id.split("|");
		SendVoiceMsg(arrClient_Uid,arrClient_Id );
	}else{
		SendVoiceMsg(strClient_Uid,strClient_Id );
	}

	return;
}

function bizGroupChrMsg_PopMenu(){
	var str = getGroupMemberList(pop_menu_group_uid)
	if(str=="") { return;}

	var strClient_Uid = getTagValue(str,"client_uid")
	var strClient_Id = getTagValue(str,"client_id")

	if(strClient_Uid.indexOf("|")>=0){
		var arrClient_Uid = strClient_Uid.split("|");
		var arrClient_Id = strClient_Id.split("|");
		SendCharMsg(arrClient_Uid,arrClient_Id );
	}else{
		SendCharMsg(strClient_Uid,strClient_Id );
	}
	return;
}

function bizGroupSmsMsg_PopMenu(){
	SendSmsMsg('biz','','',pop_menu_group_uid, 'group_uid');
	return;
}

function bizGroupView_PopMenu(){
	var target,url;
	if(top.biz_body) {target = top.biz_body}
	else if(parent.biz_body) {target = parent.biz_body}  
	else {target=window}
	if (location.pathname == '/biz/tree/tree_biz_member_pop.jsp') 
		url = '/biz/tree/tree_biz_member_pop.jsp';
	else
		url = '/member_search.do';

	target.location.href = url + '?groupUid=' + pop_menu_group_uid;
	return;
}


function getGroupMemberList(group_uid){
	//alert("group_uid="+group_uid);
	if(group_uid.length==0) { return alert("그룹 아이디가 입력되지 않았습니다.");}
	var str = virtualGetData('/biz/include/get_group_member_list.jsp?group_uid='+group_uid);
	//alert(str);
	var result = getTagValue(str,"result");
	
	if( "1" == result){
		return str;
	} else {
		msg  = getTagValue(str,"msg");
		alert(msg);
		return "";
	}
}


function bizAdminMenu_PopMenu(){
	alert('어디로 보내지');
	return;
}

function bizGroupAdminMenu_PopMenu(){
	alert('그룹 어디로 보내지');
	return;
}








