// JavaScript Document
var autoReloadTimer;
var autoReloadToggle=true;
var lastWarning=0;
var lastRenraku=0;
var webName,srcVer;
var haishaFlg=false;
var simpleFlg=true;
var allUserFlg = false;
var cssURL = '';
var lastWarningCheckMS = 0;
var readInterval = 1000 * 30;	

var loginTaxiCode = '';

var targetHaishaData = {};

var renrakuNoCheckList = [];
var taxiNoCheckList = [];
function loadComplete(){
	cssURL = $('#cssURL').val();
	lastWarningCheckMS = parseInt($('#lastWarningCheckMS').val())*60*1000;
	webName = $('#webName').val();
	srcVer = $('#srcVer').val();
	
	var nowTimecase = $('#timecase').val();
	var newCSSURL = cssURL;
	var mainCSSURL = cssURL + 'main.css';
	switch(nowTimecase){
		case '002':
			newCSSURL = newCSSURL + 'main_night.css';
			$('*[name="btnHaishaHenkou"]').removeClass('btn-secondary');
			$('*[name="btnHaishaHenkou"]').addClass('btn-light');
			$('.btnMenu').removeClass('btn-warning');
			$('.btnMenu').addClass('btn-primary');
			$('*[name="btnModeChange"]').empty();
			$('*[name="btnModeChange"]').append('<i class="fas fa-sun"></i>昼');
			break;

		case '001':
			newCSSURL = newCSSURL + 'main_day.css';
			$('*[name="btnHaishaHenkou"]').removeClass('btn-light');
			$('*[name="btnHaishaHenkou"]').addClass('btn-secondary');
			$('.btnMenu').removeClass('btn-primary');
			$('.btnMenu').addClass('btn-warning');
			$('*[name="btnModeChange"]').empty();
			$('*[name="btnModeChange"]').append('<i class="fas fa-moon"></i>夜');
			break;
	}
	$('#cssMain').attr('href',mainCSSURL);
	$('#cssTimecase').attr('href',newCSSURL);
	
	$('#btnLogin').on('click',function(){
		var sound = new Howl({src: [srcVer+'/sound/mute.mp3']}).play();
		var param = {
			'appname':nasiappname,
			'prgname':'TX001',
			'ssid': '',
			'loginID': $('#inpLoginID').val(),
			'loginPass': $('#inpLoginPass').val(),
			'arguments':'ssid,loginID,loginPass'
		};
		//var retCheck = cmGetXMLbyAjax(param,true,callbackAjax);
		var callbackAjax = function(){
			var retCheck = retXML;
			if($(retCheck).find('kbn').text() === 'I001' ){
				loginTaxiCode = $(retCheck).find('taxiCode').text(); 
				$('#ssid').val($(retCheck).find('ssid').text());
				haishaFlg = $('#chbLoginHaisha').prop('checked');
				if(!haishaFlg){
					simpleFlg = false;
					allUserFlg = false;
					$('#btnSimpleList').hide();
					$('#btnUserList').show();
				}else {
					simpleFlg = true;
					allUserFlg = true;
					$('#btnSimpleList').show();
					$('#btnUserList').hide();
				}
				pagindDiv('divListTaxi');
			}
		};
		cmGetXMLbyAjax(param,true,callbackAjax);
	});
	
	$('#btnSimpleList').on('click',function(){
		simpleFlg = !simpleFlg;
		if(simpleFlg){
			$('#btnSimpleList').text('詳細');
		}else {
			$('#btnSimpleList').text('一行');
		}
		getTaxiList();
	});
	
	$('#btnUserList').on('click',function(){
		allUserFlg = !allUserFlg;
		simpleFlg = !simpleFlg;
		if(simpleFlg){
			$('#btnUserList').text('担当');
		}else {
			$('#btnUserList').text('全件');
		}
		getTaxiList();
	});
	
	$('#btnReloadList').on('click',function(){
		startAutoReload();
		getTaxiList();
	});
	
	$('#btnReloadToggle').on('click',function(){
		if(autoReloadToggle){
			stopAutoReload();
			$(this).text('自動更新 ON');
		}else {
			startAutoReload();
			$(this).text('自動更新OFF');
		}
		autoReloadToggle = !autoReloadToggle;
	});
	
	$('*[name="btnBack"]').on('click',function(){
		pagindDiv($('#backPageID').val());
	});
	
	$('*[name="btnCheck"]').on('click',function(){
		pagindDiv('divRenrakuList');
	});
	
	$('*[name="btnModeChange"]').on('click',function(){
		var nowTimecase = $('#timecase').val();
		var newCSSURL = cssURL;
		switch(nowTimecase){
			case '001':
				newCSSURL = newCSSURL + 'main_night.css';
				$('#timecase').val('002');
				$('*[name="btnHaishaHenkou"]').removeClass('btn-secondary');
				$('*[name="btnHaishaHenkou"]').addClass('btn-light');
				$('.btnMenu').removeClass('btn-warning');
				$('.btnMenu').addClass('btn-primary');
				$('*[name="btnModeChange"]').empty();
				$('*[name="btnModeChange"]').append('<i class="fas fa-sun"></i>昼');
				break;
				
			case '002':
				newCSSURL = newCSSURL + 'main_day.css';
				$('#timecase').val('001');
				$('*[name="btnHaishaHenkou"]').removeClass('btn-light');
				$('*[name="btnHaishaHenkou"]').addClass('btn-secondary');
				$('.btnMenu').removeClass('btn-primary');
				$('.btnMenu').addClass('btn-warning');
				$('*[name="btnModeChange"]').empty();
				$('*[name="btnModeChange"]').append('<i class="fas fa-moon"></i>夜');
				break;
		}
		$('#cssTimecase').attr('href',newCSSURL);
	});
	
	$('*[name="btnLogoff"]').on('click',function(){
		var param = {
			'appname':nasiappname,
			'prgname':'TX009',
			'ssid': $('#ssid').val(),
			'arguments':'ssid'
		};
		
		//var getList = cmGetXMLbyAjax(param,true);
		var callbackAjax = function(){
			var getList = retXML;
			if($(getList).find('kbn').text() === 'I001' ){
				window.location.href = 'driver.html';
			}
		};
		cmGetXMLbyAjax(param,true,callbackAjax);
	});
	
};

