jQuery(document).ready(function($){
	/****************************************************************/
	// Send Message : Message List
	if($("#MobileSendMsg").is("div")) {
		$.post("./wtp_send_message.ajax.php", MobileSendMsgHandler);
	}
	
	function MobileSendMsgHandler(data) {
		$("#MobileSendMsg").html(data);
		$("#MobileSendMsg").find(".mBtn_mms").click(function () {
			$("#MobileSendMsg").html('<div style="text-align:center;vertical-align: middle"><p /><p /><img alt="loading..." src="./images/ajax-loader.gif"/></div>');
			$.post($(this).attr("info"), MobileSendMsgHandler);
		});
		$("#MobileSendMsg").find(".mBtn_psms").click(function () {
			$("#MobileSendMsg").html('<div style="text-align:center;vertical-align: middle"><p /><p /><img alt="loading..." src="./images/ajax-loader.gif"/></div>');
			$.post($(this).attr("info"), MobileSendMsgHandler);
		});
		$("#MobileSendMsg").find("a.JQBTN_IMAGE").click(function () {
			var imgType = $("#MobileSendMsg").find("input[@type=hidden][@name=type]").val();
			if( imgType == "PMSS" ) {
				$("#MobilePhone").find("input[@type=hidden][@name=type]").val("PMSS");
				$("#MobilePhone").find("div.JQINPUTAREA > div").remove();
				$("#MobilePhone").find("div.JQINPUTAREA").prepend("<div class=\"hp_image2_bg\"><input type=\"hidden\" name=\"album\" value=\""+$(this).attr("info")+"\" /><img src=\""+$(this).find("img").attr("src")+"\" class=\"hp_image2\"/></div>");
			}else if( imgType == "MMSP" ) {
				$("#MobilePhone").find("input[@type=hidden][@name=type]").val("MMSP");
				$("#MobilePhone").find("div.JQINPUTAREA > div").remove();
				$("#MobilePhone").find("div.JQINPUTAREA").prepend("<div class=\"hp_image_bg\"><input type=\"hidden\" name=\"album\" value=\""+$(this).attr("info")+"\" /><img src=\""+$(this).find("img").attr("src")+"\" class=\"hp_image\"  /></div>");
			}
		});
		$("#MobileSendMsg").find("#search_btn").click(function () {
			var p_type = $("#MobileSendMsg").find("input[@name=type]").val();
			var p_schstr = $("#MobileSendMsg").find("input[@name=schstr]").val();
			//var p_orderbwy = $("#MobileSendMsg").find("input[@name=orderby][@checked]").val();
			$("#MobileSendMsg").html('<div style="text-align:center;vertical-align: middle"><p /><p /><img alt="loading..." src="./images/ajax-loader.gif"/></div>');
			$.post("./wtp_send_message.ajax.php?type="+p_type+"&schstr="+p_schstr, MobileSendMsgHandler);
		});
		$("#MobileSendMsg").find("a.JQBTN_PAGE").click(function () {
			$("#MobileSendMsg").html('<div style="text-align:center;vertical-align: middle"><p /><p /><img alt="loading..." src="./images/ajax-loader.gif"/></div>');
			$.post("./wtp_send_message.ajax.php?"+$(this).attr("info"), MobileSendMsgHandler);
		});
	}
	
	
	/****************************************************************/
	// Send Message : Phone
	if($("#MobilePhone").is("div")) {
		$.post("./wtp_phone.ajax.php", MobilePhoneHandler);
	}
	
	function CheckTSelNumber(msisdn) {
		if( msisdn.length < 10)
			return false;

		var expMsisdn = /^(62811|0811|811|62812|0812|812|62813|0813|813|62852|0852|852|62853|0853|853)/;
		return expMsisdn.test(msisdn);
	}
	
	function MobilePhoneHandler(data) {
		$("#MobilePhone").html(data);
		if($("#RecvNameList").attr("info") == 'Y') {
			var end = $("#RecvNameList").children().length;
			for(var cnt=1;cnt<=end;cnt++) {
				var kid = $("#RecvNameList > div:nth-child("+cnt+")").attr("id");
				var knm = $("#RecvNameList > div:nth-child("+cnt+")").attr("info");
				$("#MobilePhone").find("div.JQRECIPIENT").append("<dl class=\"ml15\"><dd class=\"mText08\"><span>"+knm+"</span></dd><dd class=\"mt5\"><input type=\"hidden\" name=\"ck[]\" value=\""+kid+"\" /><a info=\"\"><img src=\"./images/wtp/miDel_sms.gif\"/></a></dd></dl>");
			}
			$("#RecvNameList").attr({info: 'N'});
			$("#RecvNameList > div").remove();
		}
		$("#MobilePhone").find("dd.mt5").click(function () {
			$(this).parent().remove();
		});
		$("#MobilePhone").find("#JQSET_MSISDN").click(function () {
			var msisdn = $("#MobilePhone").find("#JQMSISDN").val();
			if( isNaN(msisdn) ) {
				alert("please input only numbers");
				$("#MobilePhone").find("#JQMSISDN").val("");
				return false;
			}else if( CheckTSelNumber(msisdn) ) {
				$("#MobilePhone").find("#JQMSISDN").val("");
				$("#MobilePhone").find("div.JQRECIPIENT").append("<dl class=\"ml15\"><dd class=\"mText08\"><span>"+msisdn+"</span></dd><dd class=\"mt5\"><input type=\"hidden\" name=\"ck[]\" value=\"m"+msisdn+"\" /><a info=\"\"><img src=\"./images/wtp/miDel_sms.gif\"/></a></dd></dl>");
				$("#MobilePhone").find("dd.mt5").click(function () {
					$(this).parent().remove();
				});
			}else {
				alert($("#MobilePhone").find("#MOBILE_MSG_NON_TSELUSER").attr("info"));
			}
		});
		$("#MobilePhone").find("#JQCLR_IMG").click(function () {
			$("#MobilePhone").find("input[@type=hidden][@name=type]").val("WDC");
			$("#MobilePhone").find("div.JQINPUTAREA > div").remove();
		});
		$("#MobilePhone").find("#JQMSISDN").keydown(function (event) {
			var keyCode = event.keyCode;
			if(keyCode == 13 && $.trim($(this).val()).length > 0) {
				$("#MobilePhone").find("#JQSET_MSISDN").click();
			}else if(!(keyCode > 47 && keyCode < 58 || keyCode > 95 && keyCode < 106 || keyCode == 8 || keyCode == 46)) {
				return false;
			}
		});
		$("#MobilePhone").find("#JQMSISDN").focus(function () {
			
		});
		$("#MobilePhone").find("#JQMSISDN").blur(function () {
			
		});
		$("#MobilePhone").find("#btn_usecoco").click(function () {
			if(answer = confirm("Do you want to use coco?")) {
				$.post("./wtp_checkcoco.ajax.php?type="+$("#MobilePhone").find("#msgtype").val(), function(data) {
					if( data == "true" ) {
						$("#MobilePhone").find("#usecoco").val("1");
						$("#MobilePhone").find(".mBtn_send").click();					
					}else{
						alert(data);	
					}
				});
			}
		});
		$("#MobilePhone").find(".mBtn_reset").click(function () {
			$("#RecvNameList").attr({info: 'N'});
			$("#RecvNameList > div").remove();
			$("#MobilePhone").find("input[@type=hidden][@name=type]").val("WDC");
			$("#MobilePhone").find("div.JQRECIPIENT > dl").remove();
			$("#MobilePhone").find("div.JQINPUTAREA > div").remove();
			$("#MobilePhone").find("div.JQINPUTAREA > textarea").val("");
			$("#MobilePhone").find("div.JQINPUTAREA > textarea").focus();
			$("#MobilePhone").find("span.JQBYTE_TEXT").html(
				"<b>0/"
				+ $("#MobilePhone").find("#MOBILE_MSG_MAX").attr("info")
				+ "</b> "
				+ $("#MobilePhone").find("#MOBILE_MSG_LIMIT_CHAR").attr("info"));
		});
		$("#MobilePhone").find(".mBtn_send").click(function () {
			if($("#MobilePhone").find("div.JQRECIPIENT > dl").length < 1) {
				alert($("#MobilePhone").find("#MOBILE_EMPTY_RECVLIST_MSG").attr("info"));
			}else{
				$.post("./wtp_phone.ajax.php", $("form").serialize(), MobilePhoneHandler);
				alert($("#MobilePhone").find("#MOBILE_MSG_SEND_COMPLETE").attr("info"));
				//alert($("form").serialize());
			}
		});
		$("#MobilePhone").find("div.JQINPUTAREA > textarea").keyup(function (event) {
			var str_msg = $(this).attr("value");
			var str_msg_len = 0;
			var str_one = "";
			var str_byte = 0;
			var str_len = 0;
			var str_max = $("#MobilePhone").find("#MOBILE_MSG_MAX").attr("info");

			if( str_msg ) {
				str_msg_len = str_msg.length;
			}
			
			for(cnt=0;cnt<str_msg_len;cnt++) {
				str_one = str_msg.charAt(cnt);
				
				if(escape(str_one).length > 4) {
					str_byte += 2;
				}else{
					str_byte += 1;
				}
				
				if(str_byte <= str_max) {
					str_len = cnt + 1;
				}
			}
			
			if(str_byte > str_max) {
				alert($("#MobilePhone").find("#MOBILE_BYTEOVER_MSG").attr("info"));
				$(this).attr("value", str_msg.substr(0,str_len))
			}
			$("#MobilePhone").find("span.JQBYTE_TEXT").html(
				"<b>"+str_len 
				+ "/" 
				+ $("#MobilePhone").find("#MOBILE_MSG_MAX").attr("info")
				+ "</b> "
				+ $("#MobilePhone").find("#MOBILE_MSG_LIMIT_CHAR").attr("info"));
		});
	}
	
	/****************************************************************/
	// Message history
	if($("#MobileMsgHis").is("div")) {
		if($("input[@type=checkbox][@name=b_date]").val() == 'Y') {
			$("select.JQ_ENABLE").removeAttr("disabled");
		}
		$("input[@type=checkbox][@name=b_date]").click(function () {
			if( this.checked ) {
				$("select.JQ_ENABLE").removeAttr("disabled");
				$(this).val("Y");
			}else{
				$("select.JQ_ENABLE").attr("disabled", "disabled");
				$(this).val("N");
			}
		});
		
		$("a.JQSEARCH").click(function () {
			$("form[@name=msg_search]").submit();
		});
		
		$("form[@name=msg_search]").submit(function () {
				if($("input[@name=b_date]").val() == 'Y' && (
					 $("select[@name=from_day]").val() == 0 ||
					 $("select[@name=from_month]").val() == 0 ||
					 $("select[@name=from_year]").val() == 0 ||
					 $("select[@name=to_day]").val() == 0 ||
					 $("select[@name=to_month]").val() == 0 ||
					 $("select[@name=to_year]").val() == 0 )) {
					alert("Please, select the date");
					return false;
				}
				return true;
		});
		
		$("a.JQDELETE_ALLMSG").click(function () {
			if($("#MobileMsgHis").find("input[@type=checkbox][@name^=ck][@checked]").length < 1) {
				alert($("#MobileMsgHis").find("#NOT_SELECTED_MSG").attr("info"));
			}else{
				var ans = confirm($("#MobileMsgHis").find("#DELETE_CONFIRM_MSG").attr("info"));
				if(ans) {
					$("form[@name=msg_delete]").submit();
				}
			}
		});
		
		$("a.JQSEND_MSG").click(function () {
			location.href = './user_wtp.php?'+$(this).attr("info");
		});
		
		$("a.JQBTN_PAGE").click(function () {
			location.href = './user_wtphistory.php?'+$(this).attr("info");
		});

//		$("td.JQMESSAGE").hover(
//			function () {
//				$(this).append("
//				<div id=\"pop\" class=\"mpInfo\" style=\"left: 270px; top: 220px;\">
//						MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMM
//				</div>
//				");
//			},
//			function () {
//				$("#pop").remove();
//			}
//		);
	}
	
	/****************************************************************/
	// Address book : Group List
	if($("#MobileGroupList").is("div")) {
		$.post("./wtp_address_group_list.ajax.php", MobileGroupListHandler);
	}
	
	function MobileGroupListHandler(data) {
		$("#MobileGroupList").html(data);
		$("#MobileMemberList").find("a.JQVIEW_GROUP_MEMBER").click(function () {
			alert("view member");
		});
		$("#MobileGroupList").find("a.JQCREATE_GROUP").click(function () {
			$("#MobileMemberList").html('<div style="text-align:center;vertical-align: middle"><p /><p /><img alt="loading..." src="./images/ajax-loader.gif"/></div>');
			$.post("./wtp_address_group_mng.ajax.php?"+$(this).attr("info"), MobileGroupSetHandler);
		});
		$("#MobileGroupList").find("a.JQMODIFY_GROUP").click(function () {
			$("#MobileMemberList").html('<div style="text-align:center;vertical-align: middle"><p /><p /><img alt="loading..." src="./images/ajax-loader.gif"/></div>');
			$.post("./wtp_address_group_mng.ajax.php?"+$(this).attr("info"), MobileGroupSetHandler);
		});
		$("#MobileGroupList").find("a.JQDELETE_GROUP").click(function () {
			var ans = confirm($("#MobileGroupList").find("#DELETE_CONFIRM_MSG").attr("info"));
			if(ans) {
				$("#MobileMemberList").html('<div style="text-align:center;vertical-align: middle"><p /><p /><img alt="loading..." src="./images/ajax-loader.gif"/></div>');
				$.post("./wtp_address_group_mng.ajax.php?"+$(this).attr("info"), MobileGroupSetExecHandler);
			}
		});
		$("#MobileGroupList").find("a.JQVIEW_SEARCH_LIST").click(function () {
			$("#MobileMemberList").html('<div style="text-align:center;vertical-align: middle"><p /><p /><img alt="loading..." src="./images/ajax-loader.gif"/></div>');
			$.post("./wtp_address_member_list.ajax.php?"+$(this).attr("info"), MobileListForSearchHandler);
		});
		$("#MobileGroupList").find("a.JQVIEW_MEMBER_LIST").click(function () {
			$("#MobileMemberList").html('<div style="text-align:center;vertical-align: middle"><p /><p /><img alt="loading..." src="./images/ajax-loader.gif"/></div>');
			$.post("./wtp_address_member_list.ajax.php?"+$(this).attr("info"), MobileListForMemberHandler);
		});
		$("#MobileGroupList").find("a.JQADDR_SEARCH").click(function() {
			$("#MobileMemberList").html('<div style="text-align:center;vertical-align: middle"><p /><p /><img alt="loading..." src="./images/ajax-loader.gif"/></div>');
			$.post("./wtp_address_member_list.ajax.php?"+$(this).attr("info"), $("form").serialize(), MobileListForMemberHandler);
		});
		$("#MobileGroupList").find("input[name='schstr']").keydown(function (event) {
			if(event.keyCode == 13) {
				$("#MobileGroupList").find("a.JQADDR_SEARCH").click();
			}
		});
	}
	
	/****************************************************************/
	// Address book : Group Create or Modify
	function MobileGroupSetHandler(data) {
		$("#MobileMemberList").html(data);
		var obj_name = $("#MobileMemberList").find("input[@name=groupname]");
		$(obj_name).focus();
		$(obj_name).keydown(function () {
			$("#MobileMemberList").find("input[@name=checkyn]").val('FAIL');
		});
		$(obj_name).change(function () {
			$("#MobileMemberList").find("input[@name=checkyn]").val('FAIL');
		});
		$("#MobileMemberList").find("a.JQCHECKNAME").click(function () {
			var str_name = $(this).parent().prev().children("input[@name=groupname").val();
			var str_desc = $(this).parent().next().children("textarea[@name=groupdesc").val();
			
			if($.trim(str_name).length < 3) {
				alert($("#MobileMemberList").find("#MSG_GROUPNAME_CHK_FIELD").attr("info"));
			}else{
				$.post("./wtp_address_group_mng.ajax.php?"+$(this).attr("info"), { groupname: str_name, groupdesc: str_desc }, MobileGroupChknameHandler);
			}
		});
		$("#MobileMemberList").find("a.JQBTN_OK").click(function () {
			if($("#MobileMemberList").find("input[@name=checkyn]").val() == 'SUCC') {
				var str_name = $("#MobileMemberList").find("input[@name=groupname]").val();
				var str_desc = $("#MobileMemberList").find("textarea[@name=groupdesc]").val();
				$.post("./wtp_address_group_mng.ajax.php?"+$(this).attr("info"), { groupname: str_name, groupdesc: str_desc }, MobileGroupSetExecHandler);
			}else{
				alert($("#MobileMemberList").find("#MSG_GROUPNAME_CHK").attr("info"));
			}
		});
		$("#MobileMemberList").find("a.JQBTN_CANCEL").click(function () {
			// Ãë¼Ò ¹öÆ°À» ´©¸£¸é ¾î¶»°Ô ÇÒ °ÍÀÎ°¡
		});
	}
	
	/****************************************************************/
	// Address book : Group Name Check
	function MobileGroupChknameHandler(data) {
		$("#MobileMemberList").find("input[@name=checkyn]").val(data);
		if(data == 'SUCC') {
			alert($("#MobileMemberList").find("#MSG_GROUPNAME_CHK_SUCC").attr("info"));
		}else{
			alert($("#MobileMemberList").find("#MSG_GROUPNAME_CHK_FAIL").attr("info"));
		}
	}
	
	/****************************************************************/
	// Address book : Group Name Create or Modify or Delete
	function MobileGroupSetExecHandler(data) {
		if(data == 'SUCC') {
			// ±×·ì »ý¼º ¶Ç´Â ¼öÁ¤¿¡ ¼º°øÇÏ¸é ¾î¶»°Ô ÇÒ °ÍÀÎ°¡
			$.post("./wtp_address_group_list.ajax.php", MobileGroupListHandler);
			$.post("./wtp_address_member_list.ajax.php", MobileListForMemberHandler);
		}else if(data == 'FAIL') {
			// ±×·ì »ý¼º ¶Ç´Â ¼öÁ¤¿¡ ½ÇÆÐÇÏ¸é ¾î¶»°Ô ÇÒ °ÍÀÎ°¡
			// alert('FAIL');
		}
	}
	
	/****************************************************************/
	// Address book : Member Create or Modify
	function MobileMemberSetHandler(data) {
		$("#MobileMemberList").html(data);
		$("#MobileMemberList").find("a.JQBTN_OK").click(function () {
			var param = $("#MobileMemberList").find("form").serialize();
			$.post("./wtp_address_member_mng.ajax.php?"+$(this).attr("info"), param, MobileMemberSetExecHandler);
		});
	}
	
	/****************************************************************/
	// Address book : Member Create or Modify
	function MobileMemberSetExecHandler(data) {
		if(data == 'SUCC') {
			$.post("./wtp_address_member_list.ajax.php", MobileListForMemberHandler);
		}else if(data == 'FAIL') {
			
		}
	}
	
	/****************************************************************/
	// Address book : Member List
	if($("#MobileMemberList").is("div")) {
		$.post("./wtp_address_member_list.ajax.php", MobileListForMemberHandler);
	}
	
	function MobileListForMemberHandler(data) {
		$("#MobileMemberList").html(data);
		$("#MobileMemberList").find("#ckAll").click(function () {
			if(this.checked) {
				$("#MobileMemberList").find("input[@type=checkbox][@name^=ck]").check();
			}else{
				$("#MobileMemberList").find("input[@type=checkbox][@name^=ck]").uncheck();
			}
		});
		$("#MobileMemberList").find("a.JQSEND_ALLMEMBER").click(function () {
			if($("#MobileMemberList").find("input[@type=checkbox][@name^=ck][@checked]").length < 1) {
				alert($("#MobileMemberList").find("#NOT_SELECTED_MSG").attr("info"));
			}else{
				$("#MobileMemberList").find("form[@name=address_list]").attr({action: "./user_wtp.php?"+$(this).attr("info")});
				$("#MobileMemberList").find("form[@name=address_list]").submit();
			}
		});
		$("#MobileMemberList").find("a.JQMODIFY_ALLMEMBER").click(function () {
			if($("#MobileMemberList").find("input[@type=checkbox][@name^=ck][@checked]").length < 1) {
				alert($("#MobileMemberList").find("#NOT_SELECTED_MSG").attr("info"));
			}else{
				var param = $("#MobileMemberList").find("form[@name=address_list]").serialize();
				$.post("./wtp_address_member_mng.ajax.php?"+$(this).attr("info"), {post_param: param}, MobileMemberSetHandler);
			}
		});
		$("#MobileMemberList").find("a.JQDELETE_ALLMEMBER").click(function () {
			if($("#MobileMemberList").find("input[@type=checkbox][@name^=ck][@checked]").length < 1) {
				alert($("#MobileMemberList").find("#NOT_SELECTED_MSG").attr("info"));
			}else{
				var ans = confirm($("#MobileMemberList").find("#DELETE_CONFIRM_MSG2").attr("info"));
				if(ans) {
					var param = $("#MobileMemberList").find("form[@name=address_list]").serialize();
					$.post("./wtp_address_member_mng.ajax.php?"+$(this).attr("info"), param, MobileMemberSetExecHandler);
				}
			}
		});
		$("#MobileMemberList").find("a.JQSEND_MEMBER").click(function () {
			location.href = './user_wtp.php?'+$(this).attr("info");
		});
		$("#MobileMemberList").find("a.JQMODIFY_MEMBER").click(function () {
			$.post("./wtp_address_member_mng.ajax.php?"+$(this).attr("info"), MobileMemberSetHandler);
		});
		$("#MobileMemberList").find("a.JQDELETE_MEMBER").click(function () {
			var ans = confirm($("#MobileMemberList").find("#DELETE_CONFIRM_MSG").attr("info"));
			if(ans) {
				$.post("./wtp_address_member_mng.ajax.php?"+$(this).attr("info"), MobileMemberSetExecHandler);
			}
		});
		$("#MobileMemberList").find("a.JQBTN_PAGE").click(function () {
			$.post("./wtp_address_member_list.ajax.php?"+$(this).attr("info"), MobileListForMemberHandler);
		});
	}

	function MobileListForSearchHandler(data) {
		$("#MobileMemberList").html(data);
		$("#MobileMemberList").find("input[@name=schstr]").focus();
		$("#MobileMemberList").find("input[@name=schstr]").keydown(function (event) {
			if(event.keyCode == 13) {
				$("#MobileMemberList").find("a.JQBTN_SEARCH").click();
			}
		});
		$("#MobileMemberList").find("a.JQBTN_SEARCH").click(function () {			
			var p_schstr = $("#MobileMemberList").find("input[@name=schstr]").val();
			if(p_schstr.length < 3) {
				alert($("#MobileMemberList").find("#MOBILE_SEARCH_CHAR_LIMIT_MSG").attr("info"));
				$("#MobileMemberList").find("input[@name=schstr]").focus()
			}else{
				$("#MobileMemberList").html('<div style="text-align:center;vertical-align: middle"><p /><p /><img alt="loading..." src="./images/ajax-loader.gif"/></div>');
				$.post("./wtp_address_member_list.ajax.php?"+$(this).attr("info"), { schstr: p_schstr }, MobileListForSearchHandler);
			}
		});
		$("#MobileMemberList").find("#ckAll").click(function () {
			if(this.checked) {
				$("#MobileMemberList").find("input[@type=checkbox][@name^=ck]").check();
			}else{
				$("#MobileMemberList").find("input[@type=checkbox][@name^=ck]").uncheck();
			}
		});
		$("#MobileMemberList").find("a.JQADD_ALLMEMBER").click(function () {
			if($("#MobileMemberList").find("input[@type=checkbox][@name^=ck][@checked]").length < 1) {
				alert($("#MobileMemberList").find("#NOT_SELECTED_MSG").attr("info"));
			}else{
				var param = $("#MobileMemberList").find("form[@name=add_member]").serialize();
				$("#MobileMemberList").html('<div style="text-align:center;vertical-align: middle"><p /><p /><img alt="loading..." src="./images/ajax-loader.gif"/></div>');
				$.post("./wtp_address_member_mng.ajax.php?"+$(this).attr("info"), param, MobileMemberSetExecHandler);
			}
		});
		$("#MobileMemberList").find("a.JQADD_ONEMEMBER").click(function () {
			$("#MobileMemberList").find("#"+$(this).attr("info")).check();
			$("#MobileMemberList").find("a.JQADD_ALLMEMBER").click();
		});
		$("#MobileMemberList").find("a.JQBTN_PAGE").click(function () {
			$("#MobileMemberList").html('<div style="text-align:center;vertical-align: middle"><p /><p /><img alt="loading..." src="./images/ajax-loader.gif"/></div>');
			$.post("./wtp_address_member_list.ajax.php?"+$(this).attr("info"), MobileListForSearchHandler);
		});
	}
	
	/****************************************************************/
	// Address book : Popup Addressbook
	if($("#mpop_body").is("div")) {
		$("a.JQADDR_SEARCH").click(function() {
			$("#ADDRSEARCH").submit();
		});
		
		$("a.JQBTN_OK").click(function () {
			$("input[@type='checkbox'][@name^='ck'][@checked]").each(function () {
				var str = $(this).attr("info");
				var el = $.grep($("#MobilePhone", window.parent.document).find("div > dl > dd > span"), function (el) {return $(el).text() == str;});
				if(!$(el).text()) {
					$("#MobilePhone", window.parent.document).find("div.JQRECIPIENT").append("<dl class=\"ml15\"><dd class=\"mText08\"><span>"+$(this).attr("info")+"</span></dd><dd class=\"mt5\"><input type=\"hidden\" name=\"ck[]\" value=\""+$(this).val()+"\" /><a info=\"\"><img src=\"./images/wtp/miDel_sms.gif\"/></a></dd></dl>");
				}
			});
			
			$("#MobilePhone", window.parent.document).find("dd.mt5").click(function () {
				$(this).parent().remove();
			});
			parent.TB_remove();
		});
	}
});
