/*  */
function create_sub_detail(path, sval, field, seri, fow, stat, mode, ditem) {
	var fdata = new FormData(),zmode = $('#SUB_MODE'+fow).val();
	var ddiv = '#detail_div_'+zmode+fow,dform = '#detail_form_'+zmode+fow,
		sdiv = '#sub_div_'+zmode+fow,sform = '#sub_form_'+zmode+fow;
	var subph = $(sdiv+' #SUB_SUBPATH'+fow).val(),tpage = $(sdiv+' #SUB_PAGPATH'+fow).val(),
		sberi = $(sdiv+' #SUB_ERIPATH'+fow).val();
	var subphs = subph.split('/'),tpages = tpage.split('/'),sberis = sberi.split('/');
	var mjson = (fromid_output_json(dform,'name')).replace(/'/g, "''"),
		sjson = (fromid_output_json(sform,'name')).replace(/'/g, "''"),
		smode = (stat == 'view') ? mode : subphs[subphs.length-2],
		sditem = (stat == 'view') ? ditem : tpages[tpages.length-1],
		type = ((stat == 'view' && zmode == subph) || 
				(stat != 'view' && subphs.length == 2)) ? 'D' : 'S',
		txsat = ($('#WEB_CURR_EDIT').val() == '1' && fow != 'L') ? '1' : '0';
	fdata.append('mjson', mjson);fdata.append('sjson', sjson);
	var url = path+'core/cw5e_engine_sub.php?sid='+sval+'&parent='+EncodeURLutf8(path)+
			  '&mode='+field+'&sfield='+field+'&seri='+seri+'&fow='+fow+'&stat='+stat+
			  '&smode='+smode+'&sditem='+sditem+'&zmode='+zmode+'&type='+type+
			  '&mvlen='+(mjson.length).toString()+'&svlen='+(sjson.length).toString()+
			  '&txsat='+txsat+'&act=ctsub';
	// console.log(url+'|'+mjson+'|'+sjson);
	$.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 (type == 'D') {
					$(ddiv).hide();$(sdiv).show();
				}
				if (stat == 'view') {
					$(sdiv+' #SUB_SUBPATH'+fow).val(subph+'/'+field);
					$(sdiv+' #SUB_PAGPATH'+fow).val(tpage+'/'+ditem);
					$(sdiv+' #SUB_ERIPATH'+fow).val(sberi+'/'+seri);
				}
				if (ret_msg.class_str) {
					if (stat == 'view' && type == 'S' && 
						$('#'+mode+'_style_class').length > 0) $('#'+mode+'_style_class').remove();
					if (stat != 'view' && 
						$('#'+field+'_style_class').length > 0) $('#'+field+'_style_class').remove();
					$('#'+zmode+'_style_class').after(ret_msg.class_str);
				}
				if (ret_msg.html_str) {
					$(sform).empty().append(ret_msg.html_str);
					mode_enableck_control(path,sval,field,'view',sform,'','',seri,fow);
				}
			}
		},
		error: function(msg){
			// 失敗後執行 
			console.log(msg);
		},
		complete: function(msg){
			// 完成後執行 
			// console.log(msg);
		}
	});
}