/*  */
function mode_procedure_detail(path, sval, mode, ditem, field, deri, dform, fow, ptype, mutp) {
	//if (confirm(return_language_str(path, sval, mode, 'CONFIRM_'+ditem+'_'+field, ''))) {
	loading_create('Y');
	var zmode = $('#SUB_MODE'+fow).val();
	var zdiv = '#detail_div_'+zmode+fow,zform = '#detail_form_'+zmode+fow,
		sdiv = '#sub_div_'+zmode+fow,sform = '#sub_form_'+zmode+fow;
	var sberis = $(sdiv+' #SUB_ERIPATH'+fow).val().split('/');
	var zeri = ($(zform+' #ERI').length > 0 && $(zform+' #ERI').val() != '') ? $(zform+' #ERI').val() : $(zform+' #TEMPERI').val();
	var meri = (mode == zmode) ? zeri : sberis[sberis.length-1];
	var ftype = ($('#SUB_MODE'+fow).val() == $('#SUB_SUBPATH'+fow).val()) ? 'D' : 'S';
	switch (mutp) {
		case 'R': mdir = 'manage'; break;
		case 'B':
		default: mdir = 'modules'; break;
	}
	var url = path+'core/cw5e_engine_detail.php?sid='+sval+'&parent='+EncodeURLutf8(path)+'&mode='+mode+'&ditem='+ditem+'&field='+field+'&deri='+deri+'&mutp='+mutp+'&act=exproc';
	url += '&fow='+fow+'&zmode='+zmode+'&zeri='+zeri+'&meri='+meri;
	//url += '&fow='+fow+'&ftype='+ftype+'&deri='+deri;
	var djson = (fromid_output_json(dform,'name')).replace(/'/g, "''");
	var verlen = djson.length,merr = '';
	url += '&verlen='+verlen.toString()+'&ptype='+ptype;
	//console.log(djson);
	//$.ajaxSetup({ async:false });
	$.post(url, 'htmljson='+EncodeURLutf8(djson), function(msg) {
		//console.log(msg);
		var ret_msg = JSON.parse(msg);
		if (ret_msg[0].result == 'false') {
			if (ret_msg[0].idstrs) {
				var strs = ret_msg[0].idstrs.split(','), stid = '';
				for (var i = 0 ; i < strs.length ; i++) {
					if (strs[i].substr(0,1) == '#' || strs[i].substr(0,1) == '.') {
						stid = strs[i];
					} else stid = '#'+strs[i];
					$(dform+' '+stid).css('background-color','#FF7744');
				}
			}
			if (ret_msg[0].message) {
				merr += ret_msg[0].message;
			}
			alert(merr);
			if ((ret_msg[0].iact) && (ret_msg[0].meri) &&
				(ret_msg[0].mtype) && (ret_msg[0].ldiv)) {
				if (ftype == 'D') {
					var url2 = path+mdir+'/'+mode+'/detail.php?sid='+sval+'&parent='+EncodeURLutf8(path)+'&mode='+mode+'&mutp='+mutp+'&act='+ret_msg[0].iact+'&ERI='+ret_msg[0].meri;
					var perm = "exec="+EncodeURLutf8($("#search_exec_"+ret_msg[0].mtype).val())+
							   "&qwe="+EncodeURLutf8($("#search_where_"+ret_msg[0].mtype).val())+
							   "&sor="+EncodeURLutf8($("#search_order_"+ret_msg[0].mtype).val())+
							   "&itms="+EncodeURLutf8($("#detail_items_"+ret_msg[0].mtype).val());
					post_redirect(ret_msg[0].ldiv, perm, url2);
				} else if (ftype == 'S') {
					var subphs = $('#SUB_SUBPATH'+fow).val().split('/'),
						suberis = $('#SUB_ERIPATH'+fow).val().split('/');
					var spnum = subphs.length;
					create_sub_detail(path, sval, subphs[spnum-1], suberis[spnum-1], fow, 'load', '', '');
				}
			}
			loading_close('');
			return false;
		} else {
			if ((ret_msg[0].iact) && (ret_msg[0].meri) &&
				(ret_msg[0].mtype) && (ret_msg[0].ldiv)) {
				if (ftype == 'D') {
					var url2 = path+mdir+'/'+mode+'/detail.php?sid='+sval+'&parent='+EncodeURLutf8(path)+'&mode='+mode+'&mutp='+mutp+'&act='+ret_msg[0].iact+'&ERI='+ret_msg[0].meri;
					var perm = "exec="+EncodeURLutf8($("#search_exec_"+ret_msg[0].mtype).val())+
							   "&qwe="+EncodeURLutf8($("#search_where_"+ret_msg[0].mtype).val())+
							   "&sor="+EncodeURLutf8($("#search_order_"+ret_msg[0].mtype).val())+
							   "&itms="+EncodeURLutf8($("#detail_items_"+ret_msg[0].mtype).val());
					post_redirect(ret_msg[0].ldiv, perm, url2);
				} else if (ftype == 'S') {
					var subphs = $('#SUB_SUBPATH'+fow).val().split('/'),
						suberis = $('#SUB_ERIPATH'+fow).val().split('/');
					var spnum = subphs.length;
					create_sub_detail(path, sval, subphs[spnum-1], suberis[spnum-1], fow, 'load', '', '');
				}
			}
			if (ret_msg[0].message) alert(ret_msg[0].message);
			else alert(return_language_str(path, sval, mode, ditem+'_'+field+'_COMPLETE', ''));
			loading_close('');
		}
	});
	//$.ajaxSetup({ async:true });
	//}
}