/*  */
function modedb_lisave_detail(path, sval, mode, ditem, table, fow, eri, iid) {
	var loary = JSON.parse(return_language_str(path, sval, mode, '', ''));
	setTimeout(function(){
		var zmode = $('#SUB_MODE'+fow).val(),subph = $('#SUB_SUBPATH'+fow).val();
		var dform = '#detail_form_'+zmode+fow;
		var type = ((zmode == subph) ? 'D' : 'S'), eid = iid.closest('tr'), lentp = false;
		eid.find('td input').each(function(){
			var tid = $(this);
			if (tid.attr('type') == 'button') return;
			tid.css('background-color','#FFFFFF');
			if ((tid.attr('htpe')) && tid.attr('htpe') == 'edNormal' && 
				(tid.attr('fdsize')) && parseInt(tid.attr('fdsize')) < tid.val().length) {
				lentp = true;
				tid.css('background-color', '#FF7744');
			}
		});
		eid.find('td textarea').each(function(){
			var tid = $(this);
			tid.css('background-color','#FFFFFF');
			if ((tid.attr('htpe')) && tid.attr('htpe') == 'edNormal' && 
				(tid.attr('fdsize')) && parseInt(tid.attr('fdsize')) < tid.val().length) {
				lentp = true;
				tid.css('background-color', '#FF7744');
			}
		});
		eid.find('td select').each(function(){
			var tid = $(this);
			tid.css('background-color','#FFFFFF');
		});
		if (lentp) {
			alert((loary['ERROR_FIELD_OUT_LENGTH']) ? loary['ERROR_FIELD_OUT_LENGTH'] : 'ERROR_FIELD_OUT_LENGTH');
			return false;
		}
		var url = path+'core/cw5e_engine_detail.php?sid='+sval+'&parent='+EncodeURLutf8(path)+'&mode='+mode+'&ditem='+ditem+'&table='+table+'&fow='+fow+'&type='+type+'&ERI='+eri+'&act=dblisave';
		url += '&dbtyp='+EncodeURLutf8($('#'+ditem+'_db_list #dblt_type_'+ditem).val())+
			   '&meri='+EncodeURLutf8($(dform+' #ERI').val())+
			   '&teri='+EncodeURLutf8($(dform+' #TEMPERI').val())+
			   '&zmode='+zmode;
		var djson = (fromid_output_json(eid)).replace(/'/g, "''");
		var verlen = djson.length;
		url += '&verlen='+verlen.toString();
		$.post(url, 'htmljson='+EncodeURLutf8(djson), function(msg) {
			// console.log(msg);
			var ret_msg = JSON.parse(msg);
			if (ret_msg[0].result == "false") {
				alert(ret_msg[0].message);
				return false;
			} else {
				$('#'+ditem+'_db_list #dblt_type_'+ditem).val('E');
				if (ret_msg[0].eri) {
					modedb_edload_detail(path, sval, mode, ditem, fow, ret_msg[0].eri, iid);
				}
			}
		});
	}, 500);
}