/*  */
function modesub_edit_detail(path, sval, ltype, zmode, zeri, sfield, meri, fow, ditemstr) {
	var ddiv = '#detail_div_'+zmode+fow,dform = '#detail_form_'+zmode+fow,
		sdiv = '#sub_div_'+zmode+fow,sform = '#sub_form_'+zmode+fow;
	var fdata = new FormData(),
		mjson = (fromid_output_json(dform,'name')).replace(/'/g, "''"),
		sjson = (fromid_output_json(sform,'name')).replace(/'/g, "''");
	fdata.append('mjson', mjson);fdata.append('sjson', sjson);
	var url = path+'core/cw5e_engine_sub.php?sid='+sval+'&parent='+EncodeURLutf8(path)+
			  '&zmode='+zmode+'&zeri='+zeri+'&sfield='+sfield+'&meri='+meri+'&ltype='+ltype+
			  '&mvlen='+(mjson.length).toString()+'&svlen='+(sjson.length).toString()+
			  '&act=subeditck';
	$.ajax({
		type: 'post',
		url: url,
		data: fdata,
		processData: false,
		contentType: false,
		beforeSend: function(){
			// 開始前執行 
		},
		success: function(msg){
			// 成功後執行 
			// console.log(msg);
			var ret_msg = JSON.parse(msg);
			if (ret_msg.result == 'false') {
				alert(ret_msg.message);
				return false;
			} else {
				if ((ditemstr) && ditemstr != '') {
					var ditems = ditemstr.split(',');
					for (var i = 0; i < ditems.length; i++) {
						$(sform+' #edit_'+ditems[i]).val('');
					}
				}
				// Enable text
				//$(sform+' :input').prop('disabled', false);
				$(sform).find('input,select,textarea').each(function(){
					if ($(this).is('input')) {
						if (($(this).attr('type')) && $(this).attr('type') != 'hidden') {
							$(this).prop('disabled', false);
						}
					} else $(this).prop('disabled', false);
					if (($(this).attr('objt')) && ($(this).attr('txta'))) {
						var txta = $(this).attr('txta');
						var tobj = $(this).attr('type');
						var objt = $(this).attr('objt');
						if (txta == 't' && tobj == 'text') {
							$(this).prop('readonly', true);
						} else if (txta == 'd' || txta == 't' || objt == 'edProcBtn' || objt == 'edExportBtn') {
							if (objt == 'edComboList' || objt == 'edCheckBox' || objt == 'edRadioGroup' || 
								objt == 'edyymmEdit' || objt == 'edYearEdit' || objt == 'edMonthEdit' || 
								objt == 'edTimeEdit') {
								var alcs = $(this).attr('alcs');
								$('.'+alcs).prop('disabled', true);
							} else if (tobj != 'hidden') {
								$(this).prop('disabled', true);
							}
						}
						if (tobj == 'button' && objt == 'edSubBtn') {
							$(this).prop('disabled', true);
						}
						if (tobj == 'hidden' && objt == 'edCkEditor' && txta == 'e') {
							var fld = $(this).attr('tid');
							if (fld) CKEDITOR.instances[fld].setReadOnly(false);
						}
						if (txta == 't' && objt != 'edCkEditor') {
							$(this).prop('readonly', true);
						}
						if (txta == 'd' && objt != 'edCkEditor') {
							$(this).prop('disabled', true);
						}
					}
				});
				$(sform+' #btn_sedit').prop('disabled', true);
				$(sform+' #btn_sreturn').prop('disabled', true);
				if (ret_msg.data) mode_valchange_action(ret_msg.data, sform);
				eval('if (typeof edit_after_'+sfield+' == "function") edit_after_'+sfield+'("'+sval+'");');
			}
		},
		error: function(msg){
			// 失敗後執行 
			console.log(msg);
		},
		complete: function(msg){
			// 完成後執行 
			// console.log(msg);
		}
	});
}