function pagindDiv(pageID){
	stopAutoReload();
	
	$('#pageID').val(pageID);
	
	$('#backPageID').val($('.pageDiv.d-block').attr('id'));
	
	$('.pageDiv').removeClass('d-block');
	$('.pageDiv').addClass('d-none');
	
	$('#'+pageID).addClass('d-block');
	$('#'+pageID).removeClass('d-none');
	
	switch(pageID){
		case 'divListTaxi' :
			startAutoReload();
			getTaxiList();
			break;
		
		case 'divChoiceTaxi' :
			getTaxiNoList();
			break;
		
		case 'divPilotData' :
			break;
			
		case 'divRenrakuList' :
			getRenrakuList();
			break;
	}
	
	$(window).scrollTop(0);
}

function startAutoReload(){
	autoReloadTimer = setInterval(getTaxiList,readInterval);
}
function stopAutoReload(){
	clearInterval(autoReloadTimer);
}

function getTaxiList(){
	$('#spinLoading').show();
	var param = {
		'appname':nasiappname,
		'prgname':'TX011',
		'ssid': $('#ssid').val(),
		//'haichaCheck' : haishaFlg,
		'haichaCheck' : allUserFlg,
		'arguments':'ssid,haichaCheck'
	};
	//var getList = cmGetXMLbyAjax(param,true);
	var callbackAjax = function(){
		var getList = retXML;
		if($(getList).find('kbn').text() === 'I001' ){
			$('#lstTaxi').empty();
			var warningFlg = false;
			var soundFlg = false;
			$(getList).find('line').each(function(){
				var btnCss = '';
				if($('#cssTimecase').attr('data-timecase') === '001'){
					btnCss = 'btn-secondary';
				}else {
					btnCss = 'btn-light';
				}
				var btnHaisya = '&nbsp;',cssHaisya='nomalTbody',cssStatus="";
				var iconKakunin = '',classKakunin='icon-red';
				if(haishaFlg){
					if($(this).find('noTaxiFlg').text() === '0'){
						if($(this).find('taxiCode').text() === ''){
							if($(this).find('ketteiKbn').text() === '1'){
								btnHaisya = '<button type="button" class="btn btn-success btn-sm btnHaisha" name="btnHaisha" data-haishakbn="0" data-taxino="'+$(this).find('taxiNo').text()+'">配車</button>';
							}
							if($(this).find('saisokuFlg').text() === '0'){
								cssHaisya = 'haisyaTbody';
							}else {
								cssHaisya = 'saisokuTbody';
								warningFlg = true;
								if(taxiNoCheckList.indexOf($(this).find('taxiNo').text()) === -1){
									taxiNoCheckList.push($(this).find('taxiNo').text());
									soundFlg = true;
								}
							}
						}else {
							btnHaisya = '<button type="button" class="btn '+btnCss+' btn-sm btnHaisha" name="btnHaishaHenkou" data-haishakbn="1" data-taxino="'+$(this).find('taxiNo').text()+'">変更</button>';
						}
					}
					if($(this).find('kakuninKbn').text() === '1'){
						iconKakunin = '<i class="fas"><img class="sumi" src="'+srcVer+'/image/sumi.png"></i>';
						classKakunin = '';
					}
				}else {
					if($(this).find('kakuninKbn').text() === '1'){
						iconKakunin = '<i class="fas"><img class="sumi" src="'+srcVer+'/image/sumi.png"></i>';
						classKakunin = '';
					}
					if($(this).find('kakuninKbn').text() === '0' && loginTaxiCode === $(this).find('taxiCode').text()){
						btnHaisya = '<button type="button" class="btn '+btnCss+' btn-sm btnHaishaKakunin" name="btnHaishaKakunin" data-taxino="'+$(this).find('taxiNo').text()+'">確認</button>';
					}
				}
				var mukaeIcon = '';
				if($(this).find('mukaeKbn').text() === '1' || $(this).find('mukaeKbn').text() === '2'){
					mukaeIcon = '<i class="fas fa-home"></i>';
				}else {
					//mukaeIcon = '<i class="fas fa-subway"></i>';
				}

				var pilotLink = '';
				if($(this).find('pilotCode').text() !== '000'){
					pilotLink = '<a href="#" data-pilotid='+$(this).find('pilotCode').text()+' class="lnkPilot">'+$(this).find('pilotName').text()+'</a>';
				}else {
					pilotLink = $(this).find('pilotName').text();
				}

				var sougeiDisp = '';
				if($(this).find('mukaeKbn').text() === '1' || $(this).find('mukaeKbn').text() === '2'){
					sougeiDisp = '<i class="fas fa-home"></i>' +$(this).find('mukaeTimeSimple').text() + $(this).find('endPoint').text() +$(this).find('trainTimeSimple').text();
				}else {
					sougeiDisp = $(this).find('fromPoint').text() + $(this).find('mukaeTimeSimple').text() + $(this).find('trainTimeSimple').text()+'<i class="fas fa-home"></i>';
				}
				/*
				if(simpleFlg && $(this).find('biko').text() !== ''){
					sougeiDisp = '<i class="fas fa-exclamation-triangle icon-yellow"></i>'+sougeiDisp;
				}
				*/
				if($(this).find('midokuKbn').text() === '0'){
					if($(this).find('jimusyokeiyuKbun').text() === '1'){
						sougeiDisp = '<i class="fas fa-at icon-red"></i>'+sougeiDisp;
					}else if($(this).find('hatobakoKbn').text() === '1'){
						sougeiDisp = '<i class="fas fa-tenge icon-red"></i>'+sougeiDisp;
					}else{
						sougeiDisp = '<i class="fas fa-exclamation-triangle icon-yellow"></i>'+sougeiDisp;
					}
				}
				if($(this).find('ketteiKbn').text() === '1'){
					sougeiDisp = '<i class="fas"><img class="kettei" src="'+srcVer+'/image/kettei.png"></i>' + sougeiDisp;
				}

				var boatNo = '';
				if($(this).find('boatNo').text() !== ''){
					boatNo  = '<i class="fas fa-ship"></i>'+$(this).find('boatNo').text();
				}

				var addList = '';
				if(!simpleFlg){
					addList = 	'<li class="'+cssHaisya+'">' +
									'<div class="container-fluid">'+
										'<div class="row no-gutters bottomRow">' +
											'<div class="clearfix TaxiNickName"><span class="'+classKakunin+'">'+$(this).find('taxiNickName').text()+'</span></div>'+
											'<div class="clearfix PilotLink">'+pilotLink+'</div>' +
											'<div class="clearfix HaishaInfo sougeiDisp">'+ 
												sougeiDisp + 
											'</div>' +
											'<div class="clearfix Icon">'+iconKakunin+'</div>' +
										'</div>' +
										'<div class="row no-gutters bottomRow">' +										
											'<div class="clearfix BortNo">' +boatNo +'</div>' +
											'<div class="clearfix Biko">' +$(this).find('biko').text() +'</div>' +
											'<div class="clearfix HaishaButton"><div class="float-right">' +btnHaisya +'</div></div>' +
										'</div>' +
									'</div>' +
								'</li>';
				}else {
					addList = 	'<li class="'+cssHaisya+'">' +
									'<div class="container-fluid">'+
										'<div class="row no-gutters bottomRow">' +
											'<div class="clearfix TaxiNickName"><span class="'+classKakunin+'">'+$(this).find('taxiNickName').text()+'</span></div>'+
											'<div class="clearfix PilotLink">'+pilotLink+'</div>' +
											'<div class="clearfix simpleHaishaInfo sougeiDisp">'+ 
												sougeiDisp + 
											'</div>' +
											'<div class="clearfix HaishaButton"><div class="float-right">' +btnHaisya +'</div></div>' +
										'</div>' +
									'</div>' +
								'</li>';
				}
				$('#lstTaxi').append(addList);
				var addHaishaData = {
					taxiNickName : $(this).find('taxiNickName').text(),
					pilotLink : $(this).find('pilotName').text(),
					sougeiDisp : sougeiDisp,
					iconKakunin : iconKakunin,
					boatNo : boatNo,
					biko : $(this).find('biko').text()
				};
				if(addHaishaData.taxiNickName === ''){ addHaishaData.taxiNickName = '&nbsp;'; }
				if(addHaishaData.pilotLink === ''){ addHaishaData.pilotLink = '&nbsp;'; }
				if(addHaishaData.sougeiDisp === ''){ addHaishaData.sougeiDisp = '&nbsp;'; }
				if(addHaishaData.iconKakunin === ''){ addHaishaData.iconKakunin = '&nbsp;'; }
				if(addHaishaData.boatNo === ''){ addHaishaData.boatNo = '&nbsp;'; }
				if(addHaishaData.biko === ''){ addHaishaData.biko = '&nbsp;'; }
				targetHaishaData[$(this).find('taxiNo').text()] = addHaishaData;
			});
			$('.btnHaisha').on('click',function(){
				var haishaKbn = $(this).attr('data-haishakbn');
				var targetNo = $(this).attr('data-taxino');
				callTaxiNoList(haishaKbn,targetNo);
			});
			$('.btnHaishaKakunin').on('click',function(){
				var targetNo = $(this).attr('data-taxino');
				setKakunin(targetNo);
			});
			$('.lnkPilot').on('click',function(){
				var pilotCode = $(this).attr('data-pilotid');
				callPilotData(pilotCode);
			});

			var nowDate = new Date();
			var nowTimMS = nowDate.getTime();
			if(soundFlg){
				callWarningSE();
				lastWarning = nowTimMS;
			}else if(warningFlg){
				if(nowTimMS - lastWarning > lastWarningCheckMS){
					callWarningSE();
					lastWarning = nowTimMS;
				}
			}

			getNowDateTime();
			$('#spinLoading').hide();
			setTimeout(function(){
				checkRenraku();
			},1000*2);

		}
	};
	cmGetXMLbyAjax(param,true,callbackAjax);
	
}

