$(function(){
	$("#btnNewCredential").click(function(e){
		$("#type").val("new_dev_credential")
		submitForm()
	})
	
	$("#btnBackInput").click(function(e){
		$("#type").val("new_dev_credential")
		submitForm()
	})
	
	$("#btnConfirm").click(function(e){
		$("#type").val("credential_confirm")
		submitForm()
	})
	
	$("#btnAddNewCred").click(function(e){
		$("#type").val("credential_complete")
		submitForm()
	})
	
	$("#btnChangePasscode").click(function(e){
		$("#type").val("credential_mod_passcode")
		submitForm()
	})
	
	$("#btnBackEdit").click(function(e){
		$("#type").val("credential_edit")
		submitForm()
	})
	
	$("#btnSave").click(function(e){
		$("#type").val("credential_update")
		submitForm()
	})
	
	$("#btnSavePasscode").click(function(e){
		$("#type").val("credential_passcode_update")
		submitForm()
	})
	
	$("#sExecutionCounter").inputFilter(function(value) {
		  return /^-?\d*$/.test(value); });
	
	$("#btnSearch").click(function(e){
		submitForm("searchForm")
	})
	
	$(".rmv-dev-cred").click(function(e){
		e.preventDefault()
		let devKey = $(this).attr("hold")
		
		var asking = confirm($("#confirm_delete_devcred").val()+" ["+devKey+"]")
		
		if(asking){
			$("#type").val("credential_delete")
			$("#developer_key").val(devKey)
			submitForm()
		}
	})
	
	$(".dev-key-view").click(function(e){
		e.preventDefault()
		let devKey = $(this).attr("hold")
		
		$("#type").val("credential_edit")
		$("#developer_key").val(devKey)
		
		submitForm()
	})
	
	let datePickerIds = [
		"#expiration_date",
		"#expireDateFrom",
		"#expireDateTo",
		"#executionDateFrom",
		"#executionDateTo",
		"#createDateFrom",
		"#createDateTo",
		"#updateDateFrom",
		"#updateDateTo"
	];
	
	datePickerIds.forEach(function(item, index){
		if($(item).length == 1){
			$(item).datepicker({
					// カレンダーの設定
				dateFormat	: 'yy/mm/dd'
			})
		}
	})
})

