/*  */
function detail_edit_open(path, sval, mode, dform, ERI, ditemstr) {
	//alert("編輯檢查");
	var user = navigator.userAgent;
    var system = "Other";
	var browser = "Other";
	
	//取得登入系統 
    if(user.match("Android")){
        system = "Android";
    }else if(user.match("iPhone") || user.match("iPad")){
        system = "IOS";
    }else{
		system = "PC";
	}
	
    //取得登入瀏覽器 
	//alert(user);
    if(user.match("Edg")){
        browser = "Edg";
    }else if(user.match("Chrome")){
        browser = "Chrome";
    }else if(user.match("Firefox")){
        browser = "Firefox";
    }else if(user.match("MSIE")){
        browser = "IE";
    }else if(user.match("Opera")){
        browser = "Opera";
    }else if(user.match("Safari")){
        browser = "Safari";
    }else if(user.match("Android")){
        browser = "Android";
    }else if(user.match("iPhone") || user.match("iPad")){
        browser = "IOS";
    }else{
		browser = "Other";
	}
	if (!!window.ActiveXObject || "ActiveXObject" in window){
		browser = "IE";
	}
	//alert(browser);

	// 編輯檢查 //CC控制 
	var zmode = mode;
	var zeri = ERI;
	var url = path+'core/cw5e_engine_detail.php?sid='+sval+'&parent='+EncodeURLutf8(path)+'&mode='+mode+'&act=editcheck&ERI='+ERI+'&system='+system+'&browser='+browser;
	url += '&zmode='+zmode+'&zeri='+zeri;
	var djson = (fromid_output_json(dform,'name')).replace(/'/g, "''");
	var verlen = djson.length;
	url += '&verlen='+verlen.toString();
	// 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") {
			alert(ret_msg[0].message);
			return false;
		} else {
			if ((ditemstr) && ditemstr != "") {
				var ditems = ditemstr.split(",");
				for (var i = 0; i < ditems.length; i++) {
					$(dform+" #edit_"+ditems[i]).val("");
				}
			}
			// 20140926: 變更作業項狀態為編輯狀態 
			$('#WEB_CURR_EDIT').val(1);$('#WEB_FOCS_NAME').val('');
			// Enable buttons
			if ((ret_msg[0].brout) && ret_msg[0].brout == "1") $("#btn_brout").prop("disabled", false);
			$("#btn_cancel").prop("disabled", false);
			$("#btn_save").prop("disabled", false);
			// Disable buttons
			$("#btn_new").prop("disabled", true);
			$("#btn_copy").prop("disabled", true);
			$("#btn_del").prop("disabled", true);
			$("#btn_edit").prop("disabled", true);
			$("#btn_return").prop("disabled", true);
			$("#btn_print").prop("disabled", true);
			$("#btn_scrut").prop("disabled", true);
			$("#btn_unscrut").prop("disabled", true);
			$("#btn_send").prop("disabled", true);
			$("#btn_invalid").prop("disabled", true);
			$("#btn_prev").prop("disabled", true);
			$("#btn_next").prop("disabled", true);
			$("#btn_first").prop("disabled", true);
			$("#btn_final").prop("disabled", true);
			$("#btn_prout").prop("disabled", true);
			// Enable text
			//$(dform+" :input").prop("disabled", false);
			$(dform).find('input,select,textarea').each(function(){
				if ($(this).is('input')) {
					if (($(this).attr('type')) && $(this).attr('type') != 'hidden') {
						$(this).prop('disabled', false);
					}
				} else $(this).prop('disabled', false);
				if (($(this).attr("objt")) && ($(this).attr("txta"))) {
					var txta = $(this).attr("txta"),
						tobj = $(this).attr("type"),
						objt = $(this).attr("objt");
					if (txta == "t" && tobj == "text") {
						$(this).prop("readonly", true);
					} else if (txta == "d" || txta == "t" || objt == "edProcBtn" || objt == "edExportBtn") {
						if (objt == "edComboList" || objt == "edCheckBox" || objt == "edRadioGroup" || 
							objt == "edyymmEdit" || objt == "edYearEdit" || objt == "edMonthEdit" || 
							objt == "edTimeEdit") {
							var alcs = $(this).attr("alcs");
							$("."+alcs).prop("disabled", true);
						} else if (tobj != "hidden") {
							$(this).prop("disabled", true);
						}
					}
					if (tobj == "hidden" && objt == "edCkEditor" && txta == "e") {
						var fld = $(this).attr("tid");
						if (fld) CKEDITOR.instances[fld].setReadOnly(false);
					}
					if (txta == "t" && objt != "edCkEditor") {
						$(this).prop("readonly", true);
					}
					if (txta == "d" && objt != "edCkEditor") {
						$(this).prop("disabled", true);
					}
				}
			});
			if (ret_msg[0].data) mode_valchange_action(ret_msg[0].data, dform);
			eval('if (typeof edit_after_'+mode+' == "function") edit_after_'+mode+'("'+sval+'");');
		}
	});
}