function setKakunin(targetNo){
	$('#spinLoading').show();
	var param = {
		'appname':nasiappname,
		'prgname':'TX012',
		'ssid': $('#ssid').val(),
		'taxiNo' : targetNo,
		'arguments':'ssid,taxiNo'
	};
	//var getList = cmGetXMLbyAjax(param,true);
	var callbackAjax = function(){
		var getList = retXML;
		if($(getList).find('kbn').text() === 'I001' ){		
			getTaxiList();
			$('#spinLoading').hide();
		}
	};
	cmGetXMLbyAjax(param,true,callbackAjax);
}
function checkRenraku(){
	$('#spinLoading').show();
	var param = {
		'appname':nasiappname,
		'prgname':'TX031',
		'ssid': $('#ssid').val(),
		'haichaCheck' : haishaFlg,
		'option' : 0,
		'arguments':'ssid,haichaCheck,option'
	};
	//var getList = cmGetXMLbyAjax(param,true);
	var callbackAjax = function(){
		var getList = retXML;
		if($(getList).find('kbn').text() === 'I001' ){		
			var checkRenrakuFlg = false;
			var soundFlg = false;
			$('#iconRenraku').addClass('d-none');
			if($(getList).find('alertFlg').text() === '1'){ $('#iconRenraku').removeClass('d-none'); }
			$(getList).find('line').each(function(){
				if($(this).find('kidokuKbn').text() === '0'){
					checkRenrakuFlg = true;
				}
				if(renrakuNoCheckList.indexOf($(this).find('renrakuNo').text()) === -1){
					renrakuNoCheckList.push($(this).find('renrakuNo').text());
					soundFlg = true;
				}
			});

			var nowDate = new Date();
			var nowTimMS = nowDate.getTime();
			if(soundFlg){
				callWarningRenraku();
				lastRenraku = nowTimMS;
			}else if(checkRenrakuFlg){
				if(nowTimMS - lastRenraku > lastWarningCheckMS){
					callWarningRenraku();
					lastRenraku = nowTimMS;
				}
			}
			getNowDateTime();
			$('#spinLoading').hide();
		}
	};
	
	cmGetXMLbyAjax(param,true,callbackAjax);
}

