/*  */
function cw5e_mcheck_field(path, sval, mode, ditem, table, fdname, fchk, dform, deri, fow) {
	var inidval = dform+" #"+fdname+((deri == "") ? "" : "_"+deri);
	var inid = $(inidval);
	if (inid.length > 0) {
		var gfid = inid.attr("gfid"),
			htpe = inid.attr("htpe"),
			objt = inid.attr("objt"),
			defv = inid.attr("defv"),
			cust = inid.attr("mft");
		switch (objt) {
			case "edNumeric":
			case "edFloat":
			case "edEditBtnF":
				mode_check_number(path,sval,inid,defv);
				break;
			case "edDateEdit":
				if (inid.val() != '') mode_check_date(path,sval,inid,defv,cust);
				break;
			case "edGetNoDate":
				mode_check_date(path,sval,inid,defv,cust);
				if ($('#ERI').val().trim() == ''){
					mode_update_code(path,sval,mode,ditem,table,'newCODE',dform);
				}
				break;
			case "edyymmEdit":
				if (htpe == "edDateEdit") {
					if (!IsCheckDate(inid.val(), "S111")) {
						console.log('edyymmEdit error[1]('+inid.val()+')!');
						inid.val(defv);
					}
				} else {
					switch (cust) {
						case "mmyy":
							if (!inid.val().match("^[0-1]?[0-9][/][0-2][0-9][0-9][0-9]$")) {
								console.log('edyymmEdit error[2]('+inid.val()+')!');
								inid.val(defv);
							}
							break;
						case "yymm":
						default:
							if (!inid.val().match("^[0-2][0-9][0-9][0-9][/][0-1]?[0-9]$")) {
								console.log('edyymmEdit error[3]('+inid.val()+')!');
								inid.val(defv);
							}
							break;
					}
				}
				break;
			case "edYearEdit":
				if (htpe == "edDateEdit") {
					if (!IsCheckDate(inid.val(), "S111")) {
						console.log('edYearEdit error[1]('+inid.val()+')!');
						inid.val(defv);
					}
				} else {
					if (!inid.val().match("^[0-2][0-9][0-9][0-9]$")) {
						console.log('edYearEdit error[2]('+inid.val()+')!');
						inid.val(defv);
					}
				}
				break;
			case "edMonthEdit":
				if (htpe == "edDateEdit") {
					if (!IsCheckDate(inid.val(), "S111")) {
						console.log('edMonthEdit error[1]('+inid.val()+')!');
						inid.val(defv);
					}
				} else {
					if (!inid.val().match("^[0-1]?[0-9]$")) {
						console.log('edMonthEdit error[2]('+inid.val()+')!');
						inid.val(defv);
					}
				}
				break;
			case "edTimeEdit":
				if (htpe == "edTimeEdit" || cust == "HHiiss") {
					if (inid.val().match("^[0-2][0-9][:][0-5][0-9]$")) {
						inid.val(inid.val()+':00');
					}
					if (!inid.val().match("^[0-2][0-9][:][0-5][0-9][:][0-5][0-9]$")) {
						console.log('edTimeEdit error[1]('+inid.val()+')!');
						inid.val(defv);
					}
				} else {
					if (!inid.val().match("^[0-2][0-9][:][0-5][0-9]$")) {
						console.log('edTimeEdit error[2]('+inid.val()+')!');
						inid.val(defv);
					}
				}
				break;
			default:
				break;
		}
		if (fchk == "Y") {
			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_engine_detail.php?sid='+sval+'&parent='+EncodeURLutf8(path)+'&mode='+mode+'&ditem='+ditem+'&fdname='+fdname+'&deri='+deri+'&act=feck';
			url += '&ckval='+EncodeURLutf8(inid.val().replace(/'/g, "''"));
			url += '&zmode='+zmode+'&zeri='+zeri;
			var djson = (fromid_output_json(dform,'name')).replace(/'/g, "''");
			var verlen = djson.length;
			url += '&verlen='+verlen.toString();
			//console.log(url);
			$.post(url, 'htmljson='+EncodeURLutf8(djson), function(msg) {
				// console.log(msg);
				var ret_msg = JSON.parse(msg);
				if (ret_msg[0].result == "false") {
					inid.css("background-color", "#FF7744");
					alert(ret_msg[0].message);
					return;
				} else {
					inid.css("background-color", "#FFFFFF");
				}
			});
		}
		if (gfid == "E") {
			var alcs = inid.attr("alcs");
			var sect = $(dform+" ."+alcs),
				tval = inid.val();
			switch (objt) {
				case "edComboList":
					sect.val(tval);
					if (sect.attr("fopt") == "Y") {
						sect.find("option").remove().end();
						sect.append("<option value=\""+tval+"\">"+tval+"</option>");
					}
					break;
				case "edyymmEdit":
					if (htpe == "edDateEdit") {
						var dateArray = tval.split("/");
						$(dform+" ."+alcs+"_y").val(dateArray[0]);
						$(dform+" ."+alcs+"_m").val((('0'+dateArray[1]).substr(-2, 2)));
					} else {
						switch (cust) {
							case "mmyy":
								var dateArray = tval.split("/");
								$(dform+" ."+alcs+"_y").val(dateArray[1]);
								$(dform+" ."+alcs+"_m").val((('0'+dateArray[0]).substr(-2, 2)));
								break;
							case "yymm":
							default:
								var dateArray = tval.split("/");
								$(dform+" ."+alcs+"_y").val(dateArray[0]);
								$(dform+" ."+alcs+"_m").val((('0'+dateArray[1]).substr(-2, 2)));
								break;
						}
					}
					break;
				case "edYearEdit":
					if (htpe == "edDateEdit") {
						var dateArray = tval.split("/");
						$(dform+" ."+alcs).val(dateArray[0]);
					} else {
						$(dform+" ."+alcs).val(tval);
					}
					break;
				case "edMonthEdit":
					if (htpe == "edDateEdit") {
						var dateArray = tval.split("/");
						$(dform+" ."+alcs).val(dateArray[1]);
					} else {
						$(dform+" ."+alcs).val(tval);
					}
					break;
				case "edTimeEdit":
					var dateArray = tval.split(":");
					$(dform+" ."+alcs+"_H").val(dateArray[0]);
					$(dform+" ."+alcs+"_i").val(dateArray[1]);
					if (cust == "HHiiss") $(dform+" ."+alcs+"_s").val(dateArray[2]);
					break;
				case "edCheckBox":
					if (tval == "1") {
						sect.prop("checked",true);
					} else {
						sect.prop("checked",false);
					}
					break;
				case "edWebStr":
					sect.html(tval);
					break;
				case "edRadioGroup":
					sect.prop("checked", false);
					$(dform+" ."+alcs+"_"+tval).prop("checked", true);
					break;
				case "edWebReplace":
					sect.hide();
					$(dform+" ."+alcs+"_"+tval).show();
					break;
				case "edPathImg":
					var url = path+'core/cw5e_engine_detail.php?sid='+sval+'&parent='+EncodeURLutf8(path)+'&mode='+mode+'&act=imgpath';
					url += '&orgph='+EncodeURLutf8(tval);
					//console.log(url);
					$.get(url, '', function(msg) {
						//console.log(msg);
						var ret_msg = JSON.parse(msg);
						if (ret_msg[0].result == 'false') {
							if (ret_msg[0].message) alert(ret_msg[0].message);
							if (ret_msg[0].path) sect.find('img').attr('src',ret_msg[0].path);
							inid.val('');
							return;
						} else {
							if (ret_msg[0].path) sect.find('img').attr('src',ret_msg[0].path);
						}
					});
					break;
				case "edUploadImg":
					var filelen = 0;
					if (inid[0].files[0]) filelen = inid[0].files[0].size;
					if (filelen > 0) {
						//console.log(inid[0].files[0]);
						var imgid = $(dform+' .'+fdname+((deri == '') ? '' : '_'+deri)+'_img'),
							lodid = $(dform+' .'+fdname+((deri == '') ? '' : '_'+deri)+'_load'),
							ueri = $(dform+' #'+fdname+'_ERI'+((deri == '') ? '' : '_'+deri)).val(),
							keyfd = $(dform+' #'+fdname+'_ERI'+((deri == '') ? '' : '_'+deri)).attr('keyfd');
						var fdata = new FormData();
						fdata.append('file', inid[0].files[0]);
						var url = path+'core/cw5e_engine_detail.php?sid='+sval+'&parent='+EncodeURLutf8(path)+'&act=imgupload';
						url += '&mode='+mode+'&ditem='+ditem+'&table='+table+'&fdname='+fdname+'&keyfd='+keyfd+'&ueri='+ueri;
						//console.log(url);
						$.ajax({
							url: url,
							type: 'POST',
							data: fdata,
							processData: false,
							contentType: false,
							beforeSend: function(){
								imgid.hide();lodid.show();
							},
							success: function(msg){
								//console.log(msg);
								var ret_msg = JSON.parse(msg);
								if (ret_msg[0].result == 'false') {
									imgid.show();lodid.hide();
									if (ret_msg[0].message) alert(ret_msg[0].message);
								} else {
									imgid.show();lodid.hide();
									imgid.find('img').attr('src',ret_msg[0].image);
								}
							}
						});
					}
					break;
				case "edImportBtn":
					var filelen = 0;
					if (inid[0].files[0]) filelen = inid[0].files[0].size;
					if (filelen > 0) {
						//console.log(inid[0].files[0]);
						$('#popup_close').show();
						$('#page_popup').popup();
						$('#page_popup').popup('open', { x: 0, y: 0 });
						mode_edImportBtn_exec(path, sval, mode, ditem, table, fdname, dform, deri, fow, inidval);
					} else {
						alert(return_language_str(path, sval, '', 'F_IMPORT_ER_FILE_EMPTY', ''));
					}
					break;
				case "edEnNormal":
					sect.val(tval);
					encrypt_text_change(path, sval, mode, ditem, fdname, deri, dform, fow);
					break;
				default:
					break;
			}
		} else if (gfid == "V") {
			var alcs = inid.attr("alcs");
			var tval = inid.val();
			switch (objt) {
				case "edComboList":
				case "edRadioGroup":
				case "edWebReplace":
					if ((tval) && 
						$(dform+" ."+alcs+"_spa").length > 0 && 
						$(dform+" ."+alcs+"_spa_"+tval).length > 0) {
						$(dform+" ."+alcs+"_spa").hide();
						$(dform+" ."+alcs+"_spa_"+tval).show();
					} else {
						console.log('edComboList error[1](input id does not exist)!');
						inid.val(defv);
					}
					break;
				case "edyymmEdit":
					if ((tval) && $(dform+" ."+alcs+"_span").length > 0) {
						if (htpe == "edDateEdit") {
							var dateArray = tval.split("/");
							switch (cust) {
								case "mmyy":
									var mmyy = (('0'+dateArray[1]).substr(-2, 2))+'/'+dateArray[0];
									$(dform+" ."+alcs+"_span").html(mmyy);
									break;
								case "yymm":
								default:
									var yymm = dateArray[0]+'/'+(('0'+dateArray[1]).substr(-2, 2));
									$(dform+" ."+alcs+"_span").html(yymm);
									break;
							}
						} else {
							$(dform+" ."+alcs+"_span").html(tval);
						}
					} else {
						console.log('edyymmEdit error[1](input id does not exist)!');
						inid.val(defv);
						$(dform+" ."+alcs+"_span").html(defv);
					}
					break;
				case "edYearEdit":
					if ((tval) && $(dform+" ."+alcs+"_span").length > 0) {
						if (htpe == "edDateEdit") {
							var dateArray = tval.split("/");
							$(dform+" ."+alcs+"_span").html(dateArray[0]);
						} else {
							$(dform+" ."+alcs+"_span").html(tval);
						}
					} else {
						console.log('edYearEdit error[1](input id does not exist)!');
						inid.val(defv);
						$(dform+" ."+alcs+"_span").html(defv);
					}
					break;
				case "edMonthEdit":
					if ((tval) && $(dform+" ."+alcs+"_span").length > 0) {
						if (htpe == "edDateEdit") {
							var dateArray = tval.split("/");
							$(dform+" ."+alcs+"_span").html((('0'+dateArray[1]).substr(-2, 2)));
						} else {
							$(dform+" ."+alcs+"_span").html(tval);
						}
					} else {
						console.log('edMonthEdit error[1](input id does not exist)!');
						inid.val(defv);
						$(dform+" ."+alcs+"_span").html(defv);
					}
					break;
				case "edTimeEdit":
					if ((tval) && $(dform+" ."+alcs+"_span").length > 0) {
						if (htpe == "edTimeEdit" || cust == "HHiiss") {
							$(dform+" ."+alcs+"_span").html(tval);
						} else {
							var dateArray = tval.split(":");
							$(dform+" ."+alcs+"_span").html(dateArray[0]+':'+dateArray[1]);
						}
					} else {
						console.log('edTimeEdit error[1](input id does not exist)!');
						if (htpe == "edTimeEdit" || cust == "HHiiss") {
							$(dform+" ."+alcs+"_span").html(defv);
						} else {
							var dateArray = defv.split(":");
							$(dform+" ."+alcs+"_span").html(dateArray[0]+':'+dateArray[1]);
						}
					}
					break;
				case "edEnNormal":
					$(dform+" ."+alcs+"_span").html('****');
					break;
				default:
					if ((tval) && $(dform+" ."+alcs+"_span").length > 0) {
						$(dform+" ."+alcs+"_span").html(tval);
					} else {
						console.log(objt+' error[1](input id does not exist)!');
						inid.val(defv);
						$(dform+" ."+alcs+"_span").html(defv);
					}
					break;
			}
		}
	}
}