﻿//--------------------------------------------------------------------------------------------------//
//																									//
//	Functions																						//
//	copyright(C)2009 lcc inc. all rights reserved													//
//--------------------------------------------------------------------------------------------------//
var xmlModule 		= "./_xml.asp";
var delgateModule	= "./pPDF_Delegate.asp";
var csvModule		= "./out_CSV.asp";
var xmlRetry		= new Array(99);	//xml RetryCount
var xmlRetryLimt	= 3;				//xml Retry Limit
var xmlRetryTimeout	= 5000;				//xml Retry Timeout

var uploader	="_js/upload/uploadify.swf";
var script		="_js/upload/uploadify_district.asp";
var cancelImg	="_js/upload/cancel.png";

var loadNews_n	= 0;
var getGpNews_n	= 1;
var dateSort_n	= 2;
var getContentsData_n = 3;
var get_comm_yr_n		= 35;
var get_comm_n			= 36;
var get_comm_pos_n		= 38;
var reg_CMQuery_n		= 39;
var get_keyupQuery_n	= 37;
var get_mouseoverQuery_n= 40;
var get_memData_n		= 41;
var get_Pos_n			= 42;
var get_GnrSelection_n	= 43;
var get_Ocupation_n		= 44;
var reg_memEdit_n		= 45;
var reg_sendGroup_n		= 48;
var edit_sendGroup_n	= 51;
var get_SGList_n		= 49;
var get_SGmem_n			= 50;
var del_SG_n			= 52;
var get_CPCS_n			= 46;
var chk_comMem_n		= 64;
var reg_comMem_n		= 60;
var reg_clubMem_n		= 62;
var get_ds_n			= 30;
var reg_ds_n			= 31;
var del_ds_n			= 32;
var get_dt_n			= 47;
var get_AttedList_n		= 59;
var get_AttedList_comm_n= 61;
var reg_atChg_n			= 65;
var get_committee_n		= 33;
var get_keyupQuery_calen_n= 57;
var get_visit_n			= 34;
var get_sendGP_n		= 53;
var chg_sendGP_n		= 54;
var send_com_n			= 58;
var send_club_n			= 63;
var get_attendClub_n	= 55;
var get_clubM_n			= 56;
var chk_LoginInf_n		= 28;			// 10/04/01 Tagaya
var get_DispID_n		= 29;			// 10/04/01 Tagaya

xmlRetry["get_calen_yr"]	= 0;
xmlRetry["get_calen"]		= 0;
xmlRetry["get_clenTmp"]		= 0;
xmlRetry["reg_clenTmptUp"]	= 0;
xmlRetry["del_clenTmp"]		= 0;
xmlRetry["send_unconf"]		= 0;
xmlRetry["create_delgate"]	= 0;
xmlRetry["create_csv"]		= 0;

//================================================================================================== ready
$().ready(function(){
	for (i=0; i<xmlRetry.length; i++) xmlRetry[i]=0 ;

	//------------------------------------------------------------ 全グループの最新記事を取得
	if (document.getElementById("gpList1")) {	//グループリストが存在する場合
		loadNews();								//ページ読み込み時に全グループの最新記事を取得
	}

	//------------------------------------------------------------ クリックされたグループの記事一覧を取得 (便りを全て表示)
	$("p[id*='gp']").each(function(idx, elm) {
		$("#gp"+(idx+1)).click(function () {
			if ($("#gpToggle"+(idx+1)).is(':hidden')) {	//記事が閉じられているか
				getGpNews(idx);							//グループの記事一覧を取得
			} else {
				$("#gpToggle"+(idx+1)).slideUp("fast");
			}
		});
	});

	//------------------------------------------------------------ 全グループの最新記事を表示 (全てを開く)
	$(".opBtn").click(function () {
		loadNews();
	});
	//------------------------------------------------------------ 全グループの記事を閉じる (全てを閉じる)
	$(".clBtn").click(function () {
		for (var i=1;i<10; i++) $("#gpToggle"+i).slideUp("fast");   //slideUp
	});

	//------------------------------------------------------------ 新着順表示に切り替え (新着順)
	$(".dtBtn").click(function () {
		dateSort();
	});

	//------------------------------------------------------------ グループ順の記事を表示 (グループ順)
	$(".gpBtn").click(function () {
		$("#dateSort").slideUp("slow");	//新着順非表示
		$("#dateSort ul").remove();		//新着順をremove
		$("#gpSort").slideDown("slow");	//グループ順表示
		$(".tglPanel").toggle("slow");	//ボタンのtoggle
	});

	//------------------------------------------------------------ グループ順・新着順・全てを開く・閉じるのhover
	$(".tglPanel img").hover(
		function () {
			$(this).addClass("ocBtnHver");
		},
		function () {
			$(this).removeClass("ocBtnHver");
		}
	);

	//------------------------------------------------------------ グループ名のhover
	$(".gpTitle").hover(
		function () {
			$(this).addClass("gpTitleHver");
		},
		function () {
			$(this).removeClass("gpTitleHver");
		}
	);

	//------------------------------------------------------------ 地区委員会 切替え年度取得
	if ($("#chg_comm_yr").length) {
		get_comm_yr();
		get_comm_pos();										//役職selectBox表示イベント
		evt_comSelect($("#committeeAria table tr .kNM"))	//kNMの選択 イベント追加
		evt_comDel();										//kNMの削除 イベント追加
		evt_contxtM();										//contextMenu イベント追加
	}

	//------------------------------------------------------------ 地区委員会 年度切り替え
	$("#chg_comm_yr").change(function () {
		if (!$("#SGdlog").length && !$("#SGListdlog").length) get_comm();
	});

	//------------------------------------------------------------ 地区委員会 Rotarian選択
	$("#add_comMem").click(function () {
		open_CM();
	});

	//------------------------------------------------------------ 地区委員会 会長・幹事一覧
	$("#add_CPCS").click(function () {
		open_CPCS();
	});

	//------------------------------------------------------------ 地区委員会 役員の登録
	$("#reg_comMem").click(function () {
		chk_CM_dlg();
	});

	//------------------------------------------------------------ 地区委員会 送信グループを作成
	$("#reg_sendGrp").click(function () {
		open_SG(0);
	});

	//------------------------------------------------------------ 地区委員会 送信グループを編集
	$("#edit_sendGrp").click(function () {
		open_SGList();
	});

	//------------------------------------------------------------ カレンダー 切替え年度取得
	if ($("#chg_calen_yr").length) {
		get_calen_yr();
	}

	//------------------------------------------------------------ カレンダー 年度切り替え
	$("#chg_calen_yr").change(function () {
		//if (!$("#SGdlog").length && !$("#SGListdlog").length) get_Calen();
		get_Calen();
	});

	//------------------------------------------------------------ カレンダー 新規登録
	$("#DSadd").click(function () {
		open_DS(0);
	});

	//------------------------------------------------------------ カレンダー 編集/hover
	if ($("#DCTbl").length) {
		addEvt_DS();
	}

	//------------------------------------------------------------ アコーディオン制御 10/04/01 Tagaya
//	if ($.browser.msie && $.browser.version=="6.0")	// 2010/03/08 IE6.0

	if ($("#accordion").length) {
		if ($.browser.msie )	// 2010/04/01 IE
		{
			$("#accordion").accordion({
				autoHeight: false,
				animated: false
			});
		}
		else
		{
			$("#accordion").accordion({
				autoHeight: false,
				navigation: false
			});
		}
	}
	
	//------------------------------------------------------------ 委員会メイン･メニュー押下処理 10/04/01 Tagaya
	$("#job_service").click(function() {
		$("div[id^='public_rel']").hide();
		$("div[id^='family_comm']").hide();
		$("div[id^='gse_com']").hide();
		$("div[id^='rinfo_com']").hide();
		$("div[id^='fVision_com']").hide();
		$("div[id^='MemRetention_com']").hide();
		$("#comm_list").hide();
		$("#comm_pic").hide();
		$("div[id^='volunteer']").show();
		document.title="職業奉仕委員会 国際ロータリー第２７８０地区 - 委員会";
	});

	$("#GSE_committee").click(function() {
		$("div[id^='public_rel']").hide();
		$("div[id^='volunteer']").hide();
		$("div[id^='rinfo_com']").hide();
		$("div[id^='fVision_com']").hide();
		$("div[id^='MemRetention_com']").hide();
		$("#comm_list").hide();
		$("#comm_pic").hide();
		$("div[id^='gse_com']").show();
		//alert('GSE') ;
		document.title="GSE委員会 国際ロータリー第２７８０地区 - 委員会";
	});

	$("#Rinfo_committee").click(function() {
		$("div[id^='public_rel']").hide();
		$("div[id^='volunteer']").hide();
		$("div[id^='gse_com']").hide();
		$("div[id^='fVision_com']").hide();
		$("div[id^='MemRetention_com']").hide();
		$("#comm_list").hide();
		$("#comm_pic").hide();
		$("div[id^='rinfo_com']").show();
		//alert('Rinfo') ;
		document.title="ロータリー情報委員会 国際ロータリー第２７８０地区 - 委員会";
	});

	$("#FutureVision").click(function() {
		$("div[id^='public_rel']").hide();
		$("div[id^='volunteer']").hide();
		$("div[id^='gse_com']").hide();
		$("div[id^='rinfo_com']").hide();
		$("div[id^='MemRetention_com']").hide();
		$("#comm_list").hide();
		$("#comm_pic").hide();
		$("div[id^='fVision_com']").show();
		//alert('Rinfo') ;
		document.title="「未来の夢計画」準備委員会 国際ロータリー第２７８０地区 - 委員会";
	});

	$("#MembershipRetention").click(function() {
		$("div[id^='public_rel']").hide();
		$("div[id^='volunteer']").hide();
		$("div[id^='gse_com']").hide();
		$("div[id^='rinfo_com']").hide();
		$("div[id^='fVision_com']").hide();
		$("#comm_list").hide();
		$("#comm_pic").hide();
		$("div[id^='MemRetention_com']").show();
		//alert('Rinfo') ;
		document.title="会員増強・維持委員会 国際ロータリー第２７８０地区 - 委員会";
	});

	$("#family_committee").click(function() {
		$("div[id^='public_rel']").hide();
		$("div[id^='volunteer']").hide();
		$("div[id^='gse_com']").hide();
		$("div[id^='rinfo_com']").hide();
		$("div[id^='fVision_com']").hide();
		$("div[id^='MemRetention_com']").hide();
		$("#comm_list").hide();
		$("#comm_pic").hide();
		$("div[id^='family_comm']").show();
		document.title="家族委員会 国際ロータリー第２７８０地区 - 委員会";
	});

	$("#public_committee").click(function() {
		$("div[id^='volunteer']").hide();
		$("div[id^='family_comm']").hide();
		$("div[id^='gse_com']").hide();
		$("div[id^='rinfo_com']").hide();
		$("div[id^='fVision_com']").hide();
		$("div[id^='MemRetention_com']").hide();
		$("#comm_list").hide();
		$("#comm_pic").hide();
		$("div[id^='public_rel']").show();
		document.title="広報委員会 国際ロータリー第２７８０地区 - 委員会";
		
	});
	
	$("#committee_List").click(function() {
		$("div[id^='volunteer']").hide();
		$("div[id^='family_comm']").hide();
		$("div[id^='gse_com']").hide();
		$("div[id^='rinfo_com']").hide();
		$("div[id^='fVision_com']").hide();
		$("div[id^='MemRetention_com']").hide();
		$("div[id^='public_rel']").hide();
		$("#comm_list").show();
		$("#comm_pic").hide();
		document.title="委員会一覧表 国際ロータリー第２７８０地区 - 委員会";
	});

	$("#comm_picture").click(function() {
		$("div[id^='volunteer']").hide();
		$("div[id^='family_comm']").hide();
		$("div[id^='gse_com']").hide();
		$("div[id^='rinfo_com']").hide();
		$("div[id^='fVision_com']").hide();
		$("div[id^='MemRetention_com']").hide();
		$("div[id^='public_rel']").hide();
		$("#comm_list").hide();
		$("#comm_pic").show();
		document.title="委員会系統図 国際ロータリー第２７８０地区 - 委員会";
	});
	
	//------------------------------------------------------------ 委員会サブ･メニュー押下処理 10/04/01 Tagaya
	$("a[id^='PublicRelations']").click(function() {							// 広報
		$("div[id^='volunteer']").hide();
		$("div[id^='family_comm']").hide();
		$("div[id^='GSE_com']").hide();
		$("div[id^='rinfo_com']").hide();
		$("div[id^='fVision_com']").hide();
		$("div[id^='MemRetention_com']").hide();
		$("#comm_list").hide();
		$("#comm_pic").hide();
		$("div[id^='public_rel']").hide();
		var x = $(this).attr("id");
		var s = x.split("PublicRelations");
		var param = xmlModule+'?'+"_xsid="+$("#_xsid").val() + 
				"&_fn=get_DispID" + 
				"&_id=" + s[1] + 
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(){
				xmlRetry[get_DispID_n]++ ;
				if(xmlRetry[get_DispID_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed get_DispID");
				else {
					alert("情報の取得に失敗しました"+get_DispID_n);
					get_Vocational_Service();
				}
			},success: function(httpObj){
				xmlRetry[get_DispID_n]=0;
				var xmlRcS = httpObj.getElementsByTagName("record");
				var news;
				for (var i=0; i<xmlRcS.length; i++) {
					news = "public_rel";
					news = news + xmlNull_chk(xmlRcS[i], "ID", "");
					$("#" + news).show();
				}
			}
		});
	});

	$("a[id^='Vocational']").click(function() {									// 職業奉仕
		$("div[id^='public_rel']").hide();
		$("div[id^='family_comm']").hide();
		$("div[id^='GSE_com']").hide();
		$("div[id^='rinfo_com']").hide();
		$("div[id^='fVision_com']").hide();
		$("div[id^='MemRetention_com']").hide();
		$("#comm_list").hide();
		$("#comm_pic").hide();
		$("div[id^='volunteer']").hide();
		var x = $(this).attr("id");
		var s = x.split("Vocational");
		var param = xmlModule+'?'+"_xsid="+$("#_xsid").val() + 
				"&_fn=get_DispID" + 
				"&_id=" + s[1] + 
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(){
				xmlRetry[gget_DispID_n]++ ;
				if(xmlRetry[get_DispID_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed get_DispID");
				else {
					alert("情報の取得に失敗しました"+get_DispID_n);
					get_Vocational_Service();
				}
			},success: function(httpObj){
				xmlRetry[get_DispID_n]=0;
				var xmlRcS = httpObj.getElementsByTagName("record");
				var news;
				for (var i=0; i<xmlRcS.length; i++) {
					news = "volunteer";
					news = news + xmlNull_chk(xmlRcS[i], "ID", "");
					$("#" + news).show();
				}
			}
		});
	});

	$("a[id^='Family']").click(function() {										// 家族
		$("div[id^='public_rel']").hide();
		$("div[id^='volunteer']").hide();
		$("div[id^='GSE_com']").hide();
		$("div[id^='rinfo_com']").hide();
		$("div[id^='fVision_com']").hide();
		$("div[id^='MemRetention_com']").hide();
		$("#comm_list").hide();
		$("#comm_pic").hide();
		$("div[id^='family_comm']").hide();
		var x = $(this).attr("id");
		var s = x.split("Family");
		var param = xmlModule+'?'+"_xsid="+$("#_xsid").val() + 
				"&_fn=get_DispID" + 
				"&_id=" + s[1] + 
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(){
				xmlRetry[get_DispID_n]++ ;
				if(xmlRetry[get_DispID_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed get_DispID");
				else {
					alert("情報の取得に失敗しました"+get_DispID_n);
					get_Vocational_Service();
				}
			},success: function(httpObj){
				xmlRetry[get_DispID_n]=0;
				var xmlRcS = httpObj.getElementsByTagName("record");
				var news;
				for (var i=0; i<xmlRcS.length; i++) {
					news = "family_comm";
					news = news + xmlNull_chk(xmlRcS[i], "ID", "");
					$("#" + news).show();
				}
			}
		});
	});
	
	$("a[id^='GSE']").click(function() {										// GSE
		$("div[id^='public_rel']").hide();
		$("div[id^='volunteer']").hide();
		$("div[id^='family_comm']").hide();
		$("div[id^='rinfo_com']").hide();
		$("div[id^='fVision_com']").hide();
		$("div[id^='MemRetention_com']").hide();
		$("#comm_list").hide();
		$("#comm_pic").hide();
		$("div[id^='GSE']").hide();
		var x = $(this).attr("id");
		var s = x.split("GSE");
	//	alert(s[1] + ' - ' + $(this).attr("id")) ;
		var param = xmlModule+'?'+"_xsid="+$("#_xsid").val() + 
				"&_fn=get_DispID" + 
				"&_id=" + s[1] + 
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(){
				xmlRetry[get_DispID_n]++ ;
				if(xmlRetry[get_DispID_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed get_DispID");
				else {
					alert("情報の取得に失敗しました"+get_DispID_n);
					get_Vocational_Service();
				}
			},success: function(httpObj){
				xmlRetry[get_DispID_n]=0;
				var xmlRcS = httpObj.getElementsByTagName("record");
				var news;
				for (var i=0; i<xmlRcS.length; i++) {
					news = "GSE_com";
					news = news + xmlNull_chk(xmlRcS[i], "ID", "");
					$("#" + news).show();
				}
			}
		});
	});
	
	$("a[id^='rinfo']").click(function() {										// R情報委員会
		$("div[id^='public_rel']").hide();
		$("div[id^='volunteer']").hide();
		$("div[id^='family_comm']").hide();
		$("div[id^='gse_com']").hide();
		$("div[id^='fVision_com']").hide();
		$("div[id^='MemRetention_com']").hide();
		$("#comm_list").hide();
		$("#comm_pic").hide();
		$("div[id^='rinfo_com']").hide();
		var x = $(this).attr("id");
		var s = x.split("rinfo");
		//alert(s[1] + ' - ' + $(this).attr("id")) ;
		var param = xmlModule+'?'+"_xsid="+$("#_xsid").val() + 
				"&_fn=get_DispID" + 
				"&_id=" + s[1] + 
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(){
				xmlRetry[get_DispID_n]++ ;
				if(xmlRetry[get_DispID_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed get_DispID");
				else {
					alert("情報の取得に失敗しました"+get_DispID_n);
					get_Vocational_Service();
				}
			},success: function(httpObj){
				xmlRetry[get_DispID_n]=0;
				var xmlRcS = httpObj.getElementsByTagName("record");
				var news;
				for (var i=0; i<xmlRcS.length; i++) {
					news = "rinfo_com";
					news = news + xmlNull_chk(xmlRcS[i], "ID", "");
					$("#" + news).show();
				}
			}
		});
	});
	
	$("a[id^='fVision']").click(function() {									// 「未来の夢計画」準備委員会
		$("div[id^='public_rel']").hide();
		$("div[id^='volunteer']").hide();
		$("div[id^='family_comm']").hide();
		$("div[id^='gse_com']").hide();
		$("div[id^='rinfo_com']").hide();
		$("div[id^='MemRetention_com']").hide();
		$("#comm_list").hide();
		$("#comm_pic").hide();
		$("div[id^='fVision_com']").hide();
		var x = $(this).attr("id");
		var s = x.split("fVision");
		//alert(s[1] + ' - ' + $(this).attr("id")) ;
		var param = xmlModule+'?'+"_xsid="+$("#_xsid").val() + 
				"&_fn=get_DispID" + 
				"&_id=" + s[1] + 
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(){
				xmlRetry[get_DispID_n]++ ;
				if(xmlRetry[get_DispID_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed get_DispID");
				else {
					alert("情報の取得に失敗しました"+get_DispID_n);
					get_Vocational_Service();
				}
			},success: function(httpObj){
				xmlRetry[get_DispID_n]=0;
				var xmlRcS = httpObj.getElementsByTagName("record");
				var news;
				for (var i=0; i<xmlRcS.length; i++) {
					news = "fVision_com";
					news = news + xmlNull_chk(xmlRcS[i], "ID", "");
					$("#" + news).show();
				}
			}
		});
	});
	
	$("a[id^='MemRetention']").click(function() {		// 会員増強・維持委員会
		$("div[id^='public_rel']").hide();
		$("div[id^='volunteer']").hide();
		$("div[id^='family_comm']").hide();
		$("div[id^='gse_com']").hide();
		$("div[id^='rinfo_com']").hide();
		$("div[id^='MemRetention_com']").hide();
		$("#comm_list").hide();
		$("#comm_pic").hide();
		$("div[id^='MemRetention_com']").hide();
		var x = $(this).attr("id");
		var s = x.split("MemRetention");
		//alert(s[1] + ' - ' + $(this).attr("id")) ;
		var param = xmlModule+'?'+"_xsid="+$("#_xsid").val() + 
				"&_fn=get_DispID" + 
				"&_id=" + s[1] + 
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(){
				xmlRetry[get_DispID_n]++ ;
				if(xmlRetry[get_DispID_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed get_DispID");
				else {
					alert("情報の取得に失敗しました"+get_DispID_n);
					get_Vocational_Service();
				}
			},success: function(httpObj){
				xmlRetry[get_DispID_n]=0;
				var xmlRcS = httpObj.getElementsByTagName("record");
				var news;
				for (var i=0; i<xmlRcS.length; i++) {
					news = "MemRetention_com";
					news = news + xmlNull_chk(xmlRcS[i], "ID", "");
					$("#" + news).show();
				}
			}
		});
	});
	
	//------------------------------------------------------------ 委員会初期表示 10/04/01 Tagaya
	var x = $("#accordion h4:first a").attr("id");	// メニューの先頭を取得して最新コンテンツを表示
	switch(x){
	case "MembershipRetention":	// 会員増強・維持委員会
		$("div[id^='public_rel']").hide();
		$("div[id^='volunteer']").hide();
		$("div[id^='family_comm']").hide();
		$("div[id^='gse_com']").hide();
		$("div[id^='rinfo_com']").hide();
		$("div[id^='fVision_com']").hide();
		$("#comm_list").hide();
		$("#comm_pic").hide();
		break;
	case "FutureVision":	// 「未来の夢計画」準備委員会
		$("div[id^='public_rel']").hide();
		$("div[id^='volunteer']").hide();
		$("div[id^='family_comm']").hide();
		$("div[id^='gse_com']").hide();
		$("div[id^='rinfo_com']").hide();
		$("#comm_list").hide();
		$("#comm_pic").hide();
		break;
	case "Rinfo_committee":	// R情報委員会
		$("div[id^='public_rel']").hide();
		$("div[id^='volunteer']").hide();
		$("div[id^='family_comm']").hide();
		$("div[id^='gse_com']").hide();
		$("div[id^='fVision_com']").hide();
		$("#comm_list").hide();
		$("#comm_pic").hide();
		break;
	case "GSE_committee":	// GSE家族委員会
		$("div[id^='public_rel']").hide();
		$("div[id^='volunteer']").hide();
		$("div[id^='family_comm']").hide();
		$("div[id^='rinfo_com']").hide();
		$("div[id^='fVision_com']").hide();
		$("#comm_list").hide();
		$("#comm_pic").hide();
		break;
	case "family_committee":	// Ｒ家族委員会
		$("div[id^='public_rel']").hide();
		$("div[id^='volunteer']").hide();
		$("div[id^='gse_com']").hide();
		$("div[id^='rinfo_com']").hide();
		$("div[id^='fVision_com']").hide();
		$("#comm_list").hide();
		$("#comm_pic").hide();
		break;
	case "job_service":			// 職業奉仕委員会
		$("div[id^='public_rel']").hide();
		$("div[id^='family_comm']").hide();
		$("div[id^='gse_com']").hide();
		$("div[id^='rinfo_com']").hide();
		$("div[id^='fVision_com']").hide();
		$("#comm_list").hide();
		$("#comm_pic").hide();
		break;
	case "public_committee":	// 広報委員会
		$("div[id^='volunteer']").hide();
		$("div[id^='family_comm']").hide();
		$("div[id^='gse_com']").hide();
		$("div[id^='rinfo_com']").hide();
		$("div[id^='fVision_com']").hide();
		$("#comm_list").hide();
		$("#comm_pic").hide();
		break;
	default:
		$("div[id^='volunteer']").hide();
		$("div[id^='family_comm']").hide();
		$("div[id^='gse_com']").hide();
		$("div[id^='rinfo_com']").hide();
		$("div[id^='fVision_com']").hide();
		$("#comm_list").hide();
		$("#comm_pic").hide();
	}	
	
});