function getNowDateTime(){
	var nowDate = new Date();
	var nowDateText = nowDate.getFullYear()+'/'+String(nowDate.getMonth()+1)+'/'+nowDate.getDay()+' '+nowDate.getHours()+':'+nowDate.getMinutes()+':'+nowDate.getSeconds();
	$('#spnListUpdateDateTime').text('最終更新：'+nowDateText);
}

function callWarningSE(){
	var sound = new Howl({src: [srcVer+'/sound/warning1.mp3']}).play();
} 
function callWarningRenraku(){
	var sound = new Howl({src: [srcVer+'/sound/warning2.mp3']}).play();
} 

function callPilotData(callPilotCode){
	getPilotData(callPilotCode);
	//pagindDiv('divPilotData');
}

function getPilotData(callPilotCode){
	$('#spinLoading').show();
	var param = {
		'appname':nasiappname,
		'prgname':'TX041',
		'ssid': $('#ssid').val(),
		'pilotCode' : callPilotCode,
		'arguments':'ssid,pilotCode'
	};
	//var getList = cmGetXMLbyAjax(param,true);
	var callbackAjax = function(){
		var getList = retXML;
		if($(getList).find('kbn').text() === 'I001' ){
			$('.spnPilotData').empty();

			$('#spnPilotName').text($(getList).find('mizusakiName').text());
			$('#spnPilotZipcode').text($(getList).find('zipCode').text());
			$('#spnPilotAddress1').text($(getList).find('address1').text());
			$('#spnPilotAddress2').text($(getList).find('address2').text());

			$('#modalUserInfo').modal('show');
			$('#spinLoading').hide();
		}
	};
	
	cmGetXMLbyAjax(param,true,callbackAjax);
}


