/*  */
function mode_relation_field(path, sval, mode, ditem, field, bform, deri, fow, inpt) {
	var txat = (($(bform+' #edit_'+ditem).length > 0 && $(bform+' #edit_'+ditem).val() == '') ? 'edit' : 'view'),
		zmode = $('#SUB_MODE'+fow).val(),
		djson = (fromid_output_json(bform,'name')).replace(/'/g, "''"),
		type = ($('#SUB_MODE'+fow).val() == $('#SUB_SUBPATH'+fow).val()) ? 'D' : 'S';
	var ddiv = '#detail_div_'+zmode+fow,dform = '#detail_form_'+zmode+fow,
		sdiv = '#sub_div_'+zmode+fow,sform = '#sub_form_'+zmode+fow;
	var sberis = $(sdiv+' #SUB_ERIPATH'+fow).val().split('/');
	var zeri = ($(dform+' #ERI').length > 0 && $(dform+' #ERI').val() != '') ? $(dform+' #ERI').val() : $(dform+' #TEMPERI').val();
	var meri = (mode == zmode) ? zeri : sberis[sberis.length-1];
	var url = path+'core/cw5e_engine_detail.php?sid='+sval+'&parent='+EncodeURLutf8(path)+'&mode='+mode+'&ditem='+ditem+
			  '&act=rela&field='+field+'&deri='+deri+'&txat='+txat+'&zmode='+zmode+'&zeri='+zeri+'&meri='+meri+'&fow='+fow+
			  '&inpt='+inpt+'&dform='+EncodeURLutf8(bform)+'&verlen='+(djson.length).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 {
			if (ret_msg[0].data) mode_valchange_action(ret_msg[0].data, bform);
		}
	});
}