//================================================================================================== ajax 読み込み時
	function loadNews() {																	//loadNews
		var param = xmlModule+'?'+"_xsid="+$("#_xsid").val() + 
					"&_fn=dist_group"+ 
					"&yc="+encodeURI($("#ycs").val())+ 
					"&cache=" + (new Date()).getTime();
		new $.ajax({									//ページ読み込み時に全グループの最新記事を取得
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(){
				xmlRetry[loadNews_n]++ ;
				if(xmlRetry[loadNews_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed loadNews");
				else {
					alert("情報の取得に失敗しました"+loadNews_n);
					loadNews();
				}
			},success: function(xml) {
				xmlRetry[loadNews_n]=0;
				var xmlRcS = xml.getElementsByTagName("record");
				SetAllList(xmlRcS) ;										//記事一覧を表示
				for (var i=1;i<10; i++) $("#gpToggle"+i).slideDown("fast");	//slideDown
			}
		});
		//$("#show_xmlURI").html('<a href="'+param+'">'+param+'</a>');
	}

	function getGpNews(idx) {																//getGpNews
		var param = xmlModule+'?'+"_xsid="+$("#_xsid").val() + 
					"&_fn=dist_group"+ 
					"&yc="+encodeURI($("#ycs").val())+ 
					"&gp="+(idx+1)+ 
					"&cache=" + (new Date()).getTime();
		$.ajax({										//グループの記事一覧を取得
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(){
				xmlRetry[getGpNews_n]++ ;
				if(xmlRetry[getGpNews_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed getGpNews");
				else {
					alert("情報の取得に失敗しました"+getGpNews_n);
					getGpNews(idx);
				}
			},success: function(xml) {
				xmlRetry[getGpNews_n]=0;
				var xmlRcS = xml.getElementsByTagName("record");
				tgt=$("#gpList"+(idx+1)) ;
				SetList(tgt,xmlRcS) ;
				$("#gpToggle"+(idx+1)).slideDown("fast");
			}
		});
	}

	function dateSort() {																//dateSort
		$.ajax({
			url: xmlModule+'?'+"_xsid="+$("#_xsid").val() +
				"&_fn=dist_dateSort"+
				"&yc="+encodeURI($("#ycs").val())+
				"&cache=" + (new Date()).getTime(),
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(){
				xmlRetry[dateSort_n]++ ;
				if(xmlRetry[dateSort_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed dateSort");
				else {
					alert("情報の取得に失敗しました"+dateSort_n);
					dateSort();
				}
			},success: function(xml){
				xmlRetry[dateSort_n]=0;
				var lst = '\n';
				var xmlRcS = xml.getElementsByTagName("record");
				lst = lst+'								<ul>\n';
				for (i=0; i<xmlRcS.length; i++) {
					lst = lst+listValue(xmlRcS, i);
				}
				lst = lst+'								</ul>\n';
				$("#dateSort").html(lst);
				$("#gpSort").slideUp("slow");		//グループ順非表示
				$("#dateSort").slideDown("slow");	//新着順表示
				$(".tglPanel").toggle("slow");		//ボタンのtoggle
			}
		});
	}


//================================================================================================== 記事サマリー
	function SetList(tgt, xmlRcS) {														//SetList   読み込んだグループ記事一覧を表示
		var i, lst = '\n' ;
		if (xmlRcS.length < 1) {
				lst = lst+'							<li>現在、便りは未登録です</li>\n';
		} else {
			for (i=0; i<xmlRcS.length; i++) {
				lst = lst+listValue(xmlRcS, i);
			}
		}
		tgt.html(lst);
	}
	
	function SetAllList(xmlRcS) {														//SetAllList   全てのグループ記事を表示
		var i, j=0, g, flg, type ;
		for (g=1; g<10; g++) {
			flg=false;
			for (i=0; i<xmlRcS.length; i++) {
				type = xmlRcS[i].getElementsByTagName("Type")[0].firstChild.nodeValue;
				if (type == g) {
					$("#gpList"+g).html(listValue(xmlRcS, i));
					$("#gpAllViw"+g).html('<a href="javascript:void(0);"><img src="images/gp_allviw.gif" alt="便りを全て表示" onmouseover="setImgHvr(this);" onmouseout="setImg(this);" /></a>');
					getAllList(g);
					flg=true;
					break;
				}
			}
			if (!flg) $("#gpList"+g).html('							<li>現在、便りは未登録です</li>\n');
		}
	}
	function getAllList(i) {															//getAllList   記事一覧を取得
		$("#gpAllViw"+i+" a").click(function () {
			$("#gpToggle"+i).slideUp("fast");
			getGpNews(i-1);			//グループの記事一覧を読み込み
		});
	}


	function listValue(xmlRcS, i) {														//listValue   記事のサマリーを返す
		var lst='\n' ;
		lst = lst+'									<li>\n';
		lst = lst+'										'+xmlRcS[i].getElementsByTagName("DateRel")[0].firstChild.nodeValue.substr(5,5)+'&nbsp;<a href="#" onclick="getContents('+xmlRcS[i].getElementsByTagName("ID")[0].firstChild.nodeValue+','+xmlRcS[i].getElementsByTagName("Type")[0].firstChild.nodeValue+','+i+') ; return false;">'+xmlRcS[i].getElementsByTagName("Caption")[0].firstChild.nodeValue+'</a>\n';
		lst = lst+'										<div class="listCnt" id="listCont'+xmlRcS[i].getElementsByTagName("Type")[0].firstChild.nodeValue+'-'+i+'"></div>\n';
		lst = lst+'									</li>\n';
		return lst;
	}


//================================================================================================== 記事詳細
	function getContents(cd,type,i) {													//getContents   記事詳細を取得
		if ($("#listCont"+type+"-"+i).is(':hidden')) {	//記事詳細が閉じられているか
			$(".listCnt").slideUp("fast");				//他に開いている記事詳細を閉じる
			getContentsData(cd,type,i);
		} else {										//記事詳細が開いていたら閉じる
			$("#listCont"+type+"-"+i).slideUp("fast");
		}
	}
	function getContentsData(cd,type,i) {													//getContentsData   記事詳細のデータを取得
		$.ajax({
			url: xmlModule+'?'+"_xsid="+$("#_xsid").val() +
				"&_fn=dist_contents"+
				"&cd="+cd+
				"&cache=" + (new Date()).getTime(),
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(){
				xmlRetry[getContentsData_n]++ ;
				if(xmlRetry[getContentsData_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed getContentsData");
				else {
					alert("情報の取得に失敗しました"+getContentsData_n);
					getContentsData(cd,type,i);
				}
			},success: function(xml){
				xmlRetry[getContentsData_n]=0;
				var xmlRcS = xml.getElementsByTagName("record");
				var tgt = $("#listCont"+type+"-"+i) ;
				SetContents(tgt,xmlRcS) ;
				$("#listCont"+type+"-"+i).slideDown("fast");
				Shadowbox.setup();				//Shadowbox
			}
		});
	}


	//読み込んだ記事詳細を表示
	function SetContents(tgt, xmlRcS) {
		var doc = '\n' ;
		var Comment = xmlNull_chk(xmlRcS[0], "Comment", "").split("\n").join("<br />");
		var Caption = xmlNull_chk(xmlRcS[0], "Caption", "");
		var Path = xmlNull_chk(xmlRcS[0], "Path", "");
		var Subj = xmlNull_chk(xmlRcS[0], "Subj", "").split("\n").join("<br />");

		doc=doc+'											<table id="evt" border="0" width="100%">\n';
		doc=doc+'												<tr><td id="evtSummary" colspan="2">'+Comment+'</td></tr>\n';
		if (Caption != "　") doc=doc+'												<tr bgcolor=""#405b81""><td colspan=""2"" class=""p16LFFFB"">'+Caption+'</td></tr>\n';
		doc=doc+'												<tr>\n';
		if (Path != "　") doc=doc+'													<td><img src="/ImgDat/Event/'+Path+'" align="center" border="0"></td>\n';
		if (Subj != "　") doc=doc+'													<td>'+Subj+'</td>\n';
		doc=doc+'												</tr>\n';
		doc=doc+'											</table>\n';

		tgt.html(doc);
	}

//================================================================================================== ボタン画像
	//便りを全て表示の画像
	function setImg(tgt) {
		$(tgt).attr({ src: 'images/gp_allviw.gif'});
	}
	//便りを全て表示の画像 hover
	function setImgHvr(tgt) {
		$(tgt).attr({ src: 'images/gp_allviw2.gif'});
	}



//================================================================================================== 地区委員会
	function get_comm_yr() {														//地区委員会 年度切り替え年度取得
		var param = xmlModule+'?'+"_xsid="+document.URL + 
				"&_fn=get_comm_yr" + 
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(tp){
				xmlRetry[get_comm_yr_n]++ ;
				if(xmlRetry[get_comm_yr_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed get_comm_yr");
				else {
					get_comm_yr();
				}
			},success: function(httpObj){
				xmlRetry[get_comm_yr_n]=0;
				var opt		="", ry, sel ="";
				var xmlRcS	= httpObj.getElementsByTagName("record");
				var yc		=$("#yc").val();		//表示している年度
				for (var i=0; i<xmlRcS.length; i++) {
					ry	= xmlNull_chk(xmlRcS[i], "ry", 0);
					if (ry ==yc) sel=" selected"; else sel="";
					opt		= opt + '<option value="'+ ry +'"'+sel+'>'+ ry +'-'+ (parseInt(ry)+1) +'</option>';
				}
				$("#chg_comm_yr").html(opt);
			}
		});
	}

	function get_comm() {														//地区委員会 年度切り替え
		var elm = $("#committeeAria");
		elm.empty().css({ height: "100px", background: "url(/images/ajax-loader_l.gif) no-repeat center" });
		var param = xmlModule+'?'+"_xsid="+document.URL + 
				"&_fn=get_comm" + 
				"&_ry=" + $("#chg_comm_yr").val() +
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(tp){
				xmlRetry[get_comm_n]++ ;
				if(xmlRetry[get_comm_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed get_comm");
				else {
					get_comm();
				}
			},success: function(httpObj){
				xmlRetry[get_comm_n]=0;
				var Name, cnt, comID, mID, posID, posName, kName, club, N="", w;
				var xmlRcS	=httpObj.getElementsByTagName("record");
				var comm	='<div id="commData"></div>';
				comm = comm + '<table width="650" border="0px" align="center" cellspacing="4" cellpadding="0">';
				for (var i=0; i<xmlRcS.length; i++) {
					comm	=comm + '<tr><td>　</td>';
					Name	=xmlNull_chk(xmlRcS[i], "Name", "");
					cnt		=xmlNull_chk(xmlRcS[i], "cnt", "");
					comID	=xmlNull_chk(xmlRcS[i], "comID", "");
					mID		=xmlNull_chk(xmlRcS[i], "mID", "");
					posID	=xmlNull_chk(xmlRcS[i], "PosID", "");
					posName	=xmlNull_chk(xmlRcS[i], "PosName", "");
					kName	=xmlNull_chk(xmlRcS[i], "kName", "");
					club	=xmlNull_chk(xmlRcS[i], "club", "");
					if (Name !=N) {
						comm = comm + '<td rowspan="'+ cnt +'" class="Lst_TD F01" id="comID_'+ comID +'">'+ Name +'</td>';
						N=Name;
					}
					w=posName;
					if (w =="") w="&nbsp;";
					comm = comm + '<td class="Lst_TD comPos pos_'+ posID +'">'+ w +'</td>';
					comm = comm + '<td class="Lst_TD kNM mID_'+ mID +'">'+ kName +'</td>';
					comm = comm + '<td class="Lst_TD">'+ club +'</td>';
					comm = comm + '</tr>';
				}
				elm.css({ height: "auto", background: "none" }).empty().append(comm);
				if ($(".ui-dialog").length) {						//dialogが開かれている場合
					$(".ui-dialog").droppable("destroy");
					drp_toDialog();
					evt_comDrop($("#committeeAria table tr .F01"));	//droppable イベント追加
				}
				get_comm_pos();										//役職selectBox表示イベント
				evt_comSelect($("#committeeAria table tr .kNM"))	//kNMの選択 イベント追加
				evt_comDel();										//kNMの削除 イベント追加
				evt_contxtM();										//contextMenu イベント追加
			}
		});
	}

	function get_comm_pos() {												//地区委員会 役職取得
		var param = xmlModule+'?'+"_xsid="+document.URL + 
				"&_fn=get_comm_pos" + 
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(tp){
				xmlRetry[get_comm_pos_n]++ ;
				if(xmlRetry[get_comm_pos_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed get_comm_pos");
				else {
					get_comm_pos();
				}
			},success: function(httpObj){
				xmlRetry[get_comm_pos_n]=0;
				var ID, Pos;
				var opt		='<select id="comPos" style="display: none;"><option value=""></option>';
				var xmlRcS	= httpObj.getElementsByTagName("record");
				for (var i=0; i<xmlRcS.length; i++) {
					ID	= xmlNull_chk(xmlRcS[i], "ID", 0);
					Pos	= xmlNull_chk(xmlRcS[i], "Name", "");
					opt	= opt + '<option value="'+ ID +'">'+ Pos +'</option>';
				}
				opt	= opt + '</select>';
				$("#committeeAria").append(opt);
				evt_comm_posSel($("#committeeAria table tr .comPos"));			//地区委員会 役職selectBox表示イベント
			}
		});
	}

	function evt_comm_posSel(tgt) {												//地区委員会 役職selectBox表示イベント
		tgt.click(function() {
			if ($.data($("#commData").get(0), "posObj") ==null) {
				if ($(this).next().text() !="") {
					var midCls =get_class($(this),"pos_");
					var posID =midCls.split("pos_")[1];
					if (posID ==9) posID="";
					$(this).html($("#comPos").val(posID).css("display","block"));
					$("#comPos").focus();
					$(this).removeClass(midCls);
					$.data($("#commData").get(0), "posObj", $(this));
					evt_comm_posChg();
				}
			}
		});
	}

	function evt_comm_posChg() {												//地区委員会 役職を選択イベント
		$("#comPos").change(function(e) {
			e.stopImmediatePropagation();
			e.stopPropagation();
			var posObj =$.data($("#commData").get(0), "posObj");
			if (posObj !=null) {
				$("#comPos").triggerHandler("blur");
			}
		});
		$("#comPos").blur(function(e) {
			e.stopImmediatePropagation();
			e.stopPropagation();
			var posObj =$.data($("#commData").get(0), "posObj");
			if (posObj !=null) {
				$("#committeeAria").append($("#comPos").css("display","none"));
				posObj.text($("#comPos").find(":selected").text());
				posObj.addClass("pos_"+$(this).val());
				$.data($("#commData").get(0), "posObj", null);
			}
		});
	}

	function chk_CM_dlg() {														//地区委員会 修正を保存の確認ダイアログ表示
		var dialog = '<div id="chk_CM_dlg" style="display: none;">';
		dialog = dialog + '  <div id="del_alert"><span class="ui-icon ui-icon-alert"></span>編集した内容を保存しますか？</div>';
		dialog = dialog + '  <p>必ず他の人が操作を行っていないのを確認してください。</p>';
		dialog = dialog + '</div>';
		$("#contner").append(dialog);

		$("#chk_CM_dlg").dialog({
			resizable: false,
			modal: true,
			title:'保存の確認',
			width: 'auto',
			minHeight: 80,
			buttons: {
				'キャンセル': function() {
					$(this).remove();
				},
				'保存する': function() {
					reg_CM();		//保存処理開始
					$(this).remove();
				}
			},
			close: function() {
				$(this).remove();
			}
		});
	}

	function reg_CM() {															//地区委員会 保存用Data取得
		var i, idx, comID, posID, mID, tmp, CM="";
		var TBL	= $("#committeeAria table");
		var TR	= TBL.find("tr").length;						//trの数を取得
		for (i=0;i<TR;i++) {
			idx = TBL.find("tr:eq("+ i +")");						//一行づつDataを取得
			//comIDを取得
			tmp = idx.find(" td[id^='comID_']").attr("id");
			if (tmp) { comID =tmp.split("comID_")[1]; }
			if (idx.find(" .kNM").text() !="") {					//氏名が無ければその行は保存しない
				//mIDを取得
				mID	= get_class(idx.find(" [class*='mID_']"), "mID_").split("mID_")[1];
				//posIDを取得
				if (idx.find(" [class*='pos_']").attr("class")) {
					posID = get_class(idx.find(" [class*='pos_']"), "pos_").split("pos_")[1];
				} else {
					posID = "";
				}
				CM = CM + comID +"^"+ posID +"^"+ mID +"|";
			}
		}
		//alert($("#chg_comm_yr").val()+ " \n" +CM);
		reg_CMQuery(CM);
	}

	function reg_CMQuery(CM) {													//地区委員会 保存
		var param = xmlModule+'?'+"_xsid="+document.URL + 
				"&_fn=reg_CMQuery" + 
				"&_ry=" + $("#chg_comm_yr").val() + 
				"&_CM=" + CM + 
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(tp){
				xmlRetry[reg_CMQuery_n]++ ;
				if(xmlRetry[reg_CMQuery_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed reg_CMQuery");
				else {
					reg_CMQuery(CM);
				}
			},success: function(httpObj){
				xmlRetry[reg_CMQuery_n]=0;
				var xmlRcS	= httpObj.getElementsByTagName("record");
				var SID		= xmlNull_chk(xmlRcS[0], "msg", "-1");
				if (SID !=0) { location.reload(); return; }		//ログイン状態でなければreload
				get_comm();							//委員会の再読込み
			}
		});
	}

	function create_CMdlog() {												//地区委員会 CMdlog作成
		var dialog =	  '<div id="CMdlog">';
		dialog = dialog + '	<table border="0" cellspacing="0" cellpadding="2" style="width: 100%;" id="SCHtb">';
		dialog = dialog + '		<tr>';
		dialog = dialog + '			<th>クラブ：<input type="text" value="" id="clubSearch" style="ime-mode: disabled;" /></th>';
		dialog = dialog + '			<th>氏名：<input type="text" value="" id="nameSearch" style="ime-mode: disabled;" /></th>';
		dialog = dialog + '		</tr>';
		dialog = dialog + '	</table>';
		dialog = dialog + '	<div id="CMdiv" style="overflow: auto;height: 130px;">';
		dialog = dialog + '		<table border="0" cellspacing="1" cellpadding="0" style="width: 100%;" class="tablesorter" id="CMtb">';
		dialog = dialog + '			<thead>';
		dialog = dialog + '				<tr class="Freezing">';
		dialog = dialog + '					<th>クラブ</th>';
		dialog = dialog + '					<th>A</th>';
		dialog = dialog + '					<th>氏名</th>';
		dialog = dialog + '				</tr>';
		dialog = dialog + '			</thead>';
		dialog = dialog + '			<tbody id="CMList">';
		dialog = dialog + '			</tbody>';
		dialog = dialog + '		</table>';
		dialog = dialog + '		<div id="loader"></div>';
		dialog = dialog + '	</div>';
		dialog = dialog + '</div>';
		$("#contner").append(dialog);
		$("#CMtb").tablesorter();									//tablesorter
	}

	function open_CM() {													//地区委員会・カレンダー Rotarian選択ダイアログ表示
		if ($("#CMdlog").length) return;
		create_CMdlog();									//CMdlog作成
		var tid =null;
		$("#clubSearch, #nameSearch").keyup(function () {	//クラブ検索・氏名検索
			clearTimeout(tid);
			tid=setTimeout("get_keyupQuery()",1000);
		});

		$("#CMdlog").dialog({
			autoOpen : true,
			resizable: true,
			width: 390,
			modal: false,
			title:'Rotarian選択',
			open: function(evt,ui){
				//dialog自身へのdrop
				drp_toDialog();
				//droppable イベント追加
				if ($("#CPCSdlog").length) {				//他のdialogが存在している場合
					$("#committeeAria table tr .F01").droppable("destroy");
					$("#committeeAria table tr .kNM").droppable("destroy");
				}
				evt_comDrop($("#committeeAria table tr .F01"));
			},
			resize: function(evt,ui){
				$("#CMdiv").css("height",$("#CMdlog").height()-($("#SCHtb").height()+10)+"px");
			},
			close:function(){
				if (!$("#CPCSdlog").length) {				//他にdialogが存在していない場合
					$("#committeeAria table tr .F01").droppable("destroy");
					$("#committeeAria table tr .kNM").droppable("destroy");
				}
				$(this).remove();
			}
		});
	}

	function get_keyupQuery() {													//地区委員会 クラブ・氏名検索
		var elm =$("#CMList"), elm2 =$("#loader");
		elm.empty();
		elm2.css({ height: "100px", background: "url(/images/ajax-loader_l.gif) no-repeat center" });
		var param = xmlModule+'?'+"_xsid="+document.URL + 
				"&_fn=get_keyupQuery" + 
				"&_ry=" + $("#chg_comm_yr").val() +
				"&_club=" + encodeURI($("#clubSearch").val()) +
				"&_name=" + encodeURI($("#nameSearch").val()) +
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(tp){
				xmlRetry[get_keyupQuery_n]++ ;
				if(xmlRetry[get_keyupQuery_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed get_keyupQuery");
				else {
					get_keyupQuery();
				}
			},success: function(httpObj){
				xmlRetry[get_keyupQuery_n]=0;
				var comm ='';
				var xmlRcS	= httpObj.getElementsByTagName("record");
				for (var i=0; i<xmlRcS.length; i++) {
					comm = comm + '<tr>';
					comm = comm + '	<td class="cne_'+ xmlNull_chk(xmlRcS[i], "cNameE", "") +'">'+ xmlNull_chk(xmlRcS[i], "cName", "") +'</td>';
					comm = comm + '	<td class="ne">'+ xmlNull_chk(xmlRcS[i], "NameE", "") +'</td>';
					comm = comm + '	<td><div id="mID_'+ xmlNull_chk(xmlRcS[i], "mID", "") +'" class="nm" style="white-space: nowrap;">'+ xmlNull_chk(xmlRcS[i], "Name", "") +'</div></td>';
					comm = comm + '</tr>';
				}
				elm.append(comm);
				elm2.css({ height: "0", background: "none" });
				if (i >0) $("#CMtb").trigger("update").trigger("sorton",[[[0,0]]]);
				//ローマ字クラブ名をclubSearchへセット
				$("#CMList tr td[class^='cne_']").click(function () {
					$("#clubSearch").val($(this).attr("class").split("cne_")[1]);
				});
				//draggable イベント追加
				$("#CMList tr .nm").draggable({
					containment: '#committeeAria',
					helper: "clone",
					start: function(evt, ui) {
						$("#CMdlog").parent().css("overflow","visible");
						$("#committeeAria table tr .F01").droppable("enable");
						$("#committeeAria table tr .kNM").droppable("enable");
					},
					stop: function(evt, ui) { $("#CMdlog").parent().css("overflow","hidden"); }
				});

				//過去の委員会履歴を表示
				$("#CMList tr .nm").one("click", function(){
					get_mouseoverQuery($(this));
				});
				//会員情報を修正
				$("#CMList tr .nm").dblclick(function () {
					$.data($("#commData").get(0), "memEdit", "CM");
					open_memEdit($(this));
				});
			}
		});
	}

	function open_CPCS() {												//地区委員会 会長・幹事ダイアログ表示
		if ($("#CPCSdlog").length) return;
		var dialog =	  '<div id="CPCSdlog">';
		dialog = dialog + '	<table border="0" cellspacing="0" cellpadding="2" style="width: 100%;" id="RYSELtb">';
		dialog = dialog + '		<tr>';
		dialog = dialog + '			<th>年度：<select id="rySel"><option value="0">現年度</option><option value="1">前年度</option></select></th>';
		dialog = dialog + '		</tr>';
		dialog = dialog + '	</table>';
		dialog = dialog + '	<div id="CPCSdiv" style="overflow: auto;height: 130px;">';
		dialog = dialog + '		<table border="0" cellspacing="1" cellpadding="0" style="width: 100%;" class="tablesorter" id="CPCStb">';
		dialog = dialog + '			<thead>';
		dialog = dialog + '				<tr class="Freezing">';
		dialog = dialog + '					<th>クラブ</th>';
		dialog = dialog + '					<th>会長氏名</th>';
		dialog = dialog + '					<th>幹事氏名</th>';
		dialog = dialog + '				</tr>';
		dialog = dialog + '			</thead>';
		dialog = dialog + '			<tbody id="CPCSList">';
		dialog = dialog + '			</tbody>';
		dialog = dialog + '		</table>';
		dialog = dialog + '		<div id="CPCSLoader"></div>';
		dialog = dialog + '	</div>';
		dialog = dialog + '</div>';
		$("#contner").append(dialog);
		$("#CPCStb").tablesorter();									//tablesorter
		$("#rySel").change(function () {							//表示年度選択
			get_CPCS();
		});

		$("#CPCSdlog").dialog({
			autoOpen : true,
			resizable: true,
			width: 390,
			modal: false,
			title:'会長・幹事一覧',
			open:  function(evt,ui){
				get_CPCS();
				//dialog自身へのdrop
				drp_toDialog();
				//droppable イベント追加
				if ($("#CMdlog").length) {			//他のdialogが存在している場合
					$("#committeeAria table tr .F01").droppable("destroy");
					$("#committeeAria table tr .kNM").droppable("destroy");
				}
				evt_comDrop($("#committeeAria table tr .F01"));
			},
			resize: function(evt,ui){
				$("#CPCSdiv").css("height",$("#CPCSdlog").height()-($("#RYSELtb").height())+"px");
			},
			close:function(){
				if (!$("#CMdlog").length) {			//他にdialogが存在していない場合
					$("#committeeAria table tr .F01").droppable("destroy");
					$("#committeeAria table tr .kNM").droppable("destroy");
				}
				$(this).remove();
			}
		});
	}

	function get_CPCS() {													//地区委員会 会長・幹事を取得
		var elm =$("#CPCSList"), elm2 =$("#CPCSLoader");
		elm.empty();
		elm2.css({ height: "100px", background: "url(/images/ajax-loader_l.gif) no-repeat center" });
		var param = xmlModule+'?'+"_xsid="+$("#_xsid").val() + 
				"&_fn=get_CPCS" + 
				"&_typ=" + $("#rySel").val() +
				"&_ry=" + $("#chg_comm_yr").val() +
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(tp){
				xmlRetry[get_CPCS_n]++ ;
				if(xmlRetry[get_CPCS_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed get_CPCS");
				else {
					get_CPCS();
				}
			},success: function(httpObj){
				xmlRetry[get_CPCS_n]=0;
				var comm ='';
				var xmlRcS	= httpObj.getElementsByTagName("record");
				for (var i=0; i<xmlRcS.length; i++) {
					comm = comm + '<tr>';
					comm = comm + '	<td>'+ xmlNull_chk(xmlRcS[i], "cName", "") +'</td>';
					comm = comm + '	<td><div id="mID_'+ xmlNull_chk(xmlRcS[i], "cpID", "") +'" class="nm" style="white-space: nowrap;">'+ xmlNull_chk(xmlRcS[i], "cpName", "") +'</div></td>';
					comm = comm + '	<td><div id="mID_'+ xmlNull_chk(xmlRcS[i], "csID", "") +'" class="nm" style="white-space: nowrap;">'+ xmlNull_chk(xmlRcS[i], "csName", "") +'</div></td>';
					comm = comm + '</tr>';
				}
				elm.append(comm);
				elm2.css({ height: "0", background: "none" });
				if (i >0) $("#CPCStb").trigger("update").trigger("sorton",[[]]);

				//draggable イベント追加
				$("#CPCSList tr .nm").draggable({
					containment: '#committeeAria',
					helper: "clone",
					start: function(evt, ui) {
						$("#CPCSdlog").parent().css("overflow","visible");
						$("#committeeAria table tr .F01").droppable("enable");
						$("#committeeAria table tr .kNM").droppable("enable");
					},
					stop: function(evt, ui) { $("#CPCSdlog").parent().css("overflow","hidden"); }
				});

				//過去の委員会履歴を表示
				$("#CPCSList tr .nm").one("click", function(){
					get_mouseoverQuery($(this));
				});
				//会員情報を修正
				$("#CPCSList tr .nm").dblclick(function () {
					$.data($("#commData").get(0), "memEdit", "CPCS");
					open_memEdit($(this));
				});
			}
		});
	}

	function get_mouseoverQuery(Obj) {											//地区委員会 過去の委員会履歴を表示
		//var Obj = $.data($("#commData").get(0), "moverObj");
		var param = xmlModule+'?'+"_xsid="+document.URL + 
				"&_fn=get_mouseoverQuery" + 
				"&_mID=" + Obj.attr("id").split("mID_")[1] + 
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(tp){
				xmlRetry[get_mouseoverQuery_n]++ ;
				if(xmlRetry[get_mouseoverQuery_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed get_mouseoverQuery");
				else {
					get_mouseoverQuery();
				}
			},success: function(httpObj){
				xmlRetry[get_mouseoverQuery_n]=0;
				var xmlRcS	= httpObj.getElementsByTagName("record");
				var comm ='';
				var ry, Name01, Name02, PosMean;
				for (var i=0; i<xmlRcS.length; i++) {
					ry		= xmlNull_chk(xmlRcS[i], "ry", "");
					Name01	= xmlNull_chk(xmlRcS[i], "Name01", "");
					Name02	= xmlNull_chk(xmlRcS[i], "Name02", "");
					PosMean	= xmlNull_chk(xmlRcS[i], "PosMean", "");
					comm = comm + ry +'　'+ Name01 +'　'+ Name02 +'　'+ PosMean +'<br />';
				}
				if (i ==0) comm = "委員履歴はありません";
				$(Obj).tooltip({					//tooltipに履歴をセット
					bodyHandler: function() {
						return comm;
					}
				});
				if ($.browser.msie) {				//tooltipを表示
					document.getElementById(Obj.attr("id")).fireEvent("onmouseover");
				} else {
					$(Obj).trigger("mouseover");
				}
			}
		});
	}

	function open_memEdit(Obj) {												//地区委員会 会員情報を修正ダイアログ表示
		var dialog =	  '<div id="RMdlog">';
		dialog = dialog + '	<div id="addRep"></div>';
		dialog = dialog + '	<table border="0" cellspacing="0" cellpadding="2" style="width: 100%;" id="RMtb">';
		dialog = dialog + '		<tr>';
		dialog = dialog + '			<th>ローマ字名</th><td><span id="eName"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;入会年月日 <span id="admitted"></span></td>';
		dialog = dialog + '		</tr>';
		dialog = dialog + '		<tr>';
		dialog = dialog + '			<th>姓</th><td><input type="text" value="" id="nm1" size="10" style="ime-mode: active;" />';
		dialog = dialog + '			名 <input type="text" value="" id="nm2" size="10" style="ime-mode: active;" /></td>';
		dialog = dialog + '		</tr>';
		dialog = dialog + '		<tr>';
		dialog = dialog + '			<th>生年月日</th><td><select id="birthY"></select>/&nbsp;<select id="birthM"></select>/&nbsp;<select id="birthD"></select></td>';
		dialog = dialog + '		</tr>';
		dialog = dialog + '		<tr>';
		dialog = dialog + '			<th>クラブ内職業分類</th><td><input id="ocupation_inp" type="text" size="25" style="ime-mode: active;margin-bottom: 3px;" value="" /><span class="notes"> ※クラブ内の職業分類を入力をしてください。</span></td>';
		dialog = dialog + '		</tr>';
		dialog = dialog + '		<tr>';
		dialog = dialog + '			<th>事業所名</th><td><input type="text" id="corp" size="50" style="ime-mode: active;" value="" /></td>';
		dialog = dialog + '		</tr>';
		dialog = dialog + '		<tr>';
		dialog = dialog + '			<th>役職</th><td><input id="pos_inp" type="text" size="25" style="ime-mode: active;margin-bottom: 3px;" value="" /><span class="notes"> ※一覧にない役職の場合は入力をしてください。</span><br /><select id="pos"></select></td>';
		dialog = dialog + '		</tr>';
		dialog = dialog + '		<tr>';
		dialog = dialog + '			<th>郵便番号</th><td><input type="text" id="zip" size="10" style="ime-mode: inactive;" value="" />';
		dialog = dialog + '			<input type="button" id="addSrc" name="addSrc" value="住所検索" onclick="wrkWin=ZipCDwin(\'ZipCD\',\'width=400,height=400,resizable=yes,scrollbars=yes\',\'zip\',\'&zcr=zip&adr=adr\');wrkWin.focus() ;"><span class="notes"> ※ハイフンを含む</span></td>';
		dialog = dialog + '		</tr>';
		dialog = dialog + '		<tr>';
		dialog = dialog + '			<th>事業所所在地</th><td><input type="text" id="adr" size="44" style="ime-mode: active;margin-bottom: 3px;" value="" /><br /><input type="text" id="buil" size="25" style="ime-mode: active" value="" /><span class="notes"> ※建物名: 大和ビル3階</span></td>';
		dialog = dialog + '		</tr>';
		dialog = dialog + '		<tr>';
		dialog = dialog + '			<th>TEL</th><td><input type="text" id="TEL" size="16" style="ime-mode: inactive;" value="" />';
		dialog = dialog + '			FAX <input type="text" id="FAX" size="16" style="ime-mode: inactive;" value="" /><span class="notes"> ※ハイフンを含む</span></td>';
		dialog = dialog + '		</tr>';
		dialog = dialog + '		<tr>';
		dialog = dialog + '			<th>e-mail</th><td><input id="mail" type="text" size="50" style="ime-mode: inactive" value="" /></td>';
		dialog = dialog + '		</tr>';
		dialog = dialog + '		<tr>';
		dialog = dialog + '			<th>自宅郵便番号</th><td><input type="text" id="priZip" size="10" style="ime-mode: inactive;" value="" />';
		dialog = dialog + '			<input type="button" id="priaddSrc" name="priaddSrc" value="住所検索" onclick="wrkWin=ZipCDwin(\'ZipCD\',\'width=400,height=400,resizable=yes,scrollbars=yes\',\'priZip\',\'&zcr=priZip&adr=priAdr\');wrkWin.focus() ;"><span class="notes"> ※ハイフンを含む</span></td>';
		dialog = dialog + '		</tr>';
		dialog = dialog + '		<tr>';
		dialog = dialog + '			<th>自宅所在地</th><td><input type="text" id="priAdr" size="44" style="ime-mode: active;margin-bottom: 3px;" value="" /><br /><input type="text" id="priBuil" size="25" style="ime-mode: active" value="" /><span class="notes">※建物名を除く: 大和市△△1-2-3</span></td>';
		dialog = dialog + '		</tr>';
		dialog = dialog + '		<tr>';
		dialog = dialog + '			<th>自宅TEL</th><td><input type="text" id="priTEL" size="16" style="ime-mode: inactive;" value="" />';
		dialog = dialog + '			自宅FAX <input type="text" id="priFAX" size="16" style="ime-mode: inactive;" value="" /><span class="notes"> ※ハイフンを含む</span></td>';
		dialog = dialog + '		</tr>';
		dialog = dialog + '	</table>';
		dialog = dialog + '</div>';
		$("#contner").append(dialog);
		//役職一覧を取得
		get_Pos(Obj);
		//生年月日の日付を作成
		var i,dt;
		var yr = new Date().getFullYear();
		dt='<option value=""> </option>';		//yyyy
		for (i=yr-99; i<=yr; i++) dt = dt + '<option value="'+i+'">'+i+' ['+(yr-i)+'] '+cnvDateToWareki(i)+'</option>';
		$("#birthY").html(dt);
		dt='<option value=""> </option>';		//mm
		for (i=1; i<=12; i++) dt = dt + '<option value="'+("0"+i).slice(-2)+'">'+("0"+i).slice(-2)+'</option>';
		$("#birthM").html(dt);
		dt='<option value=""> </option>';		//dd
		for (i=1; i<=31; i++) dt = dt + '<option value="'+("0"+i).slice(-2)+'">'+("0"+i).slice(-2)+'</option>';
		$("#birthD").html(dt);

		$("#RMdlog").dialog({
			autoOpen : true,
			resizable: true,
			width: 'auto',
			modal: true,
			title:'会員情報の修正',
			buttons: {
				'閉じる': function() {
					$.data($("#commData").get(0), null);
					$(this).remove();
				},
				'修正': function() {
					chk_memEdit(Obj);
				}
			},
			close:function(){
				$.data($("#commData").get(0), null);
				$(this).remove();
			}
		});
	}

	function get_Pos(Obj) {														//地区委員会 役職一覧を取得
		$.ajax({
			url: xmlModule+'?'+"_xsid="+$("#_xsid").val() + 
				"&_fn=set_pos"+ 
				"&cache=" + (new Date()).getTime(),
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(){
				xmlRetry[get_Pos_n]++ ;
				if(xmlRetry[get_Pos_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed get_Pos");
				else {
					get_Pos(Obj);
				}
			},success: function(httpObj){
				xmlRetry[get_Pos_n]=0;
				var xmlRcS = httpObj.getElementsByTagName("record");
				var pos = '<option value=""> </option>';
				for (var i=0; i<xmlRcS.length; i++) {
					pos = pos + '<option value="'+ xmlNull_chk(xmlRcS[i], "pos", "") +'">'+ xmlNull_chk(xmlRcS[i], "pos", "") +'</option>';
				}
				$("#pos").html(pos);
				$("#pos").change(function(){ $("#pos_inp").val($(this).val()); });	//役職変更時に役職名を変更
				get_memData(Obj);													//会員の修正情報を取得
			}
		});
	}

	function get_memData(Obj) {												//地区委員会 会員の修正情報を取得
		var param = xmlModule+'?'+"_xsid="+document.URL + 
				"&_fn=get_memData" + 
				"&_mID=" + Obj.attr("id").split("mID_")[1] + 
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(tp){
				xmlRetry[get_memData_n]++ ;
				if(xmlRetry[get_memData_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed get_memData");
				else {
					get_memData(Obj);
				}
			},success: function(httpObj){
				xmlRetry[get_memData_n]=0;
				var comm ='';
				var xmlRcS		= httpObj.getElementsByTagName("record");
				var Name		= xmlNull_chk(xmlRcS[0], "Name", "");
				var kName		= xmlNull_chk(xmlRcS[0], "kName", "");
				var Admitted	= xmlNull_chk(xmlRcS[0], "Admitted", "");
				var DateBirth	= xmlNull_chk(xmlRcS[0], "DateBirth", "");
				var eMail		= xmlNull_chk(xmlRcS[0], "eMail", "");
				var Ocupation	= xmlNull_chk(xmlRcS[0], "Ocupation", "");
				var CorpName	= xmlNull_chk(xmlRcS[0], "CorpName", "");
				var Pos			= xmlNull_chk(xmlRcS[0], "Pos", "");
				var CorpZip		= xmlNull_chk(xmlRcS[0], "CorpZip", "");
				var CorpAdd		= xmlNull_chk(xmlRcS[0], "CorpAdd", "");
				var CorpTel		= xmlNull_chk(xmlRcS[0], "CorpTel", "");
				var CorpFax		= xmlNull_chk(xmlRcS[0], "CorpFax", "");
				var PriZip		= xmlNull_chk(xmlRcS[0], "PriZip", "");
				var PriAdd		= xmlNull_chk(xmlRcS[0], "PriAdd", "");
				var PriTel		= xmlNull_chk(xmlRcS[0], "PriTel", "");
				var PriFax		= xmlNull_chk(xmlRcS[0], "PriFax", "");
				$("#eName").text(Name);						//ローマ字名
				$("#admitted").text(Admitted);				//入会年月日
				if (kName !="") {							//姓名
					if (kName.indexOf("　") >-1) {
						kName =kName.split("　");
					} else if (kName.indexOf(" ") >-1) {
						kName =kName.split(" ");
					}
					if (kName.length >1) {
						$("#nm1").val(kName[0]);
						$("#nm2").val(kName[1]);
					}
				}
				if (CorpAdd.indexOf("　") >0) {				//adr
					var spla = CorpAdd.split("　");
					if (spla.length >1) {
						$("#adr").val(spla[0]);
						$("#buil").val(spla[1]);
					}
				} else {
					$("#adr").val(CorpAdd);
				}
				if (PriAdd.indexOf("　") >0) {				//priadr
					var splb = PriAdd.split("　");
					if (splb.length >1) {
						$("#priAdr").val(splb[0]);
						$("#priBuil").val(splb[1]);
					}
				} else {
					$("#priAdr").val(PriAdd);
				}
				if (DateBirth !="") {						//生年月日
					DateBirth = DateBirth.split("/");
					if (DateBirth.length >1) {
						$("#birthY").val(DateBirth[0]);
						$("#birthM").val(DateBirth[1]);
						$("#birthD").val(DateBirth[2]);
					}
				}
				$("#ocupation_inp").val(Ocupation);			//職業分類
				$("#corp").val(CorpName);					//事業所名
				$("#pos_inp").val(Pos);						//役職
				$("#pos").val(Pos);
				$("#zip").val(CorpZip);						//郵便番号
				$("#TEL").val(CorpTel);						//TEL
				$("#FAX").val(CorpFax);						//FAX
				$("#mail").val(eMail);						//mail
				$("#priZip").val(PriZip);					//自宅郵便番号
				$("#priTEL").val(PriTel);					//自宅TEL
				$("#priFAX").val(PriFax);					//自宅FAX
			}
		});
	}

	function chk_memEdit(Obj) {												//地区委員会 会員の修正情報のエラーチェック
		var msg ="";
		if ($("#zip").val().length >0) {					//郵便番号
			if (!inpChk($("#zip").val(), 2)) msg = msg +"郵便番号 ";
		}
		if ($("#TEL").val().length >0) {					//TEL
			if (!inpChk($("#TEL").val(), 1)) msg = msg +"TEL ";
		}
		if ($("#FAX").val().length >0) {					//FAX
			if (!inpChk($("#FAX").val(), 1)) msg = msg +"FAX ";
		}
		if ($("#mail").val().length >0) {					//mail
			if (!inpChk($("#mail").val(), 4)) msg = msg +"e-mail ";
		}
		if ($("#priZip").val().length >0) {					//自宅郵便番号
			if (!inpChk($("#priZip").val(), 2)) msg = msg +"自宅郵便番号 ";
		}
		if ($("#priTEL").val().length >0) {					//自宅TEL
			if (!inpChk($("#priTEL").val(), 1)) msg = msg +"自宅TEL ";
		}
		if ($("#priFAX").val().length >0) {					//自宅FAX
			if (!inpChk($("#priFAX").val(), 1)) msg = msg +"自宅FAX";
		}
		if (msg !="") {
			$("#RMdlog #addRep").html(msg+"<br />を確認してください");
		} else {
			$("#RMdlog #addRep").html("");
			chk_memEdit_dlg(Obj);
		}
	}

	function chk_memEdit_dlg(Obj) {											//地区委員会 会員の修正情報を確認ダイアログ表示
		var dialog = '<div id="chk_dlg" style="display: none;">';
		dialog = dialog + '  <div id="del_alert"><span class="ui-icon ui-icon-alert"></span>修正しますか？</p></div>';
		dialog = dialog + '</div>';
		$("#contner").append(dialog);

		var dlogObj		=$("div[aria-labelledby^='ui-dialog-title-RMdlog']");
		var dlogZidx	=dlogObj.css("z-index");
		dlogObj.css({ zIndex: dlogZidx-2 });

		$("#chk_dlg").dialog({
			resizable: false,
			modal: false,
			title:'修正の確認',
			width: 'auto',
			minHeight: 80,
			buttons: {
				'キャンセル': function() {
					dlogObj.css({ zIndex: dlogZidx });
					$(this).remove();
				},
				'修正する': function() {
					reg_memEdit(Obj)		//会員の修正情報を保存
					dlogObj.css({ zIndex: dlogZidx });
					$(this).remove();
				}
			},
			close: function() {
				dlogObj.css({ zIndex: dlogZidx });
				$(this).remove();
			}
		});
	}

	function reg_memEdit(Obj) {											//地区委員会 会員の修正情報を保存
		var param = xmlModule+'?'+"_xsid="+$("#_xsid").val() + 
				"&_fn=reg_memEdit"+ 
				"&_mID="+Obj.attr("id").split("mID_")[1] + 
				"&_corp="+encodeURI($("#corp").val()) + 
				"&_zip="+encodeURI($("#zip").val()) + 
				"&_prizip="+encodeURI($("#priZip").val()) + 
				"&_adr="+encodeURI($("#adr").val()) + 
				"&_priadr="+encodeURI($("#priAdr").val()) + 
				"&_tel="+encodeURI($("#TEL").val()) + 
				"&_pritel="+encodeURI($("#priTEL").val()) + 
				"&_pos="+encodeURI($("#pos_inp").val()) + 
				"&_fax="+encodeURI($("#FAX").val()) + 
				"&_prifax="+encodeURI($("#priFAX").val()) + 
				"&_name="+encodeURI($("#nm1").val()+"　"+$("#nm2").val()) + 	//氏名
				"&_ocupation="+encodeURI($("#ocupation_inp").val()) + 			//職業分類
				"&_buil="+encodeURI($("#buil").val()) + 						//建物名
				"&_pribuil="+encodeURI($("#priBuil").val()) + 					//自宅建物名
				"&_mail="+encodeURI($("#mail").val()) + 						//mail
				"&cache=" + (new Date()).getTime() ;
				if ($("#birthY").val() !="" && $("#birthM").val() !="" && $("#birthD").val() !="") {	//生年月日
					param = param + "&_birth="+$("#birthY").val() + "/" + $("#birthM").val() + "/" + $("#birthD").val();
				} else { param = param + "&_birth="; }
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(){
				xmlRetry[reg_memEdit_n]++ ;
				if(xmlRetry[reg_memEdit_n]>(xmlRetryLimt-1))
					alert("サーバーとの通信に失敗しました。\n最新の情報に更新してください。\nxml failed reg_memEdit");
				else {
					alert("サーバーとの通信に失敗しました\nもう一度「修正」ボタンを押してください。");
				}
			},success: function(httpObj){
				xmlRetry[reg_memEdit_n]=0;
				var memEdit	= $.data($("#commData").get(0), "memEdit");
				var xmlRcS	= httpObj.getElementsByTagName("record");
				var SID		= xmlNull_chk(xmlRcS[0], "msg", "-1");
				if (SID !=0) { location.reload(); return; }		//ログイン状態でなければreload
				$("#RMdlog").remove();
				if (memEdit =="CM") get_keyupQuery();												//クラブ・氏名再検索
				if (memEdit =="CPCS") get_CPCS();													//会長・幹事を再取得
				if (memEdit =="CM_calen") {
					var CMc =$.data($("#commData").get(0), "CM_calen");
					get_clubM(CMc.parent().attr("class"), CMc.text(), $("#chk_clubM_dialog"), CMc);	//カレンダー クラブメンバー再取得
				}
				$.data($("#commData").get(0), null);
			}
		});
	}

	function inpChk(tgt,typ) {												//入力項目のチェック
		if (typ==1){   //tel
			if (! tgt.match(/^\d{2,5}-\d{1,4}-\d{4}$/)) { return false; } else { return true; }
		}
		if (typ==2){   //zip
			if (! tgt.match(/^\d{3}-\d{4}$/)) { return false; } else { return true; }
		}
		if (typ==3){   //pass
			if (checkAlphabetOrNumberOnly($("#"+tgt),0,"") !="") {
				tgt = tgt.parent().prev();
				err = err + "半角英数字以外が入力されています。";
				tgt.css({ fontWeight:"bold", color:"#f00" });
				return false;
			} else {
				if (tgt.length <6) {
					err = err + "半角英数字は６文字以上を入力してください。";
					$("#"+tgt).parent().prev().css({ fontWeight:"bold", color:"#f00" });
					return false;
				} else {
					return true;
				}
			}
		}
		if (typ==4){   //mail
			if (! tgt.match(/^[A-Za-z0-9]+[\w-]+@[\w\.-]+\.\w{2,}$/)) { return false; } else { return true; }
		}
	}

	function open_SG(gID) {												//地区委員会 送信グループを作成
		if ($("#SGdlog").length) return;
		var dialog =	  '<div id="SGdlog">';
		dialog = dialog + '	<div id="addRep"></div>';
		dialog = dialog + '	<div id="SGdiv" style="overflow: auto;height: 300px;">';
		dialog = dialog + '		<table border="0" cellspacing="0" cellpadding="0" id="SGnm"><tr><th>グループ名：</th><td><input type="text" style="ime-mode: active;" /></td></tr></table>';
		dialog = dialog + '		<table border="0" cellspacing="1" cellpadding="0" style="width: 100%;" class="tablesorter" id="SGtb">';
		dialog = dialog + '			<thead>';
		dialog = dialog + '				<tr class="Freezing">';
		dialog = dialog + '					<th>氏名</th>';
		dialog = dialog + '					<th>クラブ</th>';
		dialog = dialog + '				</tr>';
		dialog = dialog + '			</thead>';
		dialog = dialog + '			<tbody id="SGList">';
		dialog = dialog + '			</tbody>';
		dialog = dialog + '		</table>';
		dialog = dialog + '	</div>';
		dialog = dialog + '	<div id="loader"></div>';
		dialog = dialog + '</div>';
		$("#contner").append(dialog);
		$("#SGtb").tablesorter();									//tablesorter
		$("#SGdlog").droppable({									//Rotarian選択からのdroppable
			accept: ".nm",
			drop: function(evt, ui) {
				var Name	= ui.draggable.text();											//会員名を取得
				var mID		= ui.draggable.attr("id");										//mIDを取得
				var club	= ui.draggable.parent().parent().find("td:eq(0)").text();		//クラブ名を取得 eq(0)
				edit_SGtr(mID, Name, club);
			}
		});

		$("#SGdlog").dialog({
			autoOpen : true,
			resizable: true,
			width: 300,
			modal: false,
			title:'送信グループ 作成',
			open:  function(evt,ui){
				if (gID >0) get_SGmem(gID);									//gID >0 送信グループメンバーを取得
				var selObj =$("#commData").get(0);
				if ($.data(selObj, "selObj") !=null) {
					$.data(selObj, "selObj").removeClass("selBackColor");	//背景色を戻す
					$.data(selObj, "selObj", null);							//選択Objをnull
				}
				$(".F01").click(function () { get_comMem(this); });			//委員会メンバー取得 イベント追加
			},
			resize: function(evt,ui){
				$("#SGdiv").css("height",($("#SGdlog").height()-$("#addRep").height()-5)+"px");
			},
			close:function(){
				$(".F01").unbind("click");
				$("#committeeAria table tr td").removeClass("selBackColor");
				$.data($("#committeeAria").get(0), "comID", "");
				$(this).remove();
			}
		});

		if (gID >0) {
			$("#SGdlog").dialog("option", "buttons", {
				'閉じる': function() {
					$(this).dialog("close");
				},
				'削除': function() {
					chk_del_SG(gID);						//削除処理開始
				},
				'修正': function() {
					var gp =chk_sendGroup();
					if (gp !="") edit_sendGroup(gp);		//送信グループを修正
				}
			});
		} else {
			$("#SGdlog").dialog("option", "buttons", {
				'閉じる': function() {
					$(this).dialog("close");
				},
				'作成': function() {
					var gp =chk_sendGroup();
					if (gp !="") reg_sendGroup(gp);			//送信グループを保存
				}
			});
		}
	}

	function chk_sendGroup() {												//地区委員会 送信グループをの入力確認
		$("#addRep").text("");
		if ($("#SGnm input").val() =="") { $("#addRep").text("グループ名を入力してください"); return ""; }
		var w="";
		$("#SGList tr[class^='comID_']").each(function(idx, elm) {
			w=w + $(elm).attr("class").split("comID_")[1]+"/"+$(elm).find("td:eq(0)").attr("class").split("mID_")[1]+",";
		});
		return w;
	}

	function get_comMem(tgt) {												//地区委員会 送信グループを作成 委員会一覧の委員会名を選択
		var Obj		= $(tgt);
		var rspn	= Obj.attr("rowspan");									//rowspanを取得
		var Parent	= Obj.parent();
		var Next	= Parent.next();
		var flg		= false;
		var comID	= Parent.find("td:eq(1)").attr("id");
		var mem 	= "";
		var mID		= "";
		if ($.data($("#committeeAria").get(0), "comID") ==undefined || $.data($("#committeeAria").get(0), "comID") =="") {
			$.data($("#committeeAria").get(0), "comID", comID.split("comID_")[1]);
		}
		if ($("#SGnm input").val() =="") $("#SGnm input").val(Obj.text());	//委員会名を送信グループ名として取得
		if (Parent.find("td:eq(3)").text() !="") {
			edit_SGtr(comID, get_class(Parent.find("td:eq(3)"), "mID_"), Parent.find("td:eq(3)").text(), Parent.find("td:eq(4)").text().replace(/\(|\)/gi, ""), Parent.find("td:eq(3)"));
		}
		while(rspn-1 >=1) {
			flg =false;
			mID =get_class(Next.find("td:eq(2)"), "mID_");
			$("#SGList tr[class^='mID_']").each(function(idx, elm) {		//重複の確認
				if ($(elm).attr("class") ==mID) flg =true;
			});
			if (!flg) {
				mem = mem + '<tr class="'+ comID +'"><td class="'+ mID +'"><span class="ui-icon ui-icon-close inlineIco"></span>'+ Next.find("td:eq(2)").text() +"</td><td>"+ Next.find("td:eq(3)").text().replace(/\(|\)/gi, "") +"</td></tr>";
				Next.find("td:eq(2)").addClass("selBackColor");				//背景色を変更
			}
			Next = Next.next();
			rspn--;
		}
		$("#SGList").append(mem).trigger("update");
		edit_SGtr_del();													//trの削除イベント追加
	}

	function edit_SGtr(comID,id,name,club,Obj) {								//地区委員会 送信グループ tr作成
		var flg =false;
		//重複の確認
		$("#SGList tr[class^='mID_']").each(function(idx, elm) {
			if ($(elm).attr("class") ==id) flg =true;
		});
		if (flg) return;
		var mem ='<tr class="'+ comID +'"><td class="'+ id +'"><span class="ui-icon ui-icon-close inlineIco"></span>'+ name +"</td><td>"+ club +"</td></tr>";
		if (Obj !=undefined) Obj.addClass("selBackColor");					//背景色を変更
		$("#SGList").append(mem).trigger("update");
		edit_SGtr_del();													//trの削除イベント追加
	}

	function edit_SGtr_del() {												//地区委員会 送信グループ tr削除
		$("#SGList .ui-icon-close").click(function () {
			var tr	=$(this).parent().parent();
			var cls	=tr.attr("class");
			$("#committeeAria table tr td."+cls).removeClass("selBackColor");	//委員会一覧の削除した氏名の背景色を戻す
			tr.remove();
			$("#SGList").trigger("update");
		});
	}

	function reg_sendGroup(gp) {											//地区委員会 送信グループを保存
		var param = xmlModule+'?'+"_xsid="+$("#_xsid").val() + 
				"&_fn=reg_sendGroup"+ 
				"&_gp="+ gp + 
				"&_ry="+ $("#chg_comm_yr").val() + 
				"&_gNm="+ encodeURI($("#SGnm input").val()) + 
				"&_comID="+ $.data($("#committeeAria").get(0), "comID") + 
				"&cache=" + (new Date()).getTime() ;
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(){
				xmlRetry[reg_sendGroup_n]++ ;
				if(xmlRetry[reg_sendGroup_n]>(xmlRetryLimt-1))
					alert("サーバーとの通信に失敗しました。\n最新の情報に更新してください。\nxml failed reg_sendGroup");
				else {
					alert("サーバーとの通信に失敗しました\nもう一度「修正」ボタンを押してください。");
				}
				$.data($("#committeeAria").get(0), "comID", "");
			},success: function(httpObj){
				xmlRetry[reg_sendGroup_n]=0;
				var xmlRcS	= httpObj.getElementsByTagName("record");
				var SID		= xmlNull_chk(xmlRcS[0], "msg", "-1");
				if (SID ==-1) { location.reload(); return; }		//ログイン状態でなければreload
				if (SID ==0) {
					$("#addRep").text("登録しました");
					$.data($("#committeeAria").get(0), "comID", "");
				} else {
					$("#addRep").text("このグループ名はすでに使用されています");
				}
			}
		});
	}

	function open_SGList() {												//地区委員会 送信グループを編集
		if ($("#SGdlog").length || $("#SGListdlog").length) return;
		var dialog =	  '<div id="SGListdlog">';
		dialog = dialog + '	<div id="addRep"></div>';
		dialog = dialog + '	<div id="SGdiv" style="overflow: auto;height: 300px;">';
		dialog = dialog + '		<table border="0" cellspacing="1" cellpadding="0" style="width: 100%;" class="tablesorter" id="SGListtb">';
		dialog = dialog + '			<thead>';
		dialog = dialog + '				<tr class="Freezing">';
		dialog = dialog + '					<th>送信グループ名</th>';
		dialog = dialog + '				</tr>';
		dialog = dialog + '			</thead>';
		dialog = dialog + '			<tbody id="SGList">';
		dialog = dialog + '			</tbody>';
		dialog = dialog + '		</table>';
		dialog = dialog + '		<div id="loader"></div>';
		dialog = dialog + '	</div>';
		dialog = dialog + '</div>';
		$("#contner").append(dialog);
		$("#SGtb").tablesorter();									//tablesorter

		$("#SGListdlog").dialog({
			autoOpen : true,
			resizable: true,
			width: 300,
			modal: false,
			title:'送信グループ 編集',
			open:  function(evt,ui){
				get_SGList();
			},
			buttons: {
				'閉じる': function() {
					$(this).dialog("close");
				}
			},
			resize: function(evt,ui){
				$("#SGdiv").css("height",$("#SGListdlog").height()+"px");
			},
			close:function(){
				$(this).remove();
			}
		});
	}

	function get_SGList() {													//地区委員会 送信グループの一覧を取得
		var elm =$("#SGList"), elm2 =$("#loader");
		elm.empty();
		elm2.css({ height: "100px", background: "url(/images/ajax-loader_l.gif) no-repeat center" });
		var param = xmlModule+'?'+"_xsid="+document.URL + 
				"&_fn=get_SGList" + 
				"&_ry="+ $("#chg_comm_yr").val() + 
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(tp){
				xmlRetry[get_SGList_n]++ ;
				if(xmlRetry[get_SGList_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed get_SGList");
				else {
					get_SGList();
				}
			},success: function(httpObj){
				xmlRetry[get_SGList_n]=0;
				var xmlRcS	= httpObj.getElementsByTagName("record");
				var gID, gName, comID, mem="";
				for (var i=0; i<xmlRcS.length; i++) {
					gID		= xmlNull_chk(xmlRcS[i], "gID", "");
					gName	= xmlNull_chk(xmlRcS[i], "gName", "");
					comID	= xmlNull_chk(xmlRcS[i], "comID", "");
					mem		= mem + '<tr id="'+ gID +'"><td id="'+ comID +'">'+ gName +"</td></tr>";
				}
				elm.append(mem).trigger("update");
				elm2.css({ height: "0", background: "none" });
				elm.find("tr").click(function () {
					open_SG($(this).attr("id"));
					$.data($("#committeeAria").get(0), "comID", $(this).find("td:eq(0)").attr("id"));
					$("#SGListdlog").remove();
				});
			}
		});
	}

	function get_SGmem(gID) {													//地区委員会 送信グループのメンバー一覧を取得
		$("#SGList").empty();
		$("#loader").css({ height: "100px", background: "url(/images/ajax-loader_l.gif) no-repeat center" });
		var param = xmlModule+'?'+"_xsid="+document.URL + 
				"&_fn=get_SGmem" + 
				"&_gID=" + gID + 
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(tp){
				xmlRetry[get_SGmem_n]++ ;
				if(xmlRetry[get_SGmem_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed get_SGmem");
				else {
					get_SGmem(gID);
				}
			},success: function(httpObj){
				xmlRetry[get_SGmem_n]=0;
				var xmlRcS	= httpObj.getElementsByTagName("record");
				var mID, gID, comID, name, cName, gName, mem="", tbl="";
				for (var i=0; i<xmlRcS.length; i++) {
					mID		= xmlNull_chk(xmlRcS[i], "mID", "");
					gID		= xmlNull_chk(xmlRcS[i], "gID", "");
					comID	= xmlNull_chk(xmlRcS[i], "comID", "");
					name	= xmlNull_chk(xmlRcS[i], "name", "");
					cName	= xmlNull_chk(xmlRcS[i], "cName", "");
					gName	= xmlNull_chk(xmlRcS[i], "gName", "");
					mem		= mem + '<tr class="comID_'+ comID +'"><td class="mID_'+ mID +'"><span class="ui-icon ui-icon-close inlineIco"></span>'+ name +"</td><td>"+ cName +"</td></tr>";
				}
				$.data($("#addRep").get(0), "gID", gID);
				$("#loader").css({ height: "0", background: "none" });
				$("#SGList").append(mem).trigger("update");
				$("#SGdiv input").val(gName);
				edit_SGtr_del();
			}
		});
	}

	function edit_sendGroup(gp) {											//地区委員会 送信グループを修正
		var param = xmlModule+'?'+"_xsid="+$("#_xsid").val() + 
				"&_fn=edit_sendGroup"+ 
				"&_gp="+ gp + 
				"&_ry="+ $("#chg_comm_yr").val() + 
				"&_gID="+ $.data($("#addRep").get(0), "gID") + 
				"&_gNm="+ encodeURI($("#SGnm input").val()) + 
				"&_comID="+ $.data($("#committeeAria").get(0), "comID") + 
				"&cache=" + (new Date()).getTime() ;
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(){
				xmlRetry[edit_sendGroup_n]++ ;
				if(xmlRetry[edit_sendGroup_n]>(xmlRetryLimt-1))
					alert("サーバーとの通信に失敗しました。\n最新の情報に更新してください。\nxml failed edit_sendGroup");
				else {
					alert("サーバーとの通信に失敗しました\nもう一度「修正」ボタンを押してください。");
				}
			},success: function(httpObj){
				xmlRetry[edit_sendGroup_n]=0;
				var xmlRcS	= httpObj.getElementsByTagName("record");
				var SID		= xmlNull_chk(xmlRcS[0], "msg", "-1");
				if (SID !=0) { location.reload(); return; }		//ログイン状態でなければreload
				$("#addRep").text("修正しました");
			}
		});
	}

	function chk_del_SG(gID) {					//地区委員会 送信グループ削除の確認
		var dialog = '<div id="chk_del_dialog" title="送信グループの削除" style="display: none;">';
		dialog = dialog + '  <div id="del_alert"><span class="ui-icon ui-icon-alert"></span><p>'+ $("#SGnm input").val() +'<br />の送信グループを削除しますか？</p></div>';
		dialog = dialog + '</div>';
		$("#contner").append(dialog);

		$("#chk_del_dialog").dialog({
			resizable: false,
			modal: true,
			width: 'auto',
			minHeight: 80,
			buttons: {
				'キャンセル': function() {
					$(this).dialog("close");
				},
				'削除する': function() {
					del_SG(gID);			//送信グループを削除
				}
			},
			close: function() {
				$(this).remove();
			}
		});
	}

	function del_SG(gID) {													//地区委員会 送信グループを削除
		var param = xmlModule+'?'+"_xsid="+$("#_xsid").val() + 
				"&_fn=del_SG" + 
				"&_gID=" + gID + 
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(){
				xmlRetry[del_SG_n]++ ;
				if(xmlRetry[del_SG_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed del_SG");
				else {
					del_SG(gID);
				}
			},success: function(httpObj){
				xmlRetry[del_SG_n]=0;
				var xmlRcS	= httpObj.getElementsByTagName("record");
				var SID		= xmlNull_chk(xmlRcS[0], "msg", -1);
				if (SID !=0) { location.reload(); return; }		//ログイン状態でなければreload
				$("#chk_del_dialog").dialog("close");
				$("#SGdlog").dialog("close");
			}
		});
	}


	function evt_comDrop(tgt) {												//地区委員会 droppable イベント追加
		tgt.droppable({																		//地区委員会 F01へのdroppable イベント
			accept: ".nm",
			greedy: true,
			drop: function(evt, ui) {
				if (!$("#SGdlog").length) {														//送信グループ作成ダイアログは表示されていない
					var rspn	= $(this).attr("rowspan");										//rowspanを取得
					var idx		= $("#committeeAria table tr").index($(this).parent());			//dropした委員会のtrのindexを取得
					var Name	= ui.draggable.text();											//会員名を取得
					var mID		= ui.draggable.attr("id").split("mID_")[1];						//mIDを取得
					var club	= ui.draggable.parent().parent().find("td:eq(0)").text();		//クラブ名を取得 eq(0)
					var newRow	= '<tr><td>　</td><td class="Lst_TD comPos pos_">&nbsp;</td><td class="Lst_TD kNM mID_'+ mID +'">'+ Name +'</td><td class="Lst_TD">('+ club +')</td></tr>';
					$(this).attr("rowspan",(rspn+1));											//rowspanを+1
					$("#committeeAria table tr:eq("+ (rspn+idx-1) +")").after(newRow);			//rowspan+index-1番目の要素に新しい行を追加
					evt_comDrop_kNM($("#committeeAria table tr:eq("+ (rspn+idx) +") .kNM"));	//追加した行にkNMへのdroppable イベント追加
					evt_comSelect($("#committeeAria table tr:eq("+ (rspn+idx) +") .kNM"));		//追加した行にkNMの選択 イベント追加
					evt_comm_posSel($("#committeeAria table tr:eq("+ (rspn+idx) +") .comPos"));	//追加した行に役職selectBox表示 イベント追加
				}
			}
		});
		evt_comDrop_kNM($("#committeeAria table tr .kNM"));									//地区委員会 kNMへのdroppable イベント
	}

	function evt_comDrop_kNM(tgt) {											//地区委員会 kNMへのdroppable イベント
		tgt.droppable({
			accept: ".nm",
			drop: function(evt, ui) {
				if (!$("#SGdlog").length) {														//送信グループ作成ダイアログは表示されていない
					var Name	= ui.draggable.text();											//会員名を取得
					var mID		= ui.draggable.attr("id").split("mID_")[1];						//mIDを取得
					var club	= ui.draggable.parent().parent().find("td:eq(0)").text();		//クラブ名を取得 eq(0)
					var midCls	= get_class($(this), "mID_");									//指定したclass名を取得
					$(this).text(Name).removeClass(midCls).addClass("mID_"+mID);
					$(this).next().text('('+ club +')');
				}
			}
		});
	}

	function drp_toDialog() {												//地区委員会 dialog自身へのdrop
		$(".ui-dialog").droppable({
			drop: function(evt, ui) {
				$("#committeeAria table tr .F01").droppable("disable").css("filter","none");
				$("#committeeAria table tr .kNM").droppable("disable").css("filter","none");
			}
		});
	}

	function evt_comSelect(tgt) {											//地区委員会 kNMの選択 イベント追加
		tgt.click(function () {
			if ($("#SGdlog").length) {											//送信グループ作成ダイアログが表示されている
				var Obj =$(this);
				if (Obj.text() !="") {
					var tbl	=$("#committeeAria table");
					var idx	=tbl.find("tr").index(Obj.parent());	//選択したkNMの行のindexを取得
					while(idx >=0) {
						if (tbl.find("tr:eq("+ idx +") td:eq(1)").attr("id") !="") break;
						idx--;
					}
					var comID	=tbl.find("tr:eq("+ idx +") td:eq(1)").attr("id");				//comIDを取得
					edit_SGtr(comID, get_class(Obj, "mID_"), Obj.text(), Obj.next().text().replace(/\(|\)/gi, ""),Obj);	//委員会一覧の氏名を選択
				}
			} else {
				var selObj =$("#commData").get(0);
				if ($(this).attr("class").indexOf("selBackColor") >-1) {		//clickした場所はすでに選択されている
					$(this).removeClass("selBackColor");		//背景色を戻す
					$.data(selObj, "selObj", null);				//選択Objをnull
				} else {
					if ($.data(selObj, "selObj") !=null) $.data(selObj, "selObj").removeClass("selBackColor");
					$(this).addClass("selBackColor");			//背景色を変更
					$.data(selObj, "selObj", $(this));			//選択Objを保持
				}
			}
		});
	}

	function evt_comDel() {													//地区委員会 kNMの削除 イベント追加
		var selObj =$("#commData").get(0);
		$(document).keyup(function (e) {
			if (e.which ==46 && $.data(selObj, "selObj") !=null) {					//delキーが押されかつ選択Objが保持されている
				var tbl	=$("#committeeAria table");
				var idx	=tbl.find("tr").index($.data(selObj, "selObj").parent());	//選択したkNMの行のindexを取得
				var oIdx=idx;
				while(idx >=0) {
					if (tbl.find("tr:eq("+ idx +") td:eq(1)").attr("id") !="") break;
					idx--;
				}
				var comTr	=tbl.find("tr:eq("+ idx +") td:eq(1)");				//委員会名の行を取得
				if (oIdx !=idx) {												//委員会名の行以外
					comTr.attr("rowspan",(comTr.attr("rowspan")-1));			//rowspanを-1
					$.data(selObj, "selObj").parent().remove();					//選択した行を削除
				} else {														//委員会名の行
					if (comTr.attr("rowspan") ==1) {							//委員会は1行のみ
						var midCls	= get_class($.data(selObj, "selObj"), "mID_");							//mIDのclass名を取得
						var posCls	= get_class($.data(selObj, "selObj").prev(), "pos_");					//posのclass名を取得
						$.data(selObj, "selObj").removeClass(midCls).removeClass("selBackColor").empty();	//mID,選択背景色,名前を削除
						$.data(selObj, "selObj").prev().removeClass(posCls).empty();						//役職を削除
						$.data(selObj, "selObj").next().empty();											//クラブ名を削除
					} else {
						var parentTr=$.data(selObj, "selObj").parent();
						var newRow	='<td rowspan="'+ (comTr.attr("rowspan")-1) +'" class="Lst_TD F01" id="'+ comTr.attr("id") +'">'+ comTr.text() +'</td>';
						parentTr.next().find("td:eq(0)").after(newRow);			//委員会名+名前+クラブ名を追加
						evt_comDrop(parentTr.next().find("td:eq(1)"));			//F01へのdroppable イベント
						parentTr.remove();										//選択した行を削除
					}
				}
				$.data(selObj, "selObj", null);									//選択Objをnull
			}
		});
	}

	function evt_contxtM() {														//地区委員会 contextMenu
		var menu ="";
		menu =        '<ul id="myMenu" class="contextMenu2">';
		menu = menu + 	'<li class="curr"><a href="#m1"><span class="ui-icon ui-icon-search inlineIco"></span>Rotarian選択</a></li>';
		menu = menu + 	'<li class="past"><a href="#m2"><span class="ui-icon ui-icon-person inlineIco"></span>会長・幹事一覧</a></li>';
		menu = menu + 	'<li class="past"><a href="#m3"><span class="ui-icon ui-icon-disk inlineIco"></span>修正を保存</a></li>';
		menu = menu + 	'<li class="past separator"><a href="#m4"><span class="ui-icon ui-icon-document inlineIco"></span>送信グループを作成</a></li>';
		menu = menu + 	'<li class="past"><a href="#m5"><span class="ui-icon ui-icon-document-b inlineIco"></span>送信グループを編集</a></li>';
		menu = menu + 	'<li class="past separator"><a href="#m6"><span class="ui-icon ui-icon-copy inlineIco"></span>委嘱状を作成</a></li>';
		menu = menu + 	'<li class="past"><a href="#m7"><span class="ui-icon ui-icon-comment inlineIco"></span>宛先を作成</a></li>';
		menu = menu + '</ul>';
		$("#committeeAria").append(menu);
		$(".F01").contextMenu({
			menu: 'myMenu',
			button: 2
		},function(action, el, pos) {
			//var cID =$(el).attr('id').split("_")[2];
			if ($.browser.msie && $.browser.version <="7.0") action =action.split("#")[1];
			if (action =="m1") { open_CM(); }			//Rotarian選択
			if (action =="m2") { open_CPCS(); }			//会長・幹事一覧
			if (action =="m3") { chk_CM_dlg(); }		//修正を保存
			if (action =="m4") { open_SG(0); }			//送信グループを作成
			if (action =="m5") { open_SGList(); }		//送信グループを編集
			if (action =="m6") {						//委嘱状を作成
				if ($(el).parent().find("td.kNM").text() !="") {			//委員会に役員が存在している
					create_delgate($(el).attr("id").split("comID_")[1]);
				} else {
					alert("委員会に役員が設定されていません");
				}
			}
			if (action =="m7") {						//宛先を作成
				if ($(el).parent().find("td.kNM").text() !="") {			//委員会に役員が存在している
					location.href="/out_CSV.asp?_cid=" + $(el).attr("id").split("comID_")[1] + "&_fn=0";		//宛先を表示
				} else {
					alert("委員会に役員が設定されていません");
				}
			}
		});
	}

	function create_delgate(cID) {													//地区委員会 委嘱状を作成
		//alert($("#chg_comm_yr").val()+"/ "+cID);
		var param = delgateModule+'?'+"_xsid="+$("#_xsid").val() + 
		"&_cid=" + cID + 
		"&_ry=" + $("#chg_comm_yr").val() + 
		"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(tp){
				xmlRetry["create_delgate"]++ ;
				if(xmlRetry["create_delgate"]>(xmlRetryLimt-1)) {
					alert("作成に失敗しました。\n最新の情報に更新してから再度実行してください。\nxml failed create_delgate");
				} else {
					create_delgate(cID);
				}
			},success: function(httpObj){
				xmlRetry["create_delgate"]=0;
				var xmlRcS	= httpObj.getElementsByTagName("record");
				var path	= xmlNull_chk(xmlRcS[0], "path", "");
				//alert(path);
				if (path =="") {
					alert("作成に失敗しました。\n最新の情報に更新してから再度実行してください。\nxml failed create_delgate");
				} else {
					Openwin("/ImagePDF.asp?ImgPath=" + path +"","viewPDF","width=800,height=900,resizable=yes");		//pdfを表示
				}
			}
		});
	}


//================================================================================================== カレンダー
	function get_calen_yr() {														//カレンダー 年度切り替え年度取得
		var param = xmlModule+'?'+"_xsid="+ encodeURI(document.URL) + 
				"&_fn=get_calen_yr" + 
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(tp){
				xmlRetry["get_calen_yr"]++ ;
				if(xmlRetry["get_calen_yr"]>(xmlRetryLimt-1)) {
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed get_calen_yr");
				} else {
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed get_calen_yr");
					//get_calen_yr();
				}
			},success: function(httpObj){
				xmlRetry["get_calen_yr"]=0;
				var opt		="", ry, sel ="";
				var xmlRcS	= httpObj.getElementsByTagName("record");
				var yc		=$("#yc").val();		//表示している年度
				for (var i=0; i<xmlRcS.length; i++) {
					ry	= xmlNull_chk(xmlRcS[i], "ry", 0);
					if (ry ==yc) sel=" selected"; else sel="";
					opt		= opt + '<option value="'+ ry +'"'+sel+'>'+ ry +'-'+ (parseInt(ry)+1) +'</option>';
				}
				$("#chg_calen_yr").html(opt);
			}
		});
	}

	function get_Calen() {													//カレンダー 年度切り替え
		var elm = $("#CalenAria");
		elm.empty().css({ height: "100px", background: "url(/images/ajax-loader_l.gif) no-repeat center" });
		var param = xmlModule+'?'+"_xsid="+ encodeURI(document.URL) + 
				"&_fn=get_calen" + 
				"&_ry=" + $("#chg_calen_yr").val() + 
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(){
				xmlRetry["get_calen"]++ ;
				if(xmlRetry["get_calen"]>(xmlRetryLimt-1)) {
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed get_calen");
				} else {
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed get_calen");
					//get_Calen();
				}
			},success: function(httpObj){
				xmlRetry["get_calen"]=0;
				var ID, ry, theme, DS, CL, DT, TM, mcnt, dcnt, mcntF, dtRel;
				var tm ="", ico ="", s ="", w, buf, t, bbuf ="";
				var SID		= xmlNull_chk(httpObj, "SID", "");
				var FLG		= xmlNull_chk(httpObj, "FLG", "");
				var xmlRcS	= httpObj.getElementsByTagName("record");
				var Sc		= '<table id="DCTbl" width="650" border="0px" align="center" cellspacing="4" cellpadding="0">';
				for (var i=0; i<xmlRcS.length; i++) {
					ID		= xmlNull_chk(xmlRcS[i], "ID", "");
					ry		= xmlNull_chk(xmlRcS[i], "ry", "");
					theme	= xmlNull_chk(xmlRcS[i], "theme", "");
					DS		= xmlNull_chk(xmlRcS[i], "DS", "");
					CL		= xmlNull_chk(xmlRcS[i], "CL", "");
					DT		= xmlNull_chk(xmlRcS[i], "Date", "");
					TM		= xmlNull_chk(xmlRcS[i], "tm", "");
					mcnt	= xmlNull_chk(xmlRcS[i], "mcnt", "");
					dcnt	= xmlNull_chk(xmlRcS[i], "dcnt", "");
					mcntF	= xmlNull_chk(xmlRcS[i], "mcntF", "");

					if (tm !=theme) {
						if (DS =="" && mcnt >1) {
							s = '								<td class="Lst_TD theme" rowspan="'+ mcnt-1 +'">'+ theme +'</td>';
						} else {
							s ="";
							Sc += '						<tr id="DC_'+ ID +'">';
							Sc += '							<td></td>';
							if (tm =="") {
								if (mcntF >0) {
									Sc += '							<td class="Lst_TD theme" rowspan="'+ mcntF +'">'+ theme +'</td>';
								} else {
									Sc += '							<td class="Lst_TD theme" rowspan="'+ mcnt +'">a'+ theme +'</td>';
								}
							} else {
								Sc += '							<td class="Lst_TD theme" rowspan="'+ mcnt +'">'+ theme +'</td>';
							}
						}
					} else {
						Sc += '						<tr id="DC_'+ ID +'">';
						Sc += '							<td></td>';
						Sc += s;
						if (s !="") s ="";
					}

					ico ="";
					if (SID !="" && FLG !="") ico += '<span class="ui-icon ui-icon-pencil floatIco" title="カレンダー・出席者設定"></span>';
					if (s =="") {
						buf = DT;
						if (TM =="") {
							if (DS.substr(0,2) =="**") DS ='<span style="color:#f33;">[中止] </span><span style="color:#c33;">'+ DS.substr(2) +'</span>';
							if (DS.substr(0,2) =="^^") DS ='<span style="color:#215487;">[延期] </span><span style="color:#363;">'+ DS.substr(2) +'</span>';
						} else {
							buf =DT;
							if (DS.substr(0,2) =="**") DS ='<span style="color:#f33;">[中止] </span><span style="color:#c33;">'+ DS.substr(2) +'</span>';
							if (DS.substr(0,2) =="^^") DS ='<span style="color:#215487;">[延期] </span><span style="color:#363;">'+ DS.substr(2) +'</span>';
							DS = '<table width="100%" border="0px" cellspacing="0" cellpadding="0"><tr><td>'+ DS +'</td><td align="right" width="10%" nowrap>'+ TM +'</td></tr></table>';
						}
						if (bbuf ==buf) {
							buf ="　";
						} else {
							bbuf =buf;
						}
						Sc += '								<td class="Lst_TDR"><font color="'+ "#"+CL +'">'+ ico + buf +'</font></td>';
						Sc += '								<td class="Lst_TD"><font color="'+ "#"+CL +'">'+ DS +'</font></td>';
						Sc += '							</tr>';
					}
					tm =theme;
				}
				Sc += '</table>';
				elm.css({ height: "auto", background: "none" }).empty().html(Sc);
				addEvt_DS();
			}
		});
		//$("#xml_url").html('<a href="'+param+'">'+param+'</a>');
	}

	function addEvt_DS() {													//カレンダー 編集/hoverイベント追加
		$("tr[id^='DC_']").click(function (e) {		//click イベント
			if ($(e.target).attr("class").indexOf("theme") ==-1) {
				var cls =get_class($(e.target), "ui-icon-");
				switch (cls) {
					case "ui-icon-pencil":	open_DS($(this).attr("id").split("DC_")[1]); break;	//編集
					default:				open_DT($(this).attr("id").split("DC_")[1]);		//詳細
				}
			}
		});
		$("#DCTbl tr").hover(						//hover イベント
			function (e) {
				if ($(e.target).attr("class").indexOf("theme") ==-1) {
					$(this).addClass("DSHover");
				}
			},
			function () { $(this).removeClass("DSHover");	}
		);
	}

	function open_DS(id) {													//カレンダーダイアログ表示
		var i, j, hr ="", mn ="", insOptCom, insOptClub;

		for (i=8;i<23;i++) {							//時
			j=i;
			if (i<10) j="0"+i;
			hr = hr + '<option value="'+ i +'">'+ j +'</opiton>';
		}
		for (i=0;i<56;i+=5) {							//分
			j=i;
			if (i<10) j="0"+i;
			mn = mn + '<option value="'+ j +'">'+ j +'</opiton>';
		}
		var ry = parseInt($("#thisRy").text());			//ry

		var pc = '予定変更：<select id="planChange"><option value=""></option><option value="1">中止</option><option value="2">延期</option></select>';		//予定変更

		//挿入項目
		//クラブ用
		insOptClub ='<option value="#title">新着タイトル</option>';
		insOptClub =insOptClub + '<option value="#cTitle">カレンダータイトル</option>';
		insOptClub =insOptClub + '<option value="#gabaner">ガバナー</option>';
		insOptClub =insOptClub + '<option value="#dcs">地区幹事</option>';
		//insOptClub =insOptClub + '<option value="#attendance">出欠リンク</option>';
		//義務者用
		insOptCom =insOptClub + '<option value="#attendance">出欠リンク</option>';
		//insOptCom =insOptClub;

		var dialog =	  '<div id="DSdlog">';
		dialog = dialog + '	<div id="addRep"></div>';
		dialog = dialog + '	<div id="DSaccordion">';

		dialog = dialog + '		<h3 id="hd1"><a href="#">カレンダー編集</a></h3>';
		dialog = dialog + '		<div>';
		dialog = dialog + '			<table border="0" cellspacing="0" cellpadding="2" style="width: 100%;" id="calenEdit">';
		dialog = dialog + '				<tr>';
		dialog = dialog + '					<th>年度:</th>';
		dialog = dialog + '					<td><select id="ry"><option value="'+ ry +'">'+ ry +'-'+ (ry+1) +'</option><option value="'+ (ry+1) +'">'+ (ry+1) +'-'+ (ry+2) +'</option></select></td>'
		dialog = dialog + '				</tr>';
		dialog = dialog + '				<tr>';
		dialog = dialog + '					<th>開始日:</th>';
		dialog = dialog + '					<td><input type="text" value="" id="DateRel" style="ime-mode: disabled;" /> <span class="time"><select id="relH">'+ hr +'</select>：<select id="relM">'+ mn +'</select></span> <input type="checkbox" id="timeSel" />終日</td>';
		dialog = dialog + '				</tr>';
		dialog = dialog + '				<tr>';
		dialog = dialog + '					<th>終了日:</th>';
		dialog = dialog + '					<td><input type="text" value="" id="DatePri" style="ime-mode: disabled;" /> <span class="time"><select id="priH">'+ hr +'</select>：<select id="priM">'+ mn +'</select></span></td>';
		dialog = dialog + '				</tr>';
		dialog = dialog + '				<tr>';
		dialog = dialog + '					<th>内容:</th>';
		dialog = dialog + '					<td><input type="text" value="" id="Comment" style="ime-mode: active; width: 100%;" />';
		dialog = dialog + '				</tr>';
		dialog = dialog + '				<tr>';
		dialog = dialog + '					<th></th>';
		dialog = dialog + '					<td><table><tr>';
		dialog = dialog + '							<td><fieldset style="width: 275px;"><legend>※選択した項目が内容に複写されます</legend><input type="radio" name="rdo" id="rdo1">委員会　<input type="radio" name="rdo" id="rdo2">公式訪問<br /><select id="item"></select></fieldset></td>';
		if (id !=0) {
			dialog = dialog + '							<td><fieldset style="width: 130px;"><legend>※中止・延期設定</legend> '+ pc +'</fieldset></td>';
		}
		dialog = dialog + '					</tr></table></td>';
		dialog = dialog + '				</tr>';
		dialog = dialog + '			</table>';
		dialog = dialog + '		</div>';

		if (id !=0) {
			dialog = dialog + '		<h3 id="hd2"><a href="#">出席義務者</a></h3>';
			dialog = dialog + '		<div>';
			dialog = dialog + '			<div id="CMaccordion">';
			dialog = dialog + '				<h4 id="chd1"><a href="#">送信グループ</a></h4>';
			dialog = dialog + '				<div>';
			dialog = dialog + '					<p>送信グループ一覧: <select id="sendGP"></select>';
			dialog = dialog + '						<input type="button" value="義務者登録" id="reg_comMem" /><br />';
			dialog = dialog + '						<a href="javascript:void(0);" id="add_comMem"><span class="ui-icon ui-icon-search inlineIco"></span>Rotarian選択</a> ';
			dialog = dialog + '						<input type="button" value="登録済の義務者に戻す" id="rev_comMem" />';
			dialog = dialog + '					</p>';
			dialog = dialog + '					<table border="0" cellspacing="1" cellpadding="0" class="tablesorter" id="attendComm">';
			dialog = dialog + '						<thead>';
			dialog = dialog + '							<tr class="Freezing"><th>委員会</th><th>役職</th><th>氏名</th><th>クラブ</th></tr>';
			dialog = dialog + '						</thead>';
			dialog = dialog + '						<tbody>';
			dialog = dialog + '						</tbody>';
			dialog = dialog + '					</table>';
			dialog = dialog + '				</div>';
			dialog = dialog + '				<h4 id="chd2"><a href="#">義務者宛</a></h4>';
			dialog = dialog + '				<div>';
			dialog = dialog + '					<table border="0" cellspacing="1" cellpadding="0" id="sendEdit">';
			dialog = dialog + '						<tr><th></th><td style="text-align:right;"><span id="setcomMsg" style="color: #f00;"></span><select id="comInsList">'+ insOptCom +'</select><input type="button" value="挿入" id="comIns" /></td></tr>';
			dialog = dialog + '						<tr><th>タイトル:</th><td><input type="text" value="#cTitle" id="comTitle" style="ime-mode: active; width: 100%;" /></td></tr>';
			dialog = dialog + '						<tr><th>添付:</th><td><input type="button" value="ファイルの添付" id="comTmp" /> <span id="dTmp"></span></td></tr>';
			dialog = dialog + '						<tr><th>本文:</th><td><textarea id="laterComm"></textarea></td></tr>';
			dialog = dialog + '						<tr><th></th><td style="text-align: right;"><input type="button" value="確認" id="comPrv" /><input type="button" value="送信" id="comSend" /></td></tr>';
			dialog = dialog + '					</table>';
			dialog = dialog + '				</div>';
			dialog = dialog + '				<h4 id="chd3"><a href="#">クラブ宛</a></h4>';
			dialog = dialog + '				<div>';
			dialog = dialog + '					<table border="0" cellspacing="1" cellpadding="0" id="sendEdit2">';
			dialog = dialog + '						<tr><th></th><td style="text-align:right;"><span id="setclubMsg" style="color: #f00;"></span><select id="clubInsList">'+ insOptClub +'</select><input type="button" value="挿入" id="clubIns" /></td></tr>';
			dialog = dialog + '						<tr><th>タイトル:</th><td><input type="text" value="#cTitle" id="clubTitle" style="ime-mode: active; width: 100%;" /></td></tr>';
			dialog = dialog + '						<tr><th>添付:</th><td><input type="button" value="ファイルの添付" id="clubTmp" /> <span id="cTmp"></span></td></tr>';
			dialog = dialog + '						<tr><th>本文:</th><td><textarea id="laterClub"></textarea></td></tr>';
			dialog = dialog + '						<tr><th></th><td style="text-align: right;"><input type="button" value="確認" id="clubPrv" /><input type="button" value="送信" id="clubSend" /></td></tr>';
			dialog = dialog + '					</table>';
			dialog = dialog + '				</div>';
			dialog = dialog + '			</div>';
			dialog = dialog + '		</div>';

			dialog = dialog + '		<h3 id="hd3"><a href="#">クラブ出席者登録</a></h3>';
			dialog = dialog + '		<div>';
			dialog = dialog + '			<div style="overflow: auto;height:'+$(window).height()*0.7+'px;">';
			dialog = dialog + '			<table border="0" cellspacing="1" cellpadding="0" class="tablesorter" id="attendClub">';
			dialog = dialog + '				<thead>';
			dialog = dialog + '					<tr class="Freezing">';
			dialog = dialog + '						<th>クラブ</th><th>氏名</th><th>役職</th>';
			dialog = dialog + '					</tr>';
			dialog = dialog + '				</thead>';
			dialog = dialog + '				<tbody>';
			dialog = dialog + '				</tbody>';
			dialog = dialog + '			</table>';
			dialog = dialog + '			</div>';
			dialog = dialog + '		</div>';

			dialog = dialog + '		<h3 id="hd4"><a href="#">出欠確認</a></h3>';
			dialog = dialog + '		<div>';
			dialog = dialog + '			<div style="overflow: auto;height:'+$(window).height()*0.7+'px;">';
			dialog = dialog + '			<p>出席義務者</p>';
			dialog = dialog + '			<table border="0" cellspacing="1" cellpadding="0" class="tablesorter" id="attendChk_com">';
			dialog = dialog + '				<thead>';
			dialog = dialog + '					<tr class="Freezing">';
			dialog = dialog + '						<th>委員会</th><th>役職</th><th>クラブ</th><th>氏名</th><th>出欠</th>';
			dialog = dialog + '					</tr>';
			dialog = dialog + '				</thead>';
			dialog = dialog + '				<tbody>';
			dialog = dialog + '				</tbody>';
			dialog = dialog + '			</table>';
			dialog = dialog + '			<p style="margin-top: 15px;">クラブ出席者<input type="checkbox" id="club_uncon_exef" name="club_uncon_exef" value="1">出欠未確認分を送信する</p>';
			dialog = dialog + '			<table border="0" cellspacing="1" cellpadding="0" class="tablesorter" id="attendChk_club">';
			dialog = dialog + '				<thead>';
			dialog = dialog + '					<tr class="Freezing">';
			dialog = dialog + '						<th>役職</th><th>クラブ</th><th>氏名</th><th>出欠</th>';
			dialog = dialog + '					</tr>';
			dialog = dialog + '				</thead>';
			dialog = dialog + '				<tbody>';
			dialog = dialog + '				</tbody>';
			dialog = dialog + '			</table>';
			dialog = dialog + '			</div>';
			dialog = dialog + '		</div>';
		}
		dialog = dialog + '	</div>';
		dialog = dialog + '</div>';
		$("#dmCont").append(dialog);

		//accordion
		$("#CMaccordion").accordion({ autoHeight: false });
		$("#DSaccordion").accordion({
			autoHeight: false,
			changestart: function(e, ui) {
				var hd =ui.newHeader.attr("id");
				switch (hd) {
					case "hd1":	get_DSdlog_hd1(id);	break;	//カレンダー編集
					case "hd2":	get_DSdlog_def();	break;
					case "hd3":	get_DSdlog_hd3(id);	break;	//クラブ出席者登録
					case "hd4":	get_DSdlog_hd4(id);	break;	//出欠確認
					default:	get_DSdlog_def();
				}
			}
		}).find("div .tablesorter").tablesorter();

		//日付
		$("#DateRel, #DatePri").datepicker({ dateFormat: 'yy/mm/dd', minDate: new Date(ry, 7-1, 1), maxDate: new Date((parseInt(ry)+1), 6-1, 30) });
		$("#DateRel").datepicker('disable');			//datepicker disable
		$("#ry").change(function () {					//年度切り替え
			$("#DateRel, #DatePri").datepicker("option", "minDate", new Date($(this).val(), 7-1, 1)).datepicker("option", "maxDate", new Date((parseInt($(this).val())+1), 6-1, 30));
		});
		//時間
		$("#relH").change(function () {					//時間を選択時
			if ($("#DateRel").val() >=$("#DatePri").val()) {
				if (parseInt($(this).val()) >parseInt($("#priH").val())) {
					$("#priH").val($(this).val());
				}
			}
		});
		//終日
		$(".time").css("visibility", "hidden");
		$("#timeSel").click(function () {
			if ($(this).attr("checked") ==true) {		//終日 clickEvt
				$(".time").css("visibility", "hidden");
			} else {
				$(".time").css("visibility", "visible");
			}
		});
		//種類
		get_committee(1,id);							//委員会を取得
		$("#add_comMem").click(function () {			//Rotarian選択
			open_CM_calen();
		});
		get_visit(0);									//公式訪問を取得
		get_sendGP();									//送信グループ一覧を取得
		get_Details(id,1);								//トピックスの内容を取得
		get_AttedList_comm(id);							//出席義務者を取得
		get_AttedList(id);								//出席者を取得
		get_attendClub(id);								//クラブ出席者を取得
		$("#rdo1").attr("checked",true);				//委員会をchecked
		$("#rdo1").click(function () {					//委員会に表示切替
			$("#item").html($.data($("#DSdlog").get(0), "committee"));
		});
		$("#rdo2").click(function () {					//公式訪問に表示切替
			$("#item").html($.data($("#DSdlog").get(0), "visit"));
		});
		$("#reg_comMem").click(function () {			//義務者 登録
			chk_comMem(id);
		});
		$("#rev_comMem").click(function () {			//義務者 変更前に戻す
			get_AttedList_comm(id);
			$("#sendGP").val("");
		});
		$("#comIns").click(function () {				//義務者 挿入
			evt_insert($("#comInsList").val(),0);
		});
		$("#comTitle, #laterComm").click(function () {	//義務者 選択したformのID
			$.data($("#attendComm").get(0), "frmPos0", $(this).attr("id"));
		});
		$("#comTmp").click(function () {				//義務者 ファイルの添付
			creat_tmp_dlog(id,0);
		});
		$("#comPrv").click(function () {				//義務者 送信の確認
			send_com(id,0);
		});
		$("#comSend").click(function () {				//義務者 送信
			send_com(id,1);
		});
		$("#clubIns").click(function () {				//クラブ 挿入
			evt_insert($("#clubInsList").val(),1);
		});
		$("#clubTitle, #laterClub").click(function () {	//クラブ 選択したformのID
			$.data($("#attendComm").get(0), "frmPos1", $(this).attr("id"));
		});
		$("#clubTmp").click(function () {				//クラブ ファイルの添付
			creat_tmp_dlog(id,1);
		});
		$("#clubPrv").click(function () {				//クラブ 送信の確認
			send_club(id,0);
		});
		$("#clubSend").click(function () {				//クラブ 送信
			send_club(id,1);
		});
		$("#item").change(function () {					//選択されたitemを内容へコピー
			$("#Comment").val($(this).find("option:selected").text());
		});
		$("#sendGP").change(function () {				//送信グループ一覧を変更時
			chg_sendGP($(this).val());
		});

		$("#DSdlog").dialog({
			autoOpen : true,
			resizable: true,
			width: 550,
			//maxHeight: ($(window).height()*0.8),
			modal: true,
			position: [150,10],
			title:'カレンダー新規登録・編集',
			open:function(){
				$("#ry").val($("#chg_calen_yr").val()).trigger("change");	//年度
				$("#DateRel").datepicker('enable');		//datepicker enable
				$("#timeSel").attr("checked",true);		//終日 check
				get_DS(id);
				if (id ==0) {							//新規
					$("#ry").val(ry).trigger("change");
					$("#relH, #priH").val("12");
					$("#relM, #priM").val("00");
				}
			},
			/*resize:function(evt, ui){
				$("#DSaccordion").accordion("resize");
			},*/
			close:function(){
				if ($("#chk_clubM_dialog").length) $("#chk_clubM_dialog").remove();
				$(this).remove();
			}
		});
		get_DSdlog_hd1(id);								//カレンダー編集のボタンを取得 hd1
	}

	function get_DSdlog_hd1(id) {													//カレンダー カレンダー編集のボタンを取得 hd1
		if (id >0) {
			$("#DSdlog").dialog("option", "buttons", {
				'閉じる': function() {
					$(this).dialog("close");
				},
				'削除': function() {
					if (id >0) chk_del_DC(id);	//削除処理開始
				},
				'新規で登録': function() {
					if (chk_edit_DC()) {		//新規で登録処理開始
						reg_DS(0,1);
					}
				},
				'修正': function() {
					if (chk_edit_DC()) {		//登録処理開始
						reg_DS(id,0);
					}
				}
			});
		} else {
			$("#DSdlog").dialog("option", "buttons", {
				'閉じる': function() {
					$(this).dialog("close");
				},
				'登録': function() {
					if (chk_edit_DC()) {		//登録処理開始
						reg_DS(id,0);
					}
				}
			});
		}
	}

	function get_DSdlog_hd3(id) {													//カレンダー カレンダー編集のボタンを取得 hd3
		$("#DSdlog").dialog("option", "buttons", {
			'閉じる': function() {
				$(this).dialog("close");
			},
			'クラブ出席者の登録修正': function() {
				reg_clubMem(id,1);				//クラブ出席者 登録
			}
		});
	}

	function get_DSdlog_hd4(id) {													//カレンダー カレンダー編集のボタンを取得 hd4
		$("#DSdlog").dialog("option", "buttons", {
			'閉じる': function() {
				$(this).dialog("close");
			},
			'出欠一覧出力': function() {
				out_atMem(id);					//出欠一覧出力
			},
			'出欠未確認メール': function() {
				send_unconf(id,0,($('#club_uncon_exef').attr('checked'))? 1 : 0);				//出欠未確認メール
			},
			'出欠の変更': function() {
				reg_atChg(id);					//出欠の変更
			}
		});
	}

	function get_DSdlog_def() {														//カレンダー カレンダー編集のボタンを取得 default
		$("#DSdlog").dialog("option", "buttons", {
			'閉じる': function() { $(this).dialog("close"); }
		});
	}

	function get_committee(tp,id) {													//カレンダー 委員会を取得
		if ($.data($("#DSdlog").get(0), "committee") ==null) {
			var param = xmlModule+'?'+"_xsid="+$("#_xsid").val() + 
					"&_fn=get_committee" + 
					"&_ry=" + $("#ry").val() +
					"&cache=" + (new Date()).getTime();
			$.ajax({
				url: param,
				type: 'POST',
				dataType: 'xml',
				timeout: xmlRetryTimeout,
				error: function(tp){
					xmlRetry[get_committee_n]++ ;
					if(xmlRetry[get_committee_n]>(xmlRetryLimt-1))
						alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed get_committee");
					else {
						get_committee(tp);
					}
				},success: function(httpObj){
					xmlRetry[get_committee_n]=0;
					var name, kname;
					var opt ='<option value=""></option>';
					var xmlRcS	= httpObj.getElementsByTagName("record");
					for (var i=0; i<xmlRcS.length; i++) {
						name	= xmlNull_chk(xmlRcS[i], "Name", "");
						opt		= opt + '<option value="'+ name +'">'+ name +'</option>';
					}
					if (tp ==1) $("#item").html(opt);
					$.data($("#DSdlog").get(0), "committee", opt);			//委員会を保持

					xmlRcS	= httpObj.getElementsByTagName("precord");
					for (var j=0; j<xmlRcS.length; j++) {
						name	= xmlNull_chk(xmlRcS[j], "Name", "");
						kname	= xmlNull_chk(xmlRcS[j], "kNAME", "");
						if (id !=0) {
							if (j ==0) { $.data($("#attendComm").get(0), "gabaner", name+" "+kname); } 	//ガバナーを取得
							if (j ==1) { $.data($("#attendComm").get(0), "dcs", name+" "+kname); }		//地区幹事を取得
						}
					}
				}
			});
		} else {
			$("#item").html($.data($("#DSdlog").get(0), "committee"));
		}
	}

	function get_visit(tp) {														//カレンダー 公式訪問を取得
		if ($.data($("#DSdlog").get(0), "visit") ==null) {
			var param = xmlModule+'?'+"_xsid="+$("#_xsid").val() + 
					"&_fn=get_visit" + 
					"&_ry=" + $("#ry").val() +
					"&cache=" + (new Date()).getTime();
			$.ajax({
				url: param,
				type: 'POST',
				dataType: 'xml',
				timeout: xmlRetryTimeout,
				error: function(tp){
					xmlRetry[get_visit_n]++ ;
					if(xmlRetry[get_visit_n]>(xmlRetryLimt-1))
						alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed get_visit");
					else {
						get_visit(tp);
					}
				},success: function(httpObj){
					xmlRetry[get_visit_n]=0;
					var name;
					var opt ='<option value=""></option>';
					var xmlRcS	= httpObj.getElementsByTagName("record");
					for (var i=0; i<xmlRcS.length; i++) {
						name	= xmlNull_chk(xmlRcS[i], "Name", "");
						opt		= opt + '<option value="'+ name +'">'+ name + "RC公式訪問" +'</option>';
					}
					if (tp ==1) $("#item").html(opt);
					$.data($("#DSdlog").get(0), "visit", opt);				//公式訪問を保持
				}
			});
		} else {
			$("#item").html($.data($("#DSdlog").get(0), "visit"));
		}
	}

	function get_sendGP() {												//カレンダー 送信グループ一覧を取得
		var param = xmlModule+'?'+"_xsid="+$("#_xsid").val() + 
				"&_fn=get_SGList" + 
				"&_ry=" + $("#ry").val() +
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(tp){
				xmlRetry[get_sendGP_n]++ ;
				if(xmlRetry[get_sendGP_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed get_sendGP");
				else {
					get_sendGP();
				}
			},success: function(httpObj){
				xmlRetry[get_sendGP_n]=0;
				var gID, gName;
				var opt ='<option value=""></option>';
				var xmlRcS	= httpObj.getElementsByTagName("record");
				for (var i=0; i<xmlRcS.length; i++) {
					gID		= xmlNull_chk(xmlRcS[i], "gID", "");
					gName	= xmlNull_chk(xmlRcS[i], "gName", "");
					opt		= opt + '<option value="'+ gID +'">'+ gName +'</option>';
				}
				$("#sendGP").html(opt);
			}
		});
	}

	function chg_sendGP(gID) {											//カレンダー 送信グループ一覧を変更時
		var param = xmlModule+'?'+"_xsid="+$("#_xsid").val() + 
				"&_fn=get_SGmem" + 
				"&_gID=" + gID +
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(tp){
				xmlRetry[chg_sendGP_n]++ ;
				if(xmlRetry[chg_sendGP_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed chg_sendGP");
				else {
					chg_sendGP(gID);
				}
			},success: function(httpObj){
				xmlRetry[chg_sendGP_n]=0;
				var mID, name, cName, comID, comm, pos;
				var tr ="";
				var xmlRcS	= httpObj.getElementsByTagName("record");
				for (var i=0; i<xmlRcS.length; i++) {
					mID		= xmlNull_chk(xmlRcS[i], "mID", "");
					name	= xmlNull_chk(xmlRcS[i], "name", "");
					cName	= xmlNull_chk(xmlRcS[i], "cName", "");
					comID	= xmlNull_chk(xmlRcS[i], "comID", "");
					comm	= xmlNull_chk(xmlRcS[i], "comm", "");
					pos		= xmlNull_chk(xmlRcS[i], "pos", "");
					tr		= tr + '<tr id="'+ comID +'"><td><input type="checkbox" value="" checked="checked" />'+ comm +'</td><td>'+ pos +'</td><td id="mID_'+ mID +'">'+ name +'</td><td>'+ cName +'</td></tr>';
				}
				if (i>0 && $("#CMdlog").length) tr = tr + '<tr><td><input type="checkbox" value="" checked="checked" /></td><td></td><td></td><td></td></tr>';
				$("#attendComm tbody").html(tr);
				if (i>0) $("#attendComm").trigger("update").trigger("sorton",[[]]);
				evt_comSelect_calen($("#attendComm tbody tr").find("td:eq(2)"));		//氏名を選択
				$(document).unbind('keyup');
				evt_comDel_calen();														//選択trの削除
				$("#comPrv, #comSend").attr("disabled",true).attr("title","義務者の登録を行ってください");
			}
		});
	}

	function open_CM_calen() {											//カレンダー Rotarian選択ダイアログ表示
		if ($("#CMdlog").length) return;
		create_CMdlog();									//CMdlog作成
		var tid =null;
		$("#clubSearch, #nameSearch").keyup(function () {	//クラブ検索・氏名検索
			clearTimeout(tid);
			tid=setTimeout("get_keyupQuery_calen()",1000);
		});
		$("#CMdlog").dialog({
			autoOpen : true,
			resizable: true,
			width: 390,
			modal: false,
			title:'Rotarian選択',
			open: function(evt,ui){
				//新規追加 tr を作成
				if ($("#attendComm tbody tr:last td:eq(2)").text() !="") {
					$("#attendComm tbody tr:last").after('<tr><td><input type="checkbox" value="" checked="checked" /></td><td></td><td></td><td></td></tr>');
					evt_comSelect_calen($("#attendComm tbody tr:last td:eq(2)"));		//氏名を選択
				}
				//dialog自身へのdrop
				//drp_toDialog();
				evt_comDrop_calen($("#attendComm tbody tr:last td:eq(2)"));
			},
			resize: function(evt,ui){
				$("#CMdiv").css("height",$("#CMdlog").height()-($("#SCHtb").height()+10)+"px");
			},
			close:function(){
				//新規追加した tr が空欄なら削除
				if ($("#attendComm tbody tr:last td:eq(2)").text() =="") {
					$("#attendComm tbody tr:last").remove();
				}
				$(this).remove();
			}
		});
	}

	function get_keyupQuery_calen() {													//カレンダー クラブ・氏名検索
		var elm =$("#CMList"), elm2 =$("#loader");
		elm.empty();
		elm2.css({ height: "100px", background: "url(/images/ajax-loader_l.gif) no-repeat center" });
		var param = xmlModule+'?'+"_xsid="+document.URL + 
				"&_fn=get_keyupQuery" + 
				"&_ry=" + $("#chg_comm_yr").val() +
				"&_club=" + encodeURI($("#clubSearch").val()) +
				"&_name=" + encodeURI($("#nameSearch").val()) +
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(tp){
				xmlRetry[get_keyupQuery_calen_n]++ ;
				if(xmlRetry[get_keyupQuery_calen_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed get_keyupQuery_calen");
				else {
					get_keyupQuery_calen();
				}
			},success: function(httpObj){
				xmlRetry[get_keyupQuery_calen_n]=0;
				var comm ='', mID, style;
				var xmlRcS	= httpObj.getElementsByTagName("record");
				for (var i=0; i<xmlRcS.length; i++) {
					mID =xmlNull_chk(xmlRcS[i], "mID", "");
					style ="";
					$("#attendComm tbody tr td[id^='mID_']").each(function(idx, elment) {	//出席義務者は非表示
						if ("mID_"+mID ==$(elment).attr("id")) style =' style="display: none;"';
					});
					comm = comm + '<tr '+ style +'>';
					comm = comm + '	<td class="cne_'+ xmlNull_chk(xmlRcS[i], "cNameE", "") +'">'+ xmlNull_chk(xmlRcS[i], "cName", "") +'</td>';
					comm = comm + '	<td class="ne">'+ xmlNull_chk(xmlRcS[i], "NameE", "") +'</td>';
					comm = comm + '	<td><div id="mID_'+ mID +'" class="nm" style="white-space: nowrap;">'+ xmlNull_chk(xmlRcS[i], "Name", "") +'</div></td>';
					comm = comm + '</tr>';
				}
				elm.append(comm);
				elm2.css({ height: "0", background: "none" });
				if (i >0) $("#CMtb").trigger("update").trigger("sorton",[[[0,0]]]);
				//ローマ字クラブ名をclubSearchへセット
				$("#CMList tr td[class^='cne_']").click(function () {
					$("#clubSearch").val($(this).attr("class").split("cne_")[1]);
				});
				//draggable イベント追加
				$("#CMList tr .nm").draggable({
					containment: '#attendComm',
					helper: "clone",
					start: function(evt, ui) {
						$("#CMdlog").parent().css("overflow","visible");
					},
					stop: function(evt, ui) { $("#CMdlog").parent().css("overflow","hidden"); }
				});

				//過去の委員会履歴を表示
				$("#CMList tr .nm").one("click", function(){
					get_mouseoverQuery($(this));
				});
				//会員情報を修正
				$("#CMList tr .nm").dblclick(function () {
					$.data($("#commData").get(0), "memEdit", "CM");
					open_memEdit($(this));
				});
			}
		});
	}

	function evt_comDrop_calen(tgt) {									//カレンダー 氏名へのdroppable イベント
		tgt.droppable({
			accept: ".nm",
			drop: function(evt, ui) {
				var Name	= ui.draggable.text();											//会員名を取得
				var mID		= ui.draggable.attr("id").split("mID_")[1];						//mIDを取得
				var club	= ui.draggable.parent().parent().find("td:eq(0)").text();		//クラブ名を取得 eq(0)
				var dmID	= $(this).attr("id");
				ui.draggable.parent().parent().hide();										//dragしたtrをhide
				$(this).text(Name).attr("id","mID_"+mID).next().text(club);
				if ($("#attendComm tbody tr:last td:eq(2)").text() !="") {
					$("#attendComm tbody tr:last").after('<tr><td><input type="checkbox" value="" checked="checked" /></td><td></td><td></td><td></td></tr>');
					evt_comDrop_calen($(this).parent().next().find("td:eq(2)"));
					evt_comSelect_calen($(this).parent().next().find("td:eq(2)"));
				}
				if (dmID !="") $("#CMtb tbody tr td div#"+dmID).parent().parent().show();	//氏名の入替え
				$("#comPrv, #comSend").attr("disabled",true).attr("title","義務者の登録を行ってください");
			}
		});
	}

	function evt_comSelect_calen(tgt) {									//カレンダー 氏名の選択 イベント追加
		tgt.click(function () {
			var selObj =$("#attendComm").get(0);
			if ($(this).attr("class").indexOf("selBackColor") >-1) {		//clickした場所はすでに選択されている
				$(this).removeClass("selBackColor");		//背景色を戻す
				$.data(selObj, "selObj", null);				//選択Objをnull
			} else {
				if ($.data(selObj, "selObj") !=null) $.data(selObj, "selObj").removeClass("selBackColor");
				$(this).addClass("selBackColor");			//背景色を変更
				$.data(selObj, "selObj", $(this));			//選択Objを保持
			}
		});
	}

	function evt_comDel_calen() {													//カレンダー 選択trの削除 イベント追加
		var selObj =$("#attendComm").get(0);
		$(document).keyup(function (e) {
			if (e.which ==46 && $.data(selObj, "selObj") !=null) {			//delキーが押されかつ選択Objが保持されている
				var mID =$.data(selObj, "selObj").attr("id");
				$("#CMtb tbody tr td div#"+mID).parent().parent().show();	//Rotarian検索で削除した氏名の表示
				$.data(selObj, "selObj").parent().remove();					//選択したtrを削除
				$.data(selObj, "selObj", null);								//選択Objをnull
				$("#comPrv, #comSend").attr("disabled",true).attr("title","義務者の登録を行ってください");
			}
		});
	}

	//-------------------------------------------------------------------------------------------textareaへの挿入
	function evt_insert(txt,mode) {
		if (mode ==0) {
			var tgt	= $.data($("#attendComm").get(0), "frmPos0");
		} else {
			var tgt	= $.data($("#attendComm").get(0), "frmPos1");
		}
		if (tgt ==null) return;

		var el	= document.getElementById(tgt);
		if ($.browser.msie) {	//IE
			el.focus();
			var range	= document.selection.createRange();
			range.text	= txt + range.text;
		} else {
			var len	= el.selectionStart;
			var buf	= el.value;
			var A	= buf.substr(0, len);
			var B	= buf.substr(len, buf.length);
			el.value= A + txt + B;
		}
	}

	//-------------------------------------------------------------------------------------------ファイル添付関連
	function creat_tmp_dlog(ID,mode) {						//ダイアログを作成
		var dialog	='<div id="tmp_dlog" style="display: none;">';
		dialog = dialog + '  <p style="margin-bottom: 2px;">添付するファイルを選択してください（2MBまで）： </p>';
		dialog = dialog + '  <div id="fileQ"></div>';
		dialog = dialog + '  <input type="file" id="upBtn" value="" />';
		dialog = dialog + '</div>';
		$("#DSdlog").append(dialog);

		var dlogObj		=$("div[aria-labelledby^='ui-dialog-title']");
		var dlogZidx	=dlogObj.css("z-index");
		dlogObj.css({ zIndex: "50" });

		$("#tmp_dlog").dialog({				//ダイアログイベント追加
			resizable	: false,
			autoOpen	: true,
			modal		: false,
			width		: '360px',
			height		: 'auto',
			title		: "添付ファイル アップロード",
			buttons: {
				'閉じる': function() {
					$(this).dialog("close");
				},
				'選択したファイルを追加': function() {
					$("#upBtn").uploadifyUpload();
				}
			},
			close: function() {
				dlogObj.css({ zIndex: dlogZidx });
				$(this).remove();
			}
		});
		//アップロードイベント追加
		var fileSizelimit = 2000000;				//ファイルサイズMax
		var typ	= "";
		var dir	= "duty";
		var sq	= $.data($("#DSdlog").get(0), "dCnt");
		if (mode ==1) { dir ="club"; sq =$.data($("#DSdlog").get(0), "cCnt"); }
		var mcnt =sq;
		$("#upBtn").uploadify({
			'uploader'			: uploader,
			'script'			: script,
			'cancelImg'			: cancelImg,
			'folder'			: '',
			'queueID'			: 'fileQ',
			'queueSizeLimit'	: 2,
			'sizeLimit'			: fileSizelimit,
			'auto'				: false,
			'multi'				: true,
			'scriptData'		: { 'ID': ID, 'dir': dir, 'sq': ++sq },
			'fileDesc'			: 'PDF、Wordファイルを選択してください',
			'fileExt'			: '*.pdf;*.doc',
			onError: function (evt, queueID, fileObj, errorObj) {
				//alert("onError:\n"+queueID+" \n"+fileObj.name+" /"+fileObj.size+" /"+fileObj.type+" \n"+errorObj.type+" /"+errorObj.info);
				if (fileObj.size > fileSizelimit) {
					alert(fileObj.name+" アップロードエラー:\nファイルサイズが "+fileSizelimit+"バイトを超えています。");
				}
			},
			onComplete: function (evt, queueID, fileObj, response, data) {
				//alert("onComplete: "+queueID+" /"+response);
				typ = typ+fileObj.type+",";
				$("#upBtn").uploadifySettings("scriptData", { "sq": ++sq });	//連番処理
			},
			onAllComplete: function (evt, data) {
				//alert("onAllComplete: "+data.filesUploaded+" /"+data.errors+" /"+data.allBytesLoaded+" /"+data.speed);
				if (data.errors ==0) {
					reg_clenTmptUp(ID, mode, typ, data.filesUploaded, mcnt, sq);	//アップ成功
				} else {
					//reg_Up_err(ID, sq);	//アップエラー
				}
			}
		});
	}

	function reg_clenTmptUp(ID, mode, typ, cnt, mcnt, sq) {				//添付ファイル アップされたファイルの登録処理
		var xml=xmlModule+'?'+"_xsid="+$("#_xsid").val() + 
				"&_fn=reg_clenTmptUp" + 
				"&_ID="+ ID + 
				"&_mode="+ mode + 
				"&_typ="+ typ + 
				"&_cnt="+ cnt + 
				"&_mcnt="+ mcnt + 
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: xml,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(){
				xmlRetry["reg_clenTmptUp"]++ ;
				if(xmlRetry["reg_clenTmptUp"]>(xmlRetryLimt-1)) {
					//reg_Up_err($.data($("#TopicsDialog").get(0), "nID"),(parseInt(sq)+1));
					alert("登録に失敗しました。\n最新の情報に更新し、再度登録してください。\nxml failed reg_clenTmptUp");
				} else {
					alert("登録に失敗しました。\n最新の情報に更新し、再度登録してください。\nxml failed reg_clenTmptUp");
					//reg_clenTmptUp(sq, cnt);
				}
			},success: function(httpObj){
				xmlRetry["reg_clenTmptUp"]=0;
				var xmlRcS = httpObj.getElementsByTagName("record");
				var SID		= xmlNull_chk(httpObj, "SID", "");				//SID
				if (SID=="") { location.href="./pDistrict.asp?tp=3"; return; }	//ログイン状態でなければreload
				var CHK		= xmlNull_chk(xmlRcS[0], "CHK", 0);
				if (CHK ==0) {												//アップエラー
					alert("登録に失敗しました。\n最新の情報に更新し、再度登録してください。\nxml failed reg_tmptUp");
					return ;
				}
				//get_tmpData($.data($("#TopicsDialog").get(0), "nID"));		//添付ファイル を取得しなおす
				//get_topics(0,1);											//topics を取得しなおす
				if (mode ==1) {			//添付ファイルmaxカウント更新
					$.data($("#DSdlog").get(0), "cCnt", (sq-1));
				} else {
					$.data($("#DSdlog").get(0), "dCnt", (sq-1));
				}
				get_clenTmp(ID);		//添付ファイルの再読込み
				$("#tmp_dlog").dialog("close");
			}
		});
		//$("#xml_url").html('<a href="'+xml+'">'+xml+'</a>');
	}

	function del_chk_clenTmp(id, obj, flg) {				//添付ファイル削除確認
		if (flg ==0) { var buf ="義務者宛"; } else { var buf ="クラブ宛"; }
		var dialog = '<div id="del_chk_clenTmp" title="添付ファイルの削除" style="display: none;">';
		dialog = dialog + '  <div id="del_alert"><span class="ui-icon ui-icon-alert"></span><p>'+ buf +" "+ obj +'<br />の添付ファイルを削除しますか？</p></div>';
		dialog = dialog + '</div>';
		$("#DSdlog").append(dialog);

		$("#del_chk_clenTmp").dialog({
			resizable: false,
			modal: true,
			width: 'auto',
			minHeight: 80,
			buttons: {
				'キャンセル': function() {
					$(this).dialog("close");
				},
				'削除する': function() {
					del_clenTmp(id, obj, flg);			//添付ファイル削除
					$(this).dialog("close");
				}
			},
			close: function() {
				$(this).remove();
			}
		});
	}

	function del_clenTmp(id, obj, flg) {					//添付ファイル削除
		var xml=xmlModule+'?'+"_xsid="+$("#_xsid").val() + 
				"&_fn=del_clenTmp" + 
				"&_ID="+ id + 
				"&_obj="+ obj + 
				"&_flg="+ flg + 
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: xml,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(){
				xmlRetry["del_clenTmp"]++ ;
				if(xmlRetry["del_clenTmp"]>(xmlRetryLimt-1)) {
					alert("ファイルの削除に失敗しました。\nxml failed del_clenTmp");
				} else {
					del_clenTmp(id, obj, flg);
				}
			},success: function(httpObj){
				xmlRetry["del_clenTmp"]=0;
				var xmlRcS = httpObj.getElementsByTagName("record");
				var SID		= xmlNull_chk(httpObj, "SID", "");				//SID
				if (SID=="") { location.href="./pDistrict.asp?tp=3"; return; }	//ログイン状態でなければreload
				var CHK		= xmlNull_chk(xmlRcS[0], "CHK", 0);
				get_clenTmp(id);		//添付ファイルを再読込み
			}
		});
	}

	//-------------------------------------------------------------------------------------------案内 mail Fax送信関連
	function send_com(ID,mode) {						//義務者 送信
		var mID ="", sep ="";
		//対象となる義務者の選択 inputがcheckedのもの
		$("#attendComm tbody tr").find("td:eq(2)").each(function(idx, el) {
			if ($(el).parent().find("td:eq(0) input").attr("checked")) {
				if (mID !="") { sep =","; }
				mID = mID + sep + "'"+$(el).attr("id").split("mID_")[1]+"'";
			}
		});
		if (mID=="") return;

		if (mode ==1) {
			$("#setcomMsg").text("義務者宛に送信中、しばらくお待ちください...　");
			$("#comPrv, #comSend, #clubPrv, #clubSend").attr("disabled", true);
		}

		var param = xmlModule+'?'+"_xsid="+$("#_xsid").val() + 
		"&_fn=send_com" + 
		"&_id=" + ID + 
		"&_mid=" + mID + 
		"&_dir=duty" + 
		"&_gp=" + $("#sendGP").val() + 
		"&_tCap=" + encodeURIComponent($.data($("#attendComm").get(0), "tCap")) +	//トピックスのCaption
		"&_gab=" + encodeURIComponent($.data($("#attendComm").get(0), "gabaner")) +	//ガバナー
		"&_dcs=" + encodeURIComponent($.data($("#attendComm").get(0), "dcs")) +		//地区幹事
		"&_tit=" + encodeURIComponent($("#Comment").val()) + 
		"&_comtit=" + encodeURIComponent($("#comTitle").val()) + 
		"&_lt=" + encodeURIComponent($("#laterComm").val()) + 
		"&_mode=" + mode + 
		"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: 400*600,
			error: function(tp){
				$("#setcomMsg").text("時間をおいて再度送信してください　");
				$("#comPrv, #comSend, #clubPrv, #clubSend").attr("disabled", false);
				alert("送信に失敗しました。\n時間をおいて再度送信してください。\nxml failed send_com");
			},success: function(httpObj){
				xmlRetry[send_com_n]=0;
				var SID, msg;
				var xmlRcS	= httpObj.getElementsByTagName("record");
				SID	= xmlNull_chk(xmlRcS[0], "SID", "");
				msg	= xmlNull_chk(xmlRcS[0], "msg", "");
				if (SID=="") { location.href="./pDistrict.asp?tp=3"; return; }	//ログイン状態でなければreload
				if (mode ==1) {
					if (msg =="") {
						alert("送信完了");
						$("#setcomMsg").text("義務者宛に送信完了　");
					} else {
						alert("送信エラー\n"+msg);
						$("#setcomMsg").text(msg+"　");
					}
					$("#comPrv, #comSend, #clubPrv, #clubSend").attr("disabled", false);
				} else {
					var title	= xmlNull_chk(xmlRcS[0], "title", "");
					var flg, mlT, tmp, rds;
					var dialog	='<div id="send_com_prv_dlog" style="display: none;">';
					if (xmlRcS[0].getElementsByTagName("member")[0].firstChild != null) {
						var xmlRcS2	= httpObj.getElementsByTagName("member");
						for (var i=0; i<xmlRcS2.length; i++) {
							flg =xmlNull_chk(xmlRcS2[i], "flg", "");
							mlT =xmlNull_chk(xmlRcS2[i], "mlT", "");
							tmp =xmlNull_chk(xmlRcS2[i], "tmp", "");
							rds =xmlNull_chk(xmlRcS2[i], "rds", "");
							if (flg ==0) {
								dialog = dialog + '<p>件名： '+ title +'</p>';
								dialog = dialog + '<p>送信先： '+ mlT +'</p>';
								dialog = dialog + '<p>添付ファイル： '+ tmp +'</p>';
								dialog = dialog + '<div>'+ rds +'</div>';
							} else {
								dialog = dialog + '<p>送信先： '+ mlT +'</p>';
								dialog = dialog + '<p>送信内容： '+ tmp +'</p>';
								dialog = dialog + '<div>'+ rds +'</div>';
							}
							dialog = dialog + '<hr />';
						}
					}
					dialog = dialog + '</div>';
					$("#DSdlog").append(dialog);

					var dlogObj		=$("div[aria-labelledby^='ui-dialog-title']");
					var dlogZidx	=dlogObj.css("z-index");
					dlogObj.css({ zIndex: "50" });

					$("#send_com_prv_dlog").dialog({				//ダイアログイベント追加
						resizable	: true,
						autoOpen	: true,
						modal		: false,
						width		: '500px',
						height		: $(window).height()*0.8,
						title		: "送信の確認",
						buttons: {
							'閉じる': function() {
								$(this).dialog("close");
							}
						},
						close: function() {
							dlogObj.css({ zIndex: dlogZidx });
							$(this).remove();
						}
					});
				}
			}
		});
	}

	function send_club(ID,mode) {						//クラブ 送信
		if (mode ==1) {
			$("#setclubMsg").text("クラブ宛に送信中、しばらくお待ちください...　");
			$("#comPrv, #comSend, #clubPrv, #clubSend").attr("disabled", true);
		}

		var param = xmlModule+'?'+"_xsid="+$("#_xsid").val() + 
		"&_fn=send_club" + 
		"&_id=" + ID + 
		"&_dir=club" + 
		"&_gp=" + $("#sendGP").val() + 
		"&_tCap=" + encodeURIComponent($.data($("#attendComm").get(0), "tCap")) +	//トピックスのCaption
		"&_gab=" + encodeURIComponent($.data($("#attendComm").get(0), "gabaner")) +	//ガバナー
		"&_dcs=" + encodeURIComponent($.data($("#attendComm").get(0), "dcs")) +		//地区幹事
		"&_tit=" + encodeURIComponent($("#Comment").val()) + 
		"&_comtit=" + encodeURIComponent($("#comTitle").val()) + 
		"&_lt=" + encodeURIComponent($("#laterClub").val()) + 
		"&_mode=" + mode + 
		"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: 400*600,
			error: function(tp){
				$("#setclubMsg").text("時間をおいて再度送信してください　");
				$("#comPrv, #comSend, #clubPrv, #clubSend").attr("disabled", false);
				alert("送信に失敗しました。\n時間をおいて再度送信してください。\nxml failed send_club");
			},success: function(httpObj){
				xmlRetry[send_club_n]=0;
				var SID, msg;
				var xmlRcS	= httpObj.getElementsByTagName("record");
				SID	= xmlNull_chk(xmlRcS[0], "SID", "");
				msg	= xmlNull_chk(xmlRcS[0], "msg", "");
				if (SID=="") { location.href="./pDistrict.asp?tp=3"; return; }	//ログイン状態でなければreload
				if (mode ==1) {
					if (msg =="") {
						alert("送信完了");
						$("#setclubMsg").text("クラブ宛に送信完了　");
					} else {
						alert("送信エラー\n"+msg);
						$("#setclubMsg").text(msg+"　");
					}
					$("#comPrv, #comSend, #clubPrv, #clubSend").attr("disabled", false);
				} else {
					var title	= xmlNull_chk(xmlRcS[0], "title", "");
					var flg, mlT, tmp, rds;
					var dialog	='<div id="send_com_prv_dlog" style="display: none;">';
					if (xmlRcS[0].getElementsByTagName("member")[0].firstChild != null) {
						var xmlRcS2	= httpObj.getElementsByTagName("member");
						for (var i=0; i<xmlRcS2.length; i++) {
							flg =xmlNull_chk(xmlRcS2[i], "flg", "");
							mlT =xmlNull_chk(xmlRcS2[i], "mlT", "");
							tmp =xmlNull_chk(xmlRcS2[i], "tmp", "");
							rds =xmlNull_chk(xmlRcS2[i], "rds", "");
							if (flg ==0) {
								dialog = dialog + '<p>件名： '+ title +'</p>';
								dialog = dialog + '<p>送信先： '+ mlT +'</p>';
								dialog = dialog + '<p>添付ファイル： '+ tmp +'</p>';
								dialog = dialog + '<div>'+ rds +'</div>';
							} else {
								dialog = dialog + '<p>送信先： '+ mlT +'</p>';
								dialog = dialog + '<p>送信内容： '+ tmp +'</p>';
								dialog = dialog + '<div>'+ rds +'</div>';
							}
							dialog = dialog + '<hr />';
						}
					}
					dialog = dialog + '</div>';
					$("#DSdlog").append(dialog);

					var dlogObj		=$("div[aria-labelledby^='ui-dialog-title']");
					var dlogZidx	=dlogObj.css("z-index");
					dlogObj.css({ zIndex: "50" });

					$("#send_com_prv_dlog").dialog({				//ダイアログイベント追加
						resizable	: true,
						autoOpen	: true,
						modal		: false,
						width		: '500px',
						height		: $(window).height()*0.8,
						title		: "送信の確認",
						buttons: {
							'閉じる': function() {
								$(this).dialog("close");
							}
						},
						close: function() {
							dlogObj.css({ zIndex: dlogZidx });
							$(this).remove();
						}
					});
				}
			}
		});
	}


	//-------------------------------------------------------------------------------------------出欠未確認 mail Fax送信関連
	function send_unconf(ID,mode,club_uncon_exef) {						//未確認者送信
		if (mode ==1) { $("#addRep").text("未確認者に送信中、しばらくおまちください..."); }
		var param = xmlModule+'?'+"_xsid="+$("#_xsid").val() + 
		"&_fn=send_unconf" + 
		"&_id=" + ID + 
		"&_mode=" + mode + 
		"&_cue_mode=" + club_uncon_exef + 
		"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: 400*600,
			error: function(){
				$("#addRep").text("時間をおいて再度に送信してください");
				alert("送信に失敗しました。\n時間をおいて再度に送信してください。\nxml failed send_unconf");
			},success: function(httpObj){
				xmlRetry["send_unconf"]=0;
				var SID, msg;
				var xmlRcS	= httpObj.getElementsByTagName("record");
				SID	= xmlNull_chk(xmlRcS[0], "SID", "");
				msg	= xmlNull_chk(xmlRcS[0], "msg", "");
				if (SID=="") { location.href="./pDistrict.asp?tp=3"; return; }	//ログイン状態でなければreload
				if (mode ==1) {
					if (msg =="") {
						alert("送信完了");
						$("#addRep").text("未確認者宛に送信完了");
					} else {
						alert("送信エラー\n"+msg);
						$("#addRep").text(msg);
					}
				} else {
					var title	= xmlNull_chk(xmlRcS[0], "title", "");
					var flg, mlT, tmp, rds;
					var dialog	='<div id="send_com_prv_dlog" style="display: none;">';
					if (xmlRcS[0].getElementsByTagName("member")[0].firstChild != null) {
						var xmlRcS2	= httpObj.getElementsByTagName("member");
						for (var i=0; i<xmlRcS2.length; i++) {
							flg =xmlNull_chk(xmlRcS2[i], "flg", "");
							mlT =xmlNull_chk(xmlRcS2[i], "mlT", "");
							tmp =xmlNull_chk(xmlRcS2[i], "tmp", "");
							rds =xmlNull_chk(xmlRcS2[i], "rds", "");
							if (flg ==0) {
								dialog = dialog + '<p>件名： '+ title +'</p>';
								dialog = dialog + '<p>送信先： '+ mlT +'</p>';
								dialog = dialog + '<p>添付ファイル： '+ tmp +'</p>';
								dialog = dialog + '<div>'+ rds +'</div>';
							} else {
								dialog = dialog + '<p>送信先： '+ mlT +'</p>';
								dialog = dialog + '<p>送信内容： '+ tmp +'</p>';
								dialog = dialog + '<div>'+ rds +'</div>';
							}
							dialog = dialog + '<hr />';
						}
					} else {
						$("#addRep").text("すべての出欠確認は行われています");
						return;
					}
					dialog = dialog + '</div>';
					$("#DSdlog").append(dialog);

					var dlogObj		=$("div[aria-labelledby^='ui-dialog-title']");
					var dlogZidx	=dlogObj.css("z-index");
					dlogObj.css({ zIndex: "50" });

					$("#send_com_prv_dlog").dialog({				//ダイアログイベント追加
						resizable	: true,
						autoOpen	: true,
						modal		: false,
						width		: '500px',
						height		: $(window).height()*0.8,
						title		: "送信の確認",
						buttons: {
							'閉じる': function() {
								$(this).dialog("close");
							},
							'送信する': function() {
								send_unconf(ID,1,club_uncon_exef);
								$(this).dialog("close");
							}
						},
						close: function() {
							dlogObj.css({ zIndex: dlogZidx });
							$(this).remove();
						}
					});
				}
			}
		});
	}


	//-------------------------------------------------------------------------------------------クラブ出席者登録関連
	function get_attendClub(id) {											//カレンダー クラブ出席者を取得
		var param = xmlModule+'?'+"_xsid="+$("#_xsid").val() + 
				"&_fn=get_attendClub" + 
				"&_id=" + id + 
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(tp){
				xmlRetry[get_attendClub_n]++ ;
				if(xmlRetry[get_attendClub_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed get_attendClub");
				else {
					get_attendClub();
				}
			},success: function(httpObj){
				xmlRetry[get_attendClub_n]=0;
				var rcID, cName, mID, name, pos, cnt;
				var orcID =0;
				var tr ="", id;
				var xmlRcS	= httpObj.getElementsByTagName("record");
				for (var i=0; i<xmlRcS.length; i++) {
					rcID	= xmlNull_chk(xmlRcS[i], "rcID", "");
					cName	= xmlNull_chk(xmlRcS[i], "cName", "");
					mID		= xmlNull_chk(xmlRcS[i], "mID", "");
					name	= xmlNull_chk(xmlRcS[i], "name", "　");
					pos		= xmlNull_chk(xmlRcS[i], "pos", "");
					cnt		= xmlNull_chk(xmlRcS[i], "cnt", 1);
					id		= "";
					if (mID !="") id =' id="mID_'+ mID +'"';
					if (rcID !=orcID) {
						tr	= tr + '<tr class="'+ rcID +'"><td class="cNm" rowspan="'+ cnt +'">'+ cName +'</td><td'+ id +'>'+ name +'</td><td class="comm">'+ pos +'</td></tr>';
					} else {
						tr	= tr + '<tr class="'+ rcID +'"><td'+ id +'>'+ name +'</td><td class="comm">'+ pos +'</td></tr>';
					}
					orcID =rcID;
				}
				$("#attendClub tbody").html(tr);
				if (i>0) $("#attendClub").trigger("update").trigger("sorton",[[]]);

				evt_commEvt()															//役職入力選択 イベント追加

				evt_memClick($("#attendClub tbody tr"));
				evt_memDel();
				$("#attendClub tbody tr td.cNm").click(function () {					//クラブ名を選択時
					$.data($("#commData").get(0), "CM_calen", $(this));
					open_clubM($(this).text(),$(this).parent().attr("class"),$(this));	//クラブメンバー一覧を表示
				});
			}
		});
	}


	function open_clubM(rcNm,rcID,row) {											//カレンダー クラブメンバー一覧を表示
		var bgColor ="#ffe8e8";
		if (!$("#chk_clubM_dialog").length) {													//開かれていない場合
			var dialog = '<div id="chk_clubM_dialog" style="display: none;">';
			dialog = dialog + '	<div style="overflow: auto;">';
			dialog = dialog + '	<table border="0" cellspacing="1" cellpadding="0" class="tablesorter" id="clubM">';
			dialog = dialog + '		<thead>';
			dialog = dialog + '			<tr class="Freezing">';
			dialog = dialog + '				<th>A</th><th>氏名</th>';
			dialog = dialog + '			</tr>';
			dialog = dialog + '		</thead>';
			dialog = dialog + '		<tbody>';
			dialog = dialog + '		</tbody>';
			dialog = dialog + '	</table>';
			dialog = dialog + '	<div id="loader"></div>';
			dialog = dialog + '</div>';
			dialog = dialog + '</div>';
			$("#dmCont").append(dialog);
			$("#loader").css({ height: "100px", background: "url(/images/ajax-loader_l.gif) no-repeat center" });
			row.css("backgroundColor",bgColor);							//選択したクラブの背景色を変更
			$.data($("#attendClub").get(0), "rowObj", row);
			get_clubM(rcID,rcNm,$("#chk_clubM_dialog"),row);			//クラブメンバー一覧を取得

			//選択したクラブに空欄が無い場合は追加
			rCnt=row.attr("rowspan");
			idx	=$("#attendClub tbody tr").index(row.parent());
			if (row.next().text() !="　") {
				row.attr("rowspan",rCnt+1);
				$("#attendClub tbody tr:eq("+ (idx+rCnt-1) +")").after('<tr class="'+ rcID +'"><td>　</td><td class="comm"></td></tr>');
			}
		} else {																				//すでに開かれている場合
			var rowObj=$.data($("#attendClub").get(0), "rowObj");
			if (rowObj !=null) {
				if (rowObj.parent().attr("class") !=row.parent().attr("class")) {
					rowObj.css("backgroundColor","#fff");				//選択したクラブの背景色を戻す
					row.css("backgroundColor",bgColor);					//選択したクラブの背景色を変更
					$("#clubM tbody").empty();
					$("#loader").css({ height: "100px", background: "url(/images/ajax-loader_l.gif) no-repeat center" });
					//空欄を削除
					var rCnt=rowObj.attr("rowspan");
					var idx	=$("#attendClub tbody tr").index(rowObj.parent());
					if ($("#attendClub tbody tr:eq("+ (idx+rCnt-1) +") td:eq(0)").text() =="　") {
						rowObj.attr("rowspan",rCnt-1);
						$("#attendClub tbody tr:eq("+ (idx+rCnt-1) +")").remove();
					}
					//選択したクラブに空欄が無い場合は追加
					rCnt=row.attr("rowspan");
					idx	=$("#attendClub tbody tr").index(row.parent());
					if (row.next().text() !="　") {
						row.attr("rowspan",rCnt+1);
						$("#attendClub tbody tr:eq("+ (idx+rCnt-1) +")").after('<tr class="'+ rcID +'"><td>　</td><td class="comm"></td></tr>');
					}
					$("#chk_clubM_dialog").dialog("option", "title", rcNm+"RC 出席者を選択");	//ダイアログのtitle変更
					$.data($("#attendClub").get(0), "rowObj", row);
					get_clubM(rcID,rcNm,$("#chk_clubM_dialog"),row);							//クラブメンバー一覧を取得
				}
			}
		}
	}

	function get_clubM(rcID,rcNm,dObj,row) {										//カレンダー クラブメンバー一覧を取得
		var param = xmlModule+'?'+"_xsid="+$("#_xsid").val() + 
				"&_fn=get_clubM" + 
				"&_rcID=" + rcID + 
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(tp){
				xmlRetry[get_clubM_n]++ ;
				if(xmlRetry[get_clubM_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed get_clubM");
				else {
					get_clubM(rcID);
				}
			},success: function(httpObj){
				xmlRetry[get_clubM_n]=0;
				var mID, name, aName, cp, cs, ico, comm;
				var tr ="";
				var xmlRcS	= httpObj.getElementsByTagName("record");
				for (var i=0; i<xmlRcS.length; i++) {
					mID		= xmlNull_chk(xmlRcS[i], "mID", "");
					name	= xmlNull_chk(xmlRcS[i], "name", "");
					aName	= xmlNull_chk(xmlRcS[i], "aName", "");
					cp		= xmlNull_chk(xmlRcS[i], "cp", "");
					cs		= xmlNull_chk(xmlRcS[i], "cs", "");
					ico		= xmlNull_chk(xmlRcS[i], "ico", "");
					comm	= "";
					if (cp !="") comm ="cp";
					if (cs !="") comm ="cs";
					if (ico !="") comm ="ico";
					tr		= tr + '<tr id="mID_'+ mID +'"><td>'+ aName +'</td><td><span id="'+ comm +'">'+ name +'</span></td></tr>';
				}
				$("#clubM tbody").html(tr);
				$("#loader").css({ height: "0", background: "none" });
				if (i>0) $("#clubM").tablesorter();		//tablesorter

				if (!$("#chk_clubM_dialog").dialog("isOpen")) {
					//dialog表示
					var ht		=$("#DSdlog").parent().height();
					var wt		=$("#DSdlog").parent().width();
					var offset	=$("#DSdlog").parent().offset();
					dObj.dialog({
						resizable: true,
						modal: false,
						title: rcNm+"RC 出席者を選択",
						width: 'auto',
						height: ht,
						minHeight: 80,
						position: [(offset.left+wt+5-$(window).scrollLeft()),(offset.top-$(window).scrollTop())],
						open: function() {
						},
						buttons: {
							'閉じる': function() {
								$(this).dialog("close");
							}
						},
						close: function() {
							var rowObj=$.data($("#attendClub").get(0), "rowObj");
							if (rowObj !=null) {
								var rCnt=rowObj.attr("rowspan");
								var idx	=$("#attendClub tbody tr").index(rowObj.parent());
								rowObj.css("backgroundColor","#fff");
								if ($("#attendClub tbody tr:eq("+ (idx+rCnt-1) +") td:eq(0)").text() =="　") {
									rowObj.attr("rowspan",rCnt-1);			//rowspan-1
									$("#attendClub tbody tr:eq("+ (idx+rCnt-1) +")").remove();
								}
							}
							$(this).remove();
						}
					});
				}

				//会員情報を修正
				$("#clubM tr td:has(span)").dblclick(function () {
					$.data($("#commData").get(0), "memEdit", "CM_calen");
					open_memEdit($(this).parent());
				});
				//draggable イベント追加
				$("#clubM tr td:has(span)").draggable({
					containment: '#attendClub',
					helper: "clone",
					start: function(evt, ui) {
						dObj.parent().css("overflow","visible");
						$("#attendClub tbody tr").droppable("enable");
					},
					stop: function(evt, ui) { dObj.parent().css("overflow","hidden"); }
				});
				//droppable イベント削除
				$("#attendClub tbody tr td").droppable("destroy");
				//droppable イベント追加
				var idx	=$("#attendClub tbody tr").index(row.parent());
				var rs	=row.attr("rowspan");
				var cnt =0;
				var eqn =1;
				var trObj, mID;
				while(rs >0) {
					if (cnt >0) eqn =0;
					trObj	=$("#attendClub tbody tr:eq("+ idx +") td:eq("+ eqn +")");
					mID		=trObj.attr("id");								//出席者として登録されているメンバーのID
					evt_memDrop(trObj,rcID,rcNm,row);
					if (mID !="") $("#clubM tbody tr#"+mID).hide();			//クラブメンバー一覧からhide
					cnt++;
					idx++;
					rs--;
				}
			}
		});
	}

	function evt_commEvt() {														//カレンダー 役職入力選択 イベント追加
		$("#attendClub tbody tr").find("td.comm").click(function (e) {
			if ($.data($("#DSdlog").get(0), "combo") ==1) { $.data($("#DSdlog").get(0), "combo", 0); return; }
			var commTxt =new Array();
			var i =0, sc =false;
			e.stopPropagation();
			//入力済みの役職を取得
			$("#attendClub tbody tr td.comm").each(function(idx, el) {
				if ($(el).text() !="") {
					for (j=0;j<i;j++) {
						if (commTxt[j] ==$(el).text()) { sc =true; }
					}
					if (sc ==false) { commTxt[i] =$(el).text(); i++; }
					sc =false;
				}
			});

			if ($(e.target).attr("tagName").toLowerCase() =="td") {
				//Combobox作成
				var txt		=$(this).text();
				var wd		=$(this).width();
				var combo	='<select class="combo" id="commInp" style="width: '+ wd +'px;">';
				combo =combo + '  <option value="'+ txt +'">'+ txt +'</option>';
				if (txt !="") combo =combo + '  <option value=""></option>';
				for (j=0;j<i;j++) {
					combo =combo + '  <option value="'+ commTxt[j] +'">'+ commTxt[j] +'</option>';
				}
				combo =combo + '</select>';
				$(this).width(wd);
				$(this).html(combo);
				$("#commInp").vCombobox();
				//cursor_moveToEnd("commInp");			//カーソルを末尾に移動

				//Combobox以外にmousedownされたら更新する
				$("#attendClub tbody:not(#commInp, #commInp option)").mousedown(function (e) {
					var tObj =$("#commInp");
					if ($(e.target).attr("id") !="commInp") {
						if ($(e.target).parent().attr("id") !="commInp") {
							tObj.parent().text(tObj.val());
							tObj.remove();
							$("#attendClub tbody:not(#commInp, #commInp option)").unbind("mousedown");
							if ($(e.target).attr("class") =="comm") $.data($("#DSdlog").get(0), "combo", 1);
						}
					}
				});
			}
		});
	}

	function evt_memDrop(tgt,rcID,rcNm,row) {										//カレンダー droppable イベント追加
		tgt.droppable({																	//クラブ出席者登録 droppable イベント
			accept: "#clubM tr td",
			greedy: true,
			drop: function(e, ui) {
				var Name	= ui.draggable.text();										//会員名を取得
				var comm	= ui.draggable.find("span").attr("id");						//会員の役職を取得
				var mID		= ui.draggable.parent().attr("id");							//idを取得
				var rCnt	= row.attr("rowspan");
				var eqn		= 1;														//eqn=0: rowspanなし, eqn=1: rowspanあり
				$("#clubM tbody tr#"+mID).hide();										//dropしたメンバーをhide
				if ($(this).prev().attr("nodeName") ==undefined) eqn =0;
				var td	= $(this).parent().find("td:eq("+ eqn +")");
				if (td.attr("id")) {
					$("#clubM tbody tr#"+td.attr("id")).show();							//dropされたメンバーをshow
				} else {
					var parentTr =$(this).parent();
					row.attr("rowspan",rCnt+1);											//rowspan+1
					parentTr.after('<tr class="'+ rcID +'"><td>　</td><td class="comm"></td></tr>');
					evt_memDrop($(this).parent().next().find("td:eq(0)"),rcID,rcNm,row);
					$("#attendClub tbody tr td.comm").unbind("click");
					evt_commEvt();
					parentTr.unbind("click");
					evt_memClick(parentTr);
				}
				td.text(Name).attr("id",mID);
				if (comm =="cp") comm ="会長";
				if (comm =="cs") comm ="幹事";
				if (comm =="ico") comm ="クラブ管理担当者";
				td.next().text(comm);
			}
		});
	}

	function evt_memClick(tgt) {										//カレンダー クラブ出席者登録 click イベント追加
		tgt.click(function (e) {
			if ($(e.target).prev().attr("class") =="cNm" || ($(e.target).attr("class") !="cNm" && $(e.target).prev().attr("class") ==undefined)) {	//氏名をclick
				var selObj =$("#attendClub").get(0);
				if ($(e.target).attr("class").indexOf("selBackColor") >-1) {		//clickした場所はすでに選択されている
					$(e.target).removeClass("selBackColor");		//背景色を戻す
					$.data(selObj, "selObj", null);					//選択Objをnull
				} else {
					if ($.data(selObj, "selObj") !=null) $.data(selObj, "selObj").removeClass("selBackColor");
					$(e.target).addClass("selBackColor");			//背景色を変更
					$.data(selObj, "selObj", $(e.target));			//選択Objを保持
				}
			}
		});
	}

	function evt_memDel() {													//カレンダー クラブ出席者登録 削除イベント追加
		$(document).keyup(function (e) {
			var selObj =$("#attendClub").get(0);
			if (e.which ==46 && $.data(selObj, "selObj") !=null) {					//delキーが押されかつ選択Objが保持されている
				var tbl	=$("#attendClub");
				var idx	=tbl.find("tr").index($.data(selObj, "selObj").parent());	//選択した行のindexを取得
				var oIdx=idx;
				while(idx >=0) {
					if (tbl.find("tr:eq("+ idx +") td:eq(0)").attr("class").indexOf("cNm") >-1) break;
					idx--;
				}
				var clubTr	=tbl.find("tr:eq("+ idx +") td:eq(0)");				//クラブ名の行を取得
				if (oIdx !=idx) {												//クラブ名の行以外
					clubTr.attr("rowspan",(clubTr.attr("rowspan")-1));			//rowspanを-1
					$.data(selObj, "selObj").parent().remove();					//選択した行を削除
					$("#clubM tbody tr#"+$.data(selObj, "selObj").attr("id")).show();						//削除したメンバーを一覧にshow
				} else {														//クラブ名の行
					if (clubTr.attr("rowspan") ==1) {							//クラブは1行のみ
						//var posCls	= get_class($.data(selObj, "selObj").prev(), "pos_");					//posのclass名を取得
						$.data(selObj, "selObj").removeAttr("id").removeClass("selBackColor").text("　");	//mID,選択背景色,名前を削除
						//$.data(selObj, "selObj").next().removeClass(posCls).empty();						//役職を削除
					} else {													//クラブは複数行
						var row		=clubTr.attr("rowspan");
						var memID	=tbl.find("tr:eq("+ idx +") td:eq(1)").attr("id");
						var eq0		=tbl.find("tr:eq("+ (idx+1) +") td:eq(0)");
						var eq1		=tbl.find("tr:eq("+ (idx+1) +") td:eq(1)");

						clubTr.attr("rowspan",(row-1));							//rowspanを-1
						tbl.find("tr:eq("+ idx +") td:eq(1)").empty().removeClass("selBackColor").prepend(eq0.text()).attr("id",eq0.attr("id"));
						tbl.find("tr:eq("+ idx +") td:eq(2)").empty().removeClass("selBackColor").prepend(eq1.text()).attr("id",eq1.attr("id"));
						tbl.find("tr:eq("+ (idx+1) +")").remove();
						$("#clubM tbody tr#"+memID).show();											//削除したメンバーを一覧にshow
					}
				}
				$.data(selObj, "selObj", null);														//選択Objをnull
			}
		});
	}

	function get_DS(id) {													//カレンダー 情報を取得
		var param = xmlModule+'?'+"_xsid="+$("#_xsid").val() + 
				"&_fn=get_ds" + 
				"&_id=" + id +
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(){
				xmlRetry[get_ds_n]++ ;
				if(xmlRetry[get_ds_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed get_ds");
				else {
					alert("情報の取得に失敗しました"+get_ds_n);
					get_DS(id);
				}
			},success: function(httpObj){
				xmlRetry[get_ds_n]=0;
				var xmlRcS	= httpObj.getElementsByTagName("record");
				var SID		= xmlNull_chk(xmlRcS[0], "SID", "");
				if (SID=="") { location.href="./pDistrict.asp?tp=3"; return; }		//ログイン状態でなければreload
				if (id >0) {
					var DateRel	= xmlNull_chk(xmlRcS[0], "DateRel", "");
					var DatePrior= xmlNull_chk(xmlRcS[0], "DatePrior", "");
					var RH		= xmlNull_chk(xmlRcS[0], "RH", 12);
					var RM		= xmlNull_chk(xmlRcS[0], "RM", 0);
					var PH		= xmlNull_chk(xmlRcS[0], "PH", 12);
					var PM		= xmlNull_chk(xmlRcS[0], "PM", 0);
					var Comment	= xmlNull_chk(xmlRcS[0], "Comment", "");
					var pc		= xmlNull_chk(xmlRcS[0], "pc", "");
					$("#DateRel").val(DateRel);
					$("#DatePri").val(DatePrior);
					if (RM !="" || PM !="") {
						$(".time").css("visibility", "visible");
						$("#timeSel").attr("checked",false);
						$("#relH").val(RH);
						if (RM <10) RM="0"+RM;
						$("#relM").val(RM);
						$("#priH").val(PH);
						if (PM <10) PM="0"+PM;
						$("#priM").val(PM);
					} else {
						$("#relH, #priH").val("12");
						$("#relM, #priM").val("00");
					}
					$("#Comment").val(Comment);
					$("#planChange").val(pc);
					get_clenTmp(id);	//添付ファイルの取得
				}
			}
		});
	}

	function get_clenTmp(id) {																	//カレンダー 添付ファイルの取得
		var param = xmlModule+'?'+"_xsid="+$("#_xsid").val() + 
				"&_fn=get_clenTmp" + 
				"&_id=" + id +
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(){
				xmlRetry["get_clenTmp"]++ ;
				if(xmlRetry["get_clenTmp"]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed get_clenTmp");
				else {
					get_clenTmp(id);
				}
			},success: function(httpObj){
				xmlRetry["get_clenTmp"]=0;
				var xmlRcS	= httpObj.getElementsByTagName("record");
				var SID		= xmlNull_chk(xmlRcS[0], "SID", "");
				if (SID=="") { location.href="./pDistrict.asp?tp=3"; return; }		//ログイン状態でなければreload
				if (id >0) {
					var duty	= xmlNull_chk(xmlRcS[0], "duty", "");
					var club	= xmlNull_chk(xmlRcS[0], "club", "");
					var dCnt	= xmlNull_chk(xmlRcS[0], "dCnt", 0);
					var cCnt	= xmlNull_chk(xmlRcS[0], "cCnt", 0);
					var path	= "ImgDat/District/information/";
					var xmlRcS2;
					$.data($("#DSdlog").get(0), "dCnt", parseInt(dCnt));	//義務者 添付ファイルmaxカウント保持
					$.data($("#DSdlog").get(0), "cCnt", parseInt(cCnt));	//クラブ 添付ファイルmaxカウント保持
					if (duty !="") {										//義務者 添付ファイル
						xmlRcS2 =xmlRcS[0].getElementsByTagName("duty")[0].getElementsByTagName("file");
						$("#dTmp").html(format_tmp(id, xmlRcS2, path + id +"/duty/", 0));			//整形済み添付ファイルの表示
					}
					if (club !="") {										//クラブ 添付ファイル
						xmlRcS2 =xmlRcS[0].getElementsByTagName("club")[0].getElementsByTagName("file");
						$("#cTmp").html(format_tmp(id, xmlRcS2, path+ id +"/club/", 1));
					}
				}
			}
		});
	}

	function format_tmp(id, xmlRcS, path, flg) {												//添付ファイルの整形
		var obj, tmp ="";
		for (var i=0; i<xmlRcS.length; i++) {
			obj	=xmlNull_chk(xmlRcS[i], "obj", "");
			if (obj.split(".")[1] =="pdf") {
				tmp =tmp + '<span class="ui-icon ui-icon-closethick inlineIco" title="添付ファイルの削除" onclick="del_chk_clenTmp('+ id +',\''+ obj +'\','+ flg +');"></span><a href="javascript:void(0);" onclick="wrkWin=Openwin(\'/ImagePDF.asp?ImgPath=' + path + obj +'\',\'viewPDF\',\'width=800,height=900,resizable=yes\');wrkWin.focus();" title="ファイルの確認">'+ obj +'</a>　';
			} else {
				tmp =tmp + '<span class="ui-icon ui-icon-closethick inlineIco" title="添付ファイルの削除" onclick="del_chk_clenTmp('+ id +',\''+ obj +'\','+ flg +');"></span><a href="javascript:void(0);" onclick="wrkWin=Openwin(\'/' + path + obj +'\',\'viewPDF\',\'width=800,height=900,resizable=yes\');wrkWin.focus();" title="ファイルの確認">'+ obj +'</a>　';
			}
		}
		return tmp;
	}


	function open_DT(id) {													//カレンダー詳細表示
		var DTA =$("#DT_Area");
		if (DTA.length) {
			DTA.find("div").slideUp(function() {				//詳細が表示されていたら閉じる
				if (id !=DTA.prev().attr("id").split("DC_")[1]) get_Details(id);
				var row	=$.data($("#DCTbl").get(0), "row");		//rowspanのあるtrを取得
				row.attr("rowspan",(row.attr("rowspan")-1));	//rowspanを-1
				DTA.remove();
			});
		} else {
			get_Details(id,0);
		}
	}

	function get_Details(id,mode) {											//カレンダー詳細を取得
		var param = xmlModule+'?'+"_xsid="+$("#_xsid").val() + 
				"&_fn=get_dt" + 
				"&_id=" + id +
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(){
				xmlRetry[get_dt_n]++ ;
				if(xmlRetry[get_dt_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed get_dt");
				else {
					get_Details(id);
				}
			},success: function(httpObj){
				xmlRetry[get_dt_n]=0;
				var xmlRcS	= httpObj.getElementsByTagName("record");
				var Comment	= xmlNull_chk(xmlRcS[0], "Comment", "");
				var Caption	= xmlNull_chk(xmlRcS[0], "Caption", "");
				if (mode==0) {
					if (Comment !="") {
						var tbl	=$("#DCTbl");
						var tr	=tbl.find("> tbody");
						var idx	=tr.find("> tr").index($("#DC_"+id));		//clickしたtrのidx
						var row;
						while(idx >=0) {									//rowspanのあるtrを取得
							row =tr.find("> tr:eq("+ idx +") td:eq(1)");
							if (row.attr("class").indexOf("theme") >-1) break;
							idx--;
						}
						row.attr("rowspan",(row.attr("rowspan")+1));		//rowspanを+1
						$.data(tbl.get(0), "row", row);						//rowspanのあるtrを保持
						//詳細を表示
						var newTR	= '<tr id="DT_Area"><td></td><td class="Lst_TDR" colspan="2"><div>'+ Comment.split('\n').join('<br />') +'</div></td></tr>';
						$("#DC_"+id).after(newTR).next().find("div").slideDown();
					}
				} else {
					$("#laterComm, #laterClub").val(Comment);						//出席義務者のメール送信本文
					if (id !=0) $.data($("#attendComm").get(0), "tCap", Caption);	//トピックスのCaptionを保持
				}
			}
		});
	}

	function get_AttedList_comm(id) {										//出席義務者を取得
		var param = xmlModule+'?'+"_xsid="+$("#_xsid").val() + 
				"&_fn=get_AttedList" + 
				"&_id=" + id +
				"&_flg=0" +
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(){
				xmlRetry[get_AttedList_comm_n]++ ;
				if(xmlRetry[get_AttedList_comm_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed get_AttedList_comm");
				else {
					get_AttedList_comm(id);
				}
			},success: function(httpObj){
				xmlRetry[get_AttedList_comm_n]=0;
				var xmlRcS	= httpObj.getElementsByTagName("record");
				var mID, club, name, comID, com, pos, newTR="";
				for (var i=0;i<xmlRcS.length;i++) {
					mID		= xmlNull_chk(xmlRcS[i], "mID", "");
					club	= xmlNull_chk(xmlRcS[i], "club", "");
					name	= xmlNull_chk(xmlRcS[i], "name", "");
					comID	= xmlNull_chk(xmlRcS[i], "comID", "");
					com		= xmlNull_chk(xmlRcS[i], "com", "");
					pos		= xmlNull_chk(xmlRcS[i], "pos", "");
					newTR	= newTR + '<tr id="'+ comID +'"><td><input type="checkbox" value="" checked="checked" />'+ com +'</td><td>'+ pos +'</td><td id="mID_'+ mID +'">'+ name +'</td><td>'+ club +'</td></tr>';
				}
				$("#attendComm tbody").html(newTR);
				if (i>0) $("#attendComm").trigger("update").trigger("sorton",[[]]);
				evt_comSelect_calen($("#attendComm tbody tr").find("td:eq(2)"));		//氏名を選択
				$(document).unbind('keyup');
				evt_comDel_calen();														//選択trの削除
				if (i ==0) {
					$("#comPrv, #comSend").attr("disabled",true).attr("title","義務者の登録を行ってください");
				} else {
					$("#comPrv, #comSend").attr("disabled",false).attr("title","");
				}
			}
		});
	}

	function get_AttedList(id) {											//出席者を取得
		var param = xmlModule+'?'+"_xsid="+$("#_xsid").val() + 
				"&_fn=get_AttedList" + 
				"&_id=" + id +
				"&_flg=-1" +
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(){
				xmlRetry[get_AttedList_n]++ ;
				if(xmlRetry[get_AttedList_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed get_AttedList");
				else {
					get_AttedList(id);
				}
			},success: function(httpObj){
				xmlRetry[get_AttedList_n]=0;
				var xmlRcS	= httpObj.getElementsByTagName("record");
				var aID, club, name, attend, comID, com, pos, flg, cnt, cls, oClub="", comTR="", clubTR="";
				var at =["欠","出",""];
				for (var i=0;i<xmlRcS.length;i++) {
					aID		= xmlNull_chk(xmlRcS[i], "ID", "");
					club	= xmlNull_chk(xmlRcS[i], "club", "");
					name	= xmlNull_chk(xmlRcS[i], "name", "");
					attend	= xmlNull_chk(xmlRcS[i], "attend", "2");
					comID	= xmlNull_chk(xmlRcS[i], "comID", "");
					com		= xmlNull_chk(xmlRcS[i], "com", "");
					pos		= xmlNull_chk(xmlRcS[i], "pos", "");
					flg		= xmlNull_chk(xmlRcS[i], "flg", "");
					cnt		= xmlNull_chk(xmlRcS[i], "cnt", 0);
					cls		= "";
					if (attend !=1) cls=' class="atBg"';
					if (flg ==0) comTR	= comTR + '<tr id="'+ aID +'"'+cls+'><td>'+ com +'</td><td>'+ pos +'</td><td>'+ club +'</td><td>'+ name +'</td><td class="at at_'+attend+'">'+ at[attend] +'</td></tr>';
					if (flg ==1) {
						clubTR	= clubTR + '<tr id="'+ aID +'"'+cls+'><td>'+ pos +'</td>';
						//if (oClub !=club) clubTR = clubTR + '<td rowspan="'+ cnt +'">'+ club +'</td>';
						clubTR = clubTR + '<td>'+ club +'</td>';
						clubTR	= clubTR + '<td>'+ name +'</td><td class="at">'+ at[attend] +'</td></tr>';
						//oClub =club;
					}
				}
				$("#attendChk_com tbody").html(comTR);
				$("#attendChk_club tbody").html(clubTR);
				if (comTR !="") $("#attendChk_com").trigger("update").trigger("sorton",[[]]);
				if (clubTR !="") $("#attendChk_club").trigger("update").trigger("sorton",[[]]);

				$("#attendChk_com tbody tr td.at, #attendChk_club tbody tr td.at").click(function () {		//出欠を選択時
					evt_atToggle($(this));
				});
			}
		});
	}

	function evt_atToggle(Obj) {													//カレンダー 出欠確認 出欠toggle
		switch (Obj.text()) {
			case "欠":	Obj.text("出");	Obj.removeClass("at_0").addClass("at_1").parent().removeClass("atBg").addClass("atChg");	break;
			case "出":	Obj.text("");	Obj.removeClass("at_1").addClass("at_2").parent().addClass("atBg").addClass("atChg");		break;
			default:	Obj.text("欠");	Obj.removeClass("at_2").addClass("at_0").parent().addClass("atChg");
		}
	}

	function reg_atChg(id) {														//カレンダー 出欠確認 出欠の変更
		var aID ="";
		$("#attendChk_com tbody tr[class*='atChg'], #attendChk_club tbody tr[class*='atChg']").each(function(idx, elment) {	//出欠の変更されたもののみを抽出
			aID = aID + $(elment).attr("id")+"/"+get_class($(elment).find("td.at"), "at_").split("at_")[1]+",";
		});
		if (aID =="") return;
		var param = xmlModule+'?'+"_xsid="+$("#_xsid").val() + 
				"&_fn=reg_atChg" + 
				"&_id=" + id +
				"&_aID=" + aID +
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(){
				xmlRetry[reg_atChg_n]++ ;
				if(xmlRetry[reg_atChg_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed reg_atChg");
				else {
					reg_atChg(id);
				}
			},success: function(httpObj){
				xmlRetry[reg_atChg_n]=0;
				var xmlRcS	= httpObj.getElementsByTagName("record");
				var SID		= xmlNull_chk(xmlRcS[0], "msg", -1);
				if (SID==-1) { location.href="./pDistrict.asp?tp=3"; return; }	//ログイン状態でなければreload
				$("#addRep").text("出欠の変更をしました");
			}
		});
	}


	//-------------------------------------------------------------------------------------------カレンダー 義務者 出欠確認
	function chk_comMem(id) {
		var param = xmlModule+'?'+"_xsid="+$("#_xsid").val() + 
				"&_fn=chk_com_Club_Mem" + 
				"&_id=" + id +
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(){
				xmlRetry[chk_comMem_n]++ ;
				if(xmlRetry[chk_comMem_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed chk_comMem");
				else {
					chk_comMem(id);
				}
			},success: function(httpObj){
				xmlRetry[chk_comMem_n]=0;
				var xmlRcS	= httpObj.getElementsByTagName("record");
				var cnt		= xmlNull_chk(xmlRcS[0], "cnt", 0);
				if (cnt ==0) {
					reg_comMem(id);		//カレンダー 義務者 登録
				} else {
					var dialog = '<div id="chk_del_dialog" title="登録済み出欠の確認" style="display: none;">';
					dialog = dialog + '  <div id="del_alert"><span class="ui-icon ui-icon-alert"></span><p>すでに義務者の出欠が登録されています。<br />登録しなおすと出欠情報を設定しなおす必要があります。<br />義務者を登録しなおしますか？</p></div>';
					dialog = dialog + '</div>';
					$("#contner").append(dialog);
					var dlogObj		=$("div[aria-labelledby^='ui-dialog-title']");
					var dlogZidx	=dlogObj.css("z-index");
					dlogObj.css({ zIndex: "50" });

					$("#chk_del_dialog").dialog({
						bgiframe: true,
						resizable: false,
						modal: false,
						width: 'auto',
						minHeight: 80,
						buttons: {
							'キャンセル': function() {
								$(this).dialog("close");
							},
							'登録しなおす': function() {
								reg_comMem(id);		//カレンダー 義務者 登録
								$(this).dialog("close");
							}
						},
						close: function() {
							dlogObj.css({ zIndex: dlogZidx });
							$(this).remove();
						}
					});
				}
			}
		});
	}

	//-------------------------------------------------------------------------------------------カレンダー 義務者 登録関連
	function reg_comMem(id) {												//カレンダー 義務者 登録
		var mID="";
		$("#attendComm tbody tr").find("td:eq(2)").each(function(idx, el) {
			mID = mID + $(el).attr("id").split("mID_")[1] + "/" + $(el).parent().attr("id") + "/,";
		});
		if (mID=="") return;
		var param = xmlModule+'?'+"_xsid="+$("#_xsid").val() + 
				"&_fn=reg_com_Club_Mem" + 
				"&_id=" + id +
				"&_ry=" + $("#ry").val() +
				"&_mID=" + encodeURI(mID) +
				"&_flg=0" +
				"&_at=null" +
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(){
				xmlRetry[reg_comMem_n]++ ;
				if(xmlRetry[reg_comMem_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed reg_comMem");
				else {
					reg_comMem(id);
				}
			},success: function(httpObj){
				xmlRetry[reg_comMem_n]=0;
				var xmlRcS	= httpObj.getElementsByTagName("record");
				var SID		= xmlNull_chk(xmlRcS[0], "msg", -1);
				if (SID==-1) { location.href="./pDistrict.asp?tp=3"; return; }	//ログイン状態でなければreload
				$("#addRep").text("出席義務者を登録しました");
				get_AttedList(id);												//出席者を取得
				$("#comPrv, #comSend").attr("disabled",false).attr("title","");
			}
		});
		//$("#show_xmlURI").html('<a href="'+param+'">'+param+'</a>');
	}

	//-------------------------------------------------------------------------------------------カレンダー クラブ出席者 登録関連
	function reg_clubMem(id) {												//カレンダー クラブ出席者 登録
		var mID ="";
		$("#attendClub tbody tr").find("td[id^='mID_']").each(function(idx, el) {
			//var comm =null, cls =$(el).parent().find("td.comm").text(); if (cls !="") { comm =cls; }
			mID = mID + $(el).attr("id").split("mID_")[1] + "//"+ $(el).parent().find("td.comm").text() +",";
		});
//		if (mID =="") return;		消去の場合があるため空でも実行2011/07/22 

		var param = xmlModule+'?'+"_xsid="+$("#_xsid").val() + 
				"&_fn=reg_com_Club_Mem" + 
				"&_id=" + id +
				"&_ry=" + $("#ry").val() +
				"&_mID=" + encodeURI(mID) +
				"&_flg=1" +
				"&_at=1" +
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(){
				xmlRetry[reg_clubMem_n]++ ;
				if(xmlRetry[reg_clubMem_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed reg_clubMem");
				else {
					reg_clubMem(id);
				}
			},success: function(httpObj){
				xmlRetry[reg_clubMem_n]=0;
				var xmlRcS	= httpObj.getElementsByTagName("record");
				var SID		= xmlNull_chk(xmlRcS[0], "msg", -1);
				if (SID==-1) { location.href="./pDistrict.asp?tp=3"; return; }	//ログイン状態でなければreload
				$("#addRep").text("クラブ出席者を登録しました");
				get_AttedList(id);												//出席者を取得
			}
		});
		//$("#show_xmlURI").html('<a href="'+param+'">'+param+'</a>');
	}

	//-------------------------------------------------------------------------------------------カレンダー 情報を登録関連
	function reg_DS(id,re) {												//カレンダー 情報を登録
		var ts =0, DP;
		DP = $("#DatePri").val();
		if ($("#timeSel").attr("checked") ==false) {
			ts =1;
			if ($("#DatePri").val() =="") {
				DP = $("#DateRel").val();
			}
		}
		var param = xmlModule+'?'+"_xsid="+$("#_xsid").val() + 
				"&_fn=reg_ds" + 
				"&_id=" + id +
				"&_ry=" + $("#ry").val() +
				"&_DateRel=" + $("#DateRel").val() +
				"&_RH="+ $("#relH").val() + 
				"&_RM="+ $("#relM").val() + 
				"&_DatePrior=" + DP + 
				"&_PH="+ $("#priH").val() + 
				"&_PM="+ $("#priM").val() + 
				"&_ts="+ ts + 
				"&_pc="+ $("#planChange").val() + 
				"&_Comment=" + encodeURIComponent($("#Comment").val().replace(/&/gi, "&amp;").replace(/<|＜/gi, "&lt;").replace(/>|＞/gi, "&gt;")) +
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(){
				xmlRetry[reg_ds_n]++ ;
				if(xmlRetry[reg_ds_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed reg_ds");
				else {
					reg_DS(id);
				}
			},success: function(httpObj){
				xmlRetry[reg_ds_n]=0;
				var xmlRcS	= httpObj.getElementsByTagName("record");
				var SID		= xmlNull_chk(xmlRcS[0], "SID", "");
				//if (SID=="") location.reload();		//ログイン状態でなければreload
				/*if (re==0)*/ { location.href="./pDistrict.asp?tp=3"; return; }
				if (id==0 || re !=0) {
					$("#addRep").text("新規で登録しました");
				} else {
					$("#addRep").text("修正しました");
				}
			}
		});
		//$("#show_xmlURI").html('<a href="'+param+'">'+param+'</a>');
	}

	function chk_del_DC(id) {					//カレンダー削除の確認
		var dialog = '<div id="chk_del_dialog" title="カレンダーからの削除" style="display: none;">';
		var rHM ="", pHM ="";
		if ($("#timeSel").attr("checked") ==false) {
			rHM = " "+$("#relH").val() +'：'+ $("#relM").val();
			pHM = " "+$("#priH").val() +'：'+ $("#priM").val();
		}
		dialog = dialog + '  <div id="del_alert"><span class="ui-icon ui-icon-alert"></span><p>' + $("#DateRel").val() + rHM +  '<br />' + $("#DatePri").val() + pHM + '<br />' + $("#Comment").val() + '<br />を削除しますか？</p></div>';
		dialog = dialog + '</div>';
		$("#contner").append(dialog);
		var dlogObj		=$("div[aria-labelledby^='ui-dialog-title']");
		var dlogZidx	=dlogObj.css("z-index");
		dlogObj.css({ zIndex: "50" });

		$("#chk_del_dialog").dialog({
			bgiframe: true,
			resizable: false,
			modal: false,
			width: 'auto',
			minHeight: 80,
			buttons: {
				'キャンセル': function() {
					dlogObj.css({ zIndex: dlogZidx });
					$(this).remove();
				},
				'削除する': function() {
					del_DS(id);			//カレンダー 情報を削除
					//dlogObj.css({ zIndex: dlogZidx });
					//$(this).remove();
				}
			},
			close: function() {
				dlogObj.css({ zIndex: dlogZidx });
				$(this).remove();
			}
		});
	}

	function del_DS(id) {													//カレンダー 情報を削除
		var param = xmlModule+'?'+"_xsid="+$("#_xsid").val() + 
				"&_fn=del_ds" + 
				"&_id=" + id +
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(){
				xmlRetry[del_ds_n]++ ;
				if(xmlRetry[del_ds_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed del_ds_n");
				else {
					del_DS(id);
				}
			},success: function(httpObj){
				xmlRetry[del_ds_n]=0;
				var xmlRcS	= httpObj.getElementsByTagName("record");
				var SID		= xmlNull_chk(xmlRcS[0], "SID", "");
				/*if (SID=="")*/ { location.href="./pDistrict.asp?tp=3"; return; }		//ログイン状態でなければreload
				//$("#chk_del_dialog").remove();
			}
		});
	}

	function chk_edit_DC() {						//カレンダー入力項目の確認
		var ry = $("#ry").val();
		$("#addRep").text("");
		if (chkYMD($("#DateRel").val(), ry) ==false) {		//開始日
			$("#addRep").text("開始日を確認してください");
				return false;
		} else if ($("#DatePri").val() !="") {				//終了日
			if (chkYMD($("#DatePri").val(), ry) ==false) {
				$("#addRep").text("終了日を確認してください");
				return false;
			} else if ($("#DateRel").val() > $("#DatePri").val()) {
				$("#addRep").text("開始日と終了日を確認してください");
				return false;
			} else if ($("#Comment").val() =="") {				//内容
				$("#addRep").text("内容を確認してください");
				return false;
			} else if ($("#timeSel").attr("checked") ==false) {	//時間
				var rt = parseInt($("#relH").val()+$("#relM").val());
				var pt = parseInt($("#priH").val()+$("#priM").val());
				if (($("#DateRel").val() ==$("#DatePri").val()) && (rt >=pt)) {
					$("#addRep").text("時間を確認してください");
					return false;
				} else {
					return true;
				}
			} else {
				return true;
			}
		} else if ($("#Comment").val() =="") {				//内容
			$("#addRep").text("内容を確認してください");
				return false;
		} else if ($("#timeSel").attr("checked") ==false) {	//時間
			var rt = parseInt($("#relH").val()+$("#relM").val());
			var pt = parseInt($("#priH").val()+$("#priM").val());
			if (rt >=pt) {
				$("#addRep").text("時間を確認してください");
				return false;
			} else {
				return true;
			}
		} else {
				return true;
		}
	}


	//-------------------------------------------------------------------------------------------カレンダー 出席者一覧出力
	function out_atMem(id) {						//出席者一覧出力
		var i=0;
		$("#attendChk_com tbody tr, #attendChk_club tbody tr").each(function(idx, el) { i++; });
		if (i >0) {
			location.href="/out_CSV.asp?_cid=" + id + "&_fn=1";
		} else {
			alert("出席者が設定されていません");
		}
	}



