/*  */
function modesub_return_detail(path, sval, ltype, txsat, subtp, zmode, zeri, sfield, meri, fow) {
	var ddiv = '#detail_div_'+zmode+fow,dform = '#detail_form_'+zmode+fow,
		sdiv = '#sub_div_'+zmode+fow,sform = '#sub_form_'+zmode+fow;
	if (txsat == '0' || (txsat == '1' && subtp == 'Y')) {
		if (ltype == 'D') {
			modesub_dback_detail(path, sval, zmode, fow);
		} else {
			var subphs = $(sdiv+' #SUB_SUBPATH'+fow).val().split('/'),
				tpages = $(sdiv+' #SUB_PAGPATH'+fow).val().split('/'),
				sberis = $(sdiv+' #SUB_ERIPATH'+fow).val().split('/');
			subphs.pop();tpages.pop();sberis.pop();
			$(sdiv+' #SUB_SUBPATH'+fow).val(subphs.join('/'));
			$(sdiv+' #SUB_PAGPATH'+fow).val(tpages.join('/'));
			$(sdiv+' #SUB_ERIPATH'+fow).val(sberis.join('/'));
			create_sub_detail(path, sval, subphs[subphs.length-1], sberis[sberis.length-1], fow, 'rtn', subphs[subphs.length-2], tpages[tpages.length-1]);
		}
	} else if (txsat == '1') {
		var fdata = new FormData(),merr = '',
			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=subcheck';
		$.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') {
					if (ret_msg.idstrs) {
						var strs = ret_msg.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];
							$(sform+' '+stid).css('background-color','#FF7744');
						}
					}
					if (ret_msg.message) {
						merr += ret_msg.message;
					}
					alert(merr);
					return false;
				} else {
					if (ltype == 'D') {
						modesub_dback_detail(path, sval, zmode, fow);
					} else {
						var subphs = $(sdiv+' #SUB_SUBPATH'+fow).val().split('/'),
							tpages = $(sdiv+' #SUB_PAGPATH'+fow).val().split('/'),
							sberis = $(sdiv+' #SUB_ERIPATH'+fow).val().split('/');
						subphs.pop();tpages.pop();sberis.pop();
						$(sdiv+' #SUB_SUBPATH'+fow).val(subphs.join('/'));
						$(sdiv+' #SUB_PAGPATH'+fow).val(tpages.join('/'));
						$(sdiv+' #SUB_ERIPATH'+fow).val(sberis.join('/'));
						create_sub_detail(path, sval, subphs[subphs.length-1], sberis[sberis.length-1], fow, 'rtn', subphs[subphs.length-2], tpages[tpages.length-1]);
					}
				}
			},
			error: function(msg){
				// 失敗後執行 
				console.log(msg);
			},
			complete: function(msg){
				// 完成後執行 
				// console.log(msg);
			}
		});
	}
}