// JavaScript Document
var docData = [];
var docPastData = [];
var docFavoriteData = [];
var largeSummary = false;
var largeFavorite = false;
var largeContact = false;


$(document).ready(function(){
	window.name = "W160";
	
	$('.extract').click(function(){
		var extractKbn = $(this).attr("data-extractKbn");
		$('#searchSyoriKbn').val(extractKbn);
		getSearch();
	});
	
	getSearch();
});

function getSearch(){
	var setParam = {
		'appname':'NAIS3WEB',
		'prgname':'W162',
		'ssid': $('#ssid').val(),
		'searchKbn': $('#searchSyoriKbn').val(),
		'koroCd' : $('#slctKoro').val(),
		'dateYM' : $('#slctTukaDateYM').val(),
		'day' : $('#slctTukaDateD').val(),		
		'arguments':'ssid,searchKbn,koroCd,dateYM,day'
	};
	getSearchCore(setParam);
}

function getSearchCore(searchParam){
	$.ajax({
		async : true,
		url: ajaxURL,
		data : searchParam,
		dataType:'html',
		scriptCharset: 'utf-8',
		success : function(html){			
			var getHtml = $($.parseHTML(html));
			var sessionError = getHtml.filter('#sessionError').val();
			var searchKensu = parseInt(getHtml.filter('#hdnSearchKensu').val());
			if(sessionError === '0'){
				$('#divSearchContents').empty();
				$('#divSearchContents').append(getHtml.filter('#divSearchRes')[0].innerHTML);
				
				$('#btnPrintAllTop').on(
					'click',
					function(){
						KoroTuhoPrt(1);
					}
				);
				$('#btnPrintAllTopBottom').on(
					'click',
					function(){
						KoroTuhoPrt(1);
					}
				);
				$('#btnPrintSelectTop').on(
					'click',
					function(){
						KoroTuhoPrt(0);
					}
				);
				$('#btnPrintSelectBottom').on(
					'click',
					function(){
						KoroTuhoPrt(0);
					}
				);
				if(searchKensu === 0){
					cmAlert('エラー','該当のデータはありません。');
				}
				
			}else {
				cm_sessionError();
			}
		},
		error : function(XMLHttpRequest, textStatus, errorThrown){
				cmAjaxError(XMLHttpRequest, textStatus, errorThrown);
		}
	});
}		

//支援情報
function SienJoho(order_no){
	$('#prgname').val('W130');
	var funk1     = $('#searchSyoriKbn').val();
	var kyoten    = $('#slctKoro').val();	
	var r_dateym  = $('#slctTukaDateYM').val();
	var r_dated   = $('#slctTukaDateD').val();
	$('#prgname').val('W130');
	$('#param1').val(funk1);
	$('#param2').val(kyoten);
	$('#param3').val(r_dateym);
	$('#param4').val(r_dated);
	$('#param5').val(order_no);	
	$('#param6').val('W160');
	$('#param7').val('');
	$('#param8').val(0);
	$('#param9').val(0);
	$('#param10').val(0);
	$('#param11').val(0);
	$('#param12').val(0);
	$('#menuForm').submit();
}
//航路通報印刷
function KoroTuhoPrt(pkbn){
	var funk1 = $('#searchSyoriKbn').val();
	var koroCd = $('#slctKoro').val();
	var dateYM = $('#slctTukaDateYM').val();
	var day = $('#slctTukaDateD').val();
	var ssid = $('#ssid').val();
	/*
	var printUrl = naisserver+'?APPNAME='+nasiappname+'&PRGNAME=W170&ARGUMENTS=-A'+nasiappname+',-A'+ssid+',-A'+funk1+',-A'+koroCd+',-A'+pkbn+',-A'+dateYM+',-A'+day;
	window.open(printUrl,"航路通報印刷",'toolbar=0,directories=0,status=1,resizable=1,scrollbars=0,menubar=0,left=100,top=60,width=800,height=550,');
	*/
	window.open("",'航路通報印刷','toolbar=0,directories=0,status=1,resizable=1,scrollbars=0,menubar=0,left=100,top=60,width=800,height=550');
	$('#windowForm').attr('target','航路通報印刷');
	$('#Wprgname').val('W170');
	$('#w_param1').val(nasiappname);
	$('#w_param2').val(ssid);
	$('#w_param3').val(funk1);
	$('#w_param4').val(koroCd);
	$('#w_param5').val(pkbn);
	$('#w_param6').val(dateYM);
	$('#w_param7').val(day);
	$('#w_param8').val('');
	$('#w_param9').val('');
	$('#w_param10').val('');
	$('#windowForm').submit();
	$('#windowForm').attr('target','_self');
}

//水島航路通航予定表印刷
function MizusimaKoroPrt(){
	var funk1 = $('#hdnMizusimaFunc1').val();
	var tuka_dateym = $('#hdnMizusimaTukaDateYM').val();
	var tuka_dated = $('#hdnMizusimaTukaDateD').val();
	var koro = $('#hdnMizusimaKoro').val();
	var ssid = $('#ssid').val();
	/*
	var printUrl = naisserver+'?APPNAME='+nasiappname+'&PRGNAME=W200&ARGUMENTS=-A'+nasiappname+',-A'+ssid+',-A'+funk1+',-A'+koro+',-A'+tuka_dateym+',-A'+tuka_dated;
	window.open(printUrl,"水島航路通航予定表印刷",'toolbar=0,directories=0,status=1,resizable=1,scrollbars=0,menubar=0,left=100,top=60,width=800,height=550,');
	*/
	window.open("",'水島航路通航予定表印刷','toolbar=0,directories=0,status=1,resizable=1,scrollbars=0,menubar=0,left=100,top=60,width=800,height=550');
	$('#windowForm').attr('target','水島航路通航予定表印刷');
	$('#Wprgname').val('W200');
	$('#w_param1').val(nasiappname);
	$('#w_param2').val(ssid);
	$('#w_param3').val(funk1);
	$('#w_param4').val(koro);
	$('#w_param5').val(tuka_dateym);
	$('#w_param6').val(tuka_dated);
	$('#w_param7').val('');
	$('#w_param8').val('');
	$('#w_param9').val('');
	$('#w_param10').val('');
	$('#windowForm').submit();
	$('#windowForm').attr('target','_self');
}

function NPHelp(){
	var hdnWebDocAlias = $('#hdnWebDocAlias').val();
	window.open(hdnWebDocAlias+"help/nphelp_koro001.htm");
}