//================================================================================================== 委員会 ログイン・チェック　10/04/01Tagaya
	function chk_LoginInf(Idb) {													//chk_LoginInf
		var param = xmlModule+'?'+"_xsid="+$("#_xsid").val() + 
				"&_fn=get_LoginInf" + 
				"&cache=" + (new Date()).getTime();
		$.ajax({
			url: param,
			type: 'POST',
			dataType: 'xml',
			timeout: xmlRetryTimeout,
			error: function(){
				xmlRetry[chk_LoginInf_n]++ ;
				if(xmlRetry[chk_LoginInf_n]>(xmlRetryLimt-1))
					alert("情報の取得に失敗しました。\n最新の情報に更新してください。\nxml failed chk_LoginInf");
				else {
					alert("情報の取得に失敗しました"+chk_LoginInf_n);
					chk_LoginInf();
				}
			},success: function(httpObj){
				xmlRetry[chk_LoginInf_n]=0;
				var xmlRcS = httpObj.getElementsByTagName("record");
				var news = '';
				var loginf = '';
				loginf = xmlNull_chk(xmlRcS[0], "LG", "");
				if( loginf == '0' )
				{
					$("#login_Win").jqmShow();
				}
				else
				{
					var wrkWin=Openwin(  Idb ,'viewPDF','width=800,height=900,resizable=yes');wrkWin.focus();
				}
			}
		});
	}