function callTaxiNoList(callHaishaKbn,callTargetNo){
	$('#hdnCallHaishaKbn').val(callHaishaKbn);
	$('#hdnTargetTaxiNo').val(callTargetNo);
	pagindDiv('divChoiceTaxi');
}

function getTaxiNoList(){
	$('#spinLoading').show();
	var param = {
		'appname':nasiappname,
		'prgname':'TX021',
		'ssid': $('#ssid').val(),
		'haichaCheck' : haishaFlg,
		'arguments':'ssid,haichaCheck'
	};
	//var getList = cmGetXMLbyAjax(param,true);
	var callbackAjax = function(){
		var getList = retXML;
		if($(getList).find('kbn').text() === 'I001' ){
			$('#lstTaxiNo').empty();
			var setHaishaData = targetHaishaData[$('#hdnTargetTaxiNo').val()];
			var addTargetHaishaData = 	'<li>' +
											'<div class="container-fluid">'+
												'<div class="row no-gutters bottomRow">' +
													'<div class="clearfix TaxiNickName">'+setHaishaData.taxiNickName+'</div>'+
													'<div class="clearfix PilotLink">'+setHaishaData.pilotLink+'</div>' +
													'<div class="clearfix simpleHaishaInfo sougeiDisp">'+setHaishaData.sougeiDisp + '</div>' +
													'<div class="clearfix Icon">'+setHaishaData.iconKakunin +'</div>' +
												'</div>' +
												'<div class="row no-gutters bottomRow">' +										
													'<div class="clearfix BortNo">' +setHaishaData.boatNo +'</div>' +
													'<div class="clearfix Biko">' +setHaishaData.biko +'</div>' +
												'</div>' +
											'</div>' +
										'</li>';
			$('#lstTaxiNo').append(addTargetHaishaData);
			
			$(getList).find('line').each(function(){
				var addList = 	'<li class="liTaxiNo" data-taxicode="'+$(this).find('taxiCode').text()+'">' +
									'<div class="container-fluid">'+
										'<div class="row no-gutters">' +
											'<div class="col-sm-11">'+
												$(this).find('taxiName').text() +
											'</div>' +
											'<div class="col-sm-1">'+
												'<i class="fas fa-arrow-circle-right"></i>' +
											'</div>' +
										'</div>' +
									'</div>' +
								'</li>';
				$('#lstTaxiNo').append(addList);
			});
			
			$('#lstTaxiNo>li.liTaxiNo').on('click',function(){
				if (confirm("配車変更しますか？")==true){
					setTaxiNo($(this).attr('data-taxicode'));
				}
			});
			$('.lnkPilot').on('click',function(){
				var pilotCode = $(this).attr('data-pilotid');
				callPilotData(pilotCode);
			});
			$('#spinLoading').hide();
		}
	};
	cmGetXMLbyAjax(param,true,callbackAjax);
}

