/*  */
function inpt_ckval_click(ckid, hiid, clid, divid, path, sval, mode, ditem, fdname, fiext, fow, tid) {
	checkbox_val_click(ckid, hiid);
	if (clid.val() == '' && hiid.val() == '1') {
		divid.show();
	} else {
		divid.hide();
	}
	if (clid.val() != '' && tid.attr('id') != 'imptsaves') {
		var zmode = $('#SUB_MODE'+fow).val();
		var zform = '#detail_form_'+zmode+fow;
		var zeri = ($(zform+' #ERI').length > 0 && $(zform+' #ERI').val() != '') ? $(zform+' #ERI').val() : $(zform+' #TEMPERI').val();
		var url = path+'core/cw5e_import.php?sid='+sval+'&parent='+EncodeURLutf8(path)+'&act=imptdafs';
		url += '&mode='+mode+'&ditem='+ditem+'&fdname='+fdname+'&fiext='+fiext+'&code='+clid.val();
		url += '&zmode='+zmode+'&zeri='+zeri+'&fow='+fow;
		$.get(url, '', function(msg) {
			// console.log(msg);
			var ret_msg = JSON.parse(msg);
			if (ret_msg[0].result == 'false') {
				alert(ret_msg[0].message);
				return;
			} else {
				if ((ret_msg[0].itay) && (ret_msg[0].itad)) {
					var itay = ret_msg[0].itay,
						itad = ret_msg[0].itad;
					$('#impt_tite').val(itay['DHEAD']);
					$('#impt_page').val(itay['DPAGE']);
					if (ret_msg[0].html_str) {
						$('#popup_box .select_imptfield').empty().append(ret_msg[0].html_str);
					}
					for (var i=0; i < itad.length; i++) {
						if ((itad[i]['DPCKD']) && 
							$('#imptckbt_'+i.toString()).length > 0 && 
							$('#imptckbts_'+i.toString()).length > 0) {
							if (itad[i]['DPCKD'] == 1) {
								$('#imptckbts_'+i.toString()).prop('checked',true);
							} else if (itad[i]['DPCKD'] == 0) {
								$('#imptckbts_'+i.toString()).prop('checked',false);
							}
							checkbox_val_click($('#imptckbts_'+i.toString()),$('#imptckbt_'+i.toString()));
							ckb_open_editfd($('#imptckbt_'+i.toString()));
						}
						if (itad[i]['DFSTR']) {
							var fdary = itad[i]['DFSTR'].split('|');
							for (var j=0; j < fdary.length; j++) {
								if ($('#imptfield_TABLE'+i.toString()+'_'+j.toString()).length > 0) {
									$('#imptfield_TABLE'+i.toString()+'_'+j.toString()).val(fdary[j]);
								} else break;
							}
						}
					}
				}
			}
		});
	}
}