//================================================================================================== 指定したclass名を取得
	function get_class(tgt, nm) {
		var clen= tgt.attr("class").split(" ");					//classから配列を作成
		var cls = ""
		for (var i=0;i<clen.length;i++) {						//指定したclass名を取得
			if (clen[i].indexOf(nm) >-1) { cls = clen[i]; }
		}
		return cls;
	}


//================================================================================================== 日付の確認
	function chkYMD(datestr, ry) {					//chkYMD
		if(!datestr.match(/^\d{4}\/\d{2}\/\d{2}$/))	return false;	// yyyy/mm/dd 形式でない
		var vYear = datestr.substr(0, 4) - 0;
		var vMonth = datestr.substr(5, 2) - 1;
		var vDay = datestr.substr(8, 2) - 0;
		//月,日の妥当性チェック
		if(vMonth >= 0 && vMonth <= 11 && vDay >= 1 && vDay <= 31){
			var vDt = new Date(vYear, vMonth, vDay);
			if(isNaN(vDt)){
				return false;
			} else if(vDt.getFullYear() == vYear && vDt.getMonth() == vMonth && vDt.getDate() == vDay){
				var rSt = new Date(ry, 7-1, 1);
				var rEd = new Date((ry+1), 6-1, 30);
				if ((rSt.getTime() <=vDt.getTime()) && (rEd.getTime() >=vDt.getTime())) {
					return true;
				} else {
					return false;
				}
			} else {
				return false;
			}
		} else {
			return false;
		}
	}

//================================================================================================== カーソルを末尾に移動
	function cursor_moveToEnd(tgt) {
		var el =document.getElementById(tgt);
		el.focus();
		if (el.createTextRange) {
			var range =el.createTextRange();
			range.move('character', el.value.length);
			range.select();
		} else if (el.setSelectionRange) {
			el.setSelectionRange(el.value.length, el.value.length);
		}
	}