function setTaxiNo(setTaxiCode){
	var param = {
		'appname':nasiappname,
		'prgname':'TX022',
		'ssid': $('#ssid').val(),
		'haishaNo' : $('#hdnTargetTaxiNo').val(),
		'taxiCode' : setTaxiCode,
		'arguments':'ssid,haishaNo,taxiCode'
	};
	//var getList = cmGetXMLbyAjax(param,true);
	var callbackAjax = function(){
		var getList = retXML;
		if($(getList).find('kbn').text() === 'I001' ){
			pagindDiv('divListTaxi');
		}
	};
	cmGetXMLbyAjax(param,true,callbackAjax);
}

function getRenrakuList(){
	$('#spinLoading').show();
	var param = {
		'appname':nasiappname,
		'prgname':'TX031',
		'ssid': $('#ssid').val(),
		'haichaCheck' : haishaFlg,
		'option' : 1,
		'arguments':'ssid,haichaCheck,option'
	};
	//var getList = cmGetXMLbyAjax(param,true);
	var callbackAjax = function(){
		var getList = retXML;
		if($(getList).find('kbn').text() === 'I001' ){
			$('#lstRenraku').empty();
			$('#iconRenraku').addClass('d-none');
			if($(getList).find('alertFlg').text() === '1'){ $('#iconRenraku').removeClass('d-none'); }
			$(getList).find('line').each(function(){
				var listIcon = '';
				if($(this).find('kidokuKbn').text() === '0'){
					listIcon = '<i class="fas fa-arrow-circle-right"></i>';
				}else if($(this).find('kidokuKbn').text() === '1'){
					listIcon = '<i class="fas"><img class="sumi" src="'+srcVer+'/image/sumi.png"></i>';
				}else {
					listIcon = '';
				}
				var addList = 	'<li data-kidokukbn="'+$(this).find('kidokuKbn').text()+'" data-renorakuno="'+$(this).find('renrakuNo').text()+'">' +
									'<div class="container-fluid">'+
										'<div class="row no-gutters">' +
											'<div class="col-sm-4">'+
												$(this).find('renrakuDate').text() + '&nbsp;' + $(this).find('renrakuTime').text() +
											'</div>' +
											'<div class="col-sm-4">'+
												$(this).find('shozokuName').text() +
											'</div>' +
											'<div class="col-sm-4">'+
												$(this).find('renrakuUser').text() +
											'</div>' +
										'</div>' +
										'<div class="row no-gutters">' +
											'<div class="col-sm-11">'+
												$(this).find('renrakuStr').text() +
											'</div>' +
											'<div class="col-sm-1">'+
												listIcon +
											'</div>' +
										'</div>' +
									'</div>' +
								'</li>';
				$('#lstRenraku').append(addList);
			});
			$('#lstRenraku>li[data-kidokukbn="0"]').on('click',function(){
				setRenrakuNo($(this).attr('data-renorakuno'));
			});
			$('#spinLoading').hide();
		}
	};
	cmGetXMLbyAjax(param,true,callbackAjax);
}

function setRenrakuNo(renrakuNo){
	var param = {
		'appname':nasiappname,
		'prgname':'TX032',
		'ssid': $('#ssid').val(),
		'renrakuNo' : renrakuNo,
		'arguments':'ssid,renrakuNo'
	};
	//var getList = cmGetXMLbyAjax(param,true);
	var callbackAjax = function(){
		var getList = retXML;
		if($(getList).find('kbn').text() === 'I001' ){
			getRenrakuList();
		}
	};
	cmGetXMLbyAjax(param,true,callbackAjax);
}