var blg=true;

$(document).ready(function(){
	$("#dpa").unbind();
	if($(".pageFrom").val()!=2&&$(".imgFlag").val()==1){
		var claimNo = $(".inspectionClaimNo").val();
		var isBpo =  $("#isBpo").val();
		if("1"==$("#caseSource").val() && isBpo == "Y"){
			callEcm(claimNo,"");
		}else{
			window.open('../clmtask/imageInfo.do?claimNo='+claimNo,"影像");
		}
		
	}
	//当页面载入完成时获取所有省级地区
	 $.ajax({
			
		 type:"POST",
		 url:"../../dataenter/getProvince.do",
		 data:"",
		 error:function(){
			 alert("获取省份失败");
			 return;
		 },
		 success:function(data){
			 for(var i=0;i<data.length;i++){
				 var province = data[i];
				 $("#provinceContext").append("<li id="+province.areaCode+" onclick=\"getProvinceCode(this)\">"+province.areaName+"</li>");
				 $("#provinceContextcenter").append("<li id="+province.areaCode+" onclick=\"getProvinceCode(this)\">"+province.areaName+"</li>");
			 }
			 $(".select").find(".sel_list li").hover( function (){
					$(this).addClass("sel_hov");		
				},function (){
					$(this).removeClass("sel_hov");	
				}).on('click',function(){
					var _this = $(this).html();
					
					var _thisText = $(this).closest(".select").find(".sel_text");
					_thisText.html(_this);
					
				});
		 }
		 
	 });
	 
	$(".doneAllInfo").click(function(){
		if($(".pageFrom").val()!=2){
			doneAllInfo();
		}
		
		//“索赔事故性质”是否已删除或修改
/*		var changed = $("#changed").val();
		if(changed=="changed"){
			if(!confirm("索赔事故性质已更改，是否继续？"))
				return;
		}*/
		if($(".pageFrom").val()==2){
			if($("#accidentCode").val()!=$("#accidentCodeOld").val()||$("#accidentDate").val()!=$("#accidentDateOld").val()||$("#accTypesBy_").val()!=$("#accTypesBy_Old").val()||$("#changed").val() !=""){
				if(confirm("是否确认修改出险类型、出险日期或索赔事故性质？")){
					accidentFlag = 2;
					doneAllInfo(accidentFlag);
			    }
			}else{
				doneAllInfo();
			}
		}
	});
});
function selectZhijianType(flag){
	
	$(flag).attr("value")=='1'?$(flag).val("0"):$(flag).val("1");
}
/**非自动件check事件**/
function pickClaimType(obj){
	$(obj).attr('value') == "4" ? $(obj).attr('value',"5") : $(obj).attr('value',"4");
}

function selectIsMail(flag){
	$(flag).val()=='Y'?$(flag).val('N'):$(flag).val('Y');
}
//根据所选省份获取市
function findCity(provinceCode){
	
	 $("#citySpan").html("请选择市");
	 $("#cityContext").html("");
	 $("#citySpancenter").html("请选择市");
	 $("#cityContextcenter").html("");
	 $.ajax({
		 
		 type:"POST",
		 url:"../../dataenter/findCity.do",
		 data:{"provinceCode":provinceCode},
		 error:function(){
			 alert("获取市级单位失败");
			 return;
		 },
		 success:function(data){
			 for(var i=0;i<data.length;i++){
				 var city = data[i];
				 $("#cityContext").append("<li id=\""+city.areaCode+"\" onclick=\"getCityCode(this)\">"+city.areaName+"</li>");
				 $("#cityContextcenter").append("<li id=\""+city.areaCode+"\" onclick=\"getCityCode(this)\">"+city.areaName+"</li>");
			 }
			 //选中
			 $(".select").find(".sel_list li").hover( function (){
					$(this).addClass("sel_hov");		
				},function (){
					$(this).removeClass("sel_hov");	
				}).on('click',function(){
					var _this = $(this).html();
					
					var _thisText = $(this).closest(".select").find(".sel_text");
					_thisText.html(_this);
					
				});
		 }
		 
	 });
}
//获取所选省份
var provinceName = null;
var provinceCode = null;
function getProvinceCode(obj){
	 

	 provinceCode = obj.id;
	 $("#hosCityCode").val("");
	 $("#hosProvince").val(provinceCode);
	 $("#hosCityCodecenter").val("");
	 $("#hosProvincecenter").val(provinceCode);
	 provinceName = obj.innerHTML;
	 findCity(provinceCode);
}

//获取所选市的代码
var cityCode = null;
function getCityCode(obj){
	 cityCode = obj.id;
	 $("#hosCityCode").val(cityCode);
	 $("#hosCityCodecenter").val(cityCode);
}

/**
 * 跳转humanaudit
 */
function humanaudit(){
	
	var claimNo = $(".inspectionClaimNo").val();
	SkipByPost($("#contentPath").attr("content")+"humanaudit/humanAuditMain.do",{"claimNo":claimNo});
}
/**
 * 点击更多加载所有保单
 */
function bpolicy(){
	var claimNo = $(".inspectionClaimNo").val();
	/*SkipByPost($("#contentPath").attr("content")+"inspection/clmtask/inspectionClmInfo.do",{"claimNo":claimNo,"flag":"ALL"});*/

	$.ajax({
		type:"post",
		url:"queryAllPolicy.do",
		data:{"claimNo":claimNo},
		error:function(){
			alert("获取失败!");
		},
		success:function(list){
			var claimNo=$("#taskClaimNo").val();
			var pid=$("#clmCusPid").val();
			var html="";
			html+="<tr>"+
            		"<th>保单号</th>"+
            		"<th>险种名称</th>"+
            		"<th>保险期间</th>"+
            		"<th>保单状态</th>"+
            		"<th>投保人</th>"+
            		"<th>保单来源</th>"+
            	  "</tr>";
			if(list!=null){
			
			for(var i=0;i<list.length;i++){
				var xzmc=list[i].xzmc;
				if(list[i].zxbz=="1"){
					xzmc+="<span class='icon_tab_tip'></span>";
				}
				var policyNo="";
				var clamTaskClaimState=$("#clamTaskClaimState").val();
				if(clamTaskClaimState=="03"){
					policyNo+='<a href="javascript:policyInspectionInfoquery('+"'"+list[i].policyNo+"','"+
					claimNo+"','"+pid+"','"+list[i].classcode+"','"+list[i].policyInterSource+"','"+
					list[i].sGrpattr+"','"+list[i].branchid+"','"+list[i].familyFlag+"'"+')">'+list[i].policyNo +'</a>';
					}else{
					policyNo+='<a href="javascript:policyInfoquery('+"'"+list[i].policyNo+"','"+
					claimNo+"','"+pid+"','"+list[i].classcode+"','"+list[i].policyInterSource+"','"+
					list[i].sGrpattr+"','"+list[i].branchid+"','"+list[i].familyFlag+"'"+')">'+list[i].policyNo +'</a>';



				}
				if(list[i].appSource=="0"){
					policyNo+="<b class='sild_icon_sz'>寿</b>";
				}else if(list[i].appSource=="1"){
					policyNo+="<b class='sild_icon_sz'>贴</b>";
				}else if(list[i].appSource=="2"){
					
				}else if(list[i].appSource=="3"){
					policyNo+="<b class='sild_icon_sz'>贴</b>";
				}
				if(list[i].familyFlag=="1"){
					policyNo+="<b class='sild_icon_sz'>家</b>";
				}
				var policySource=list[i].policySource;
				if(policySource==null){
					policySource="";
				}
				html+="<tr>"+
        				"<td>"+policyNo+"</td>"+
        				"<td>"+xzmc+"</td>"+
        				"<td>"+list[i].bdqj+"</td>"+
        				"<td>"+list[i].policyState+"</td>"+
        				"<td>"+list[i].tbrName+"</td>"+
        				"<td>"+policySource+"</td>"+
        			  "</tr>";
				
				
			}
			}
			$("#table_bpolicy").html(html);
			showDiv("bpolicy");
		}
	
	});




}
/**
 * 跳转我的质检任务池
 */
function queryMyTask(claimNo){
	 SkipByPost("myClaimStateAndCurrentOperater.do",{claimNo:claimNo});
}

/**
 * 跳转保单详情页面
 * @param policyNo
 * @param claimNo
 * @param pid
 * @param classcode
 */
function policyInfoquery(policyNo,claimNo,pid,classcode,policyInterSource,sGrpattr,branchid,familyFlag){
	SkipByPost("policyInfo.do",{policyNo:policyNo,claimNo:claimNo,pid:pid,classcode:classcode,policyInterSource:policyInterSource,sGrpattr:sGrpattr,branchid:branchid,pageFrom:2,familyFlag:familyFlag});
	
}
function policyInspectionInfoquery(policyNo,claimNo,pid,classcode,policyInterSource,sGrpattr,branchid,familyFlag){
	SkipByPost("policyInfo.do",{policyNo:policyNo,claimNo:claimNo,pid:pid,classcode:classcode,policyInterSource:policyInterSource,sGrpattr:sGrpattr,branchid:branchid,pageFrom:'',familyFlag:familyFlag});
}
function dispatcherEventPage(eventNo){
	if(eventNo!=""){
		$("#eventNo").val(eventNo);
	}
	$("#pageFrom").val($(".pageFrom").val());
	$("#dispatchEventPage").attr("action","dispatcherEventPage.do");
	$("#dispatchEventPage").submit();
	
}

function operAllInfo(accidentFlag,isToOutSysReport){
	/**claimType**/
	var claimType = $("#auto").attr("value");
	if(claimType==null|| claimType=="" ||claimType==undefined ||claimType=="undefined"){
		claimType="";
	}	
	//被保人信息
	var lifeReportNo = $("#clamlIfeReportNo").val();
	var clamTaskClaimState = $("#clamTaskClaimState").val();
	var taskCaseSource = $("#taskCaseSource").val();
	if((lifeReportNo==null||lifeReportNo=="") && clamTaskClaimState=="03" && taskCaseSource != '3'){
		if((lifeReportNo==null||lifeReportNo=="") && taskCaseSource != '3'){
			if($.trim($("#customerInfoName").val())==""||$.trim($("#customerInfoName").val())==null){
				alert("请填写被保人姓名。");
				return;
			}
			if($.trim($("#customerInfoSex").attr("code"))==""||$.trim($("#customerInfoSex").attr("code"))==null){
				alert("请填写被保人性别。");
				return;
			}
			if($.trim($("#customerInfoIdtype").attr("code"))==""||$.trim($("#customerInfoIdtype").attr("code"))==null){
				alert("请填写被保人证件类型。");
				return;
			}
			if($.trim($("#customerInfoPid").val())==""||$.trim($("#customerInfoPid").val())==null){
				alert("请填写被保人证件号。");
				return;
			}
		}
	}
	//修改被保险人信息
	var customerInfoPid = $.trim($("#customerInfoPid").val());
	var customerInfoName =$.trim($("#customerInfoName").val());
	var customerInfoIdtype = $.trim($('#customerInfoIdtype').attr('code'));
	var customerInfoSex = $.trim($("#customerInfoSex").attr('code'));
	var customerInfoPhone = $.trim($("#customerInfoPhone").val());
	var customerInfoFtele = $.trim($("#customerInfoFtele").val());
	var customerInfoFaddr = $.trim($("#customerInfoFaddr").val());
	var customerInfoFzip = $.trim($("#customerInfoFzip").val());
	var customerInfoEmail = $.trim($("#customerInfoEmail").val());
	
	
	//报案人信息
	var claimNo =$.trim($("#claimNo").val());
	var reportDate = $.trim($("#reportDate").val());
	var repInsRelationship = $("#divrepInsRelationship_code").val();
	if(repInsRelationship!=undefined&&repInsRelationship!="")
	$("#repInsRelationship").val(repInsRelationship);
	var idtype = $.trim($("#dividtype_code").val());
	if(idtype!=undefined&&idtype!="")
	$("#idtype").val(idtype); 
	var pid = $.trim($("#pid").val());
	var pname = $.trim($("#pname").val());
	var sex = $.trim($("#divsex_code").val());
	if(sex!=undefined&&sex!="")
	$("#sex").val(sex); 
	var phone = $.trim($("#phone").val());
	var tel = $("#tel").val();
	var contractAddr = $.trim($("#contractAddr").val());
	var postCode = $.trim($("#postCode").val());
	var email = $.trim($("#email").val());
	//申请人信息
	var sqrappInsRelationship = $("#divSqrappInsRelationship_code").val();
	if(sqrappInsRelationship!=undefined&&sqrappInsRelationship!=""){
		$("#sqrappInsRelationship").val(sqrappInsRelationship);
	}
	var sqridtype = $.trim($("#divSqridtype_code").val());
	if(sqridtype!=undefined&&sqridtype!="")
	$("#sqridtype").val(sqridtype); 
	var sqr_pid = $.trim($("#sqr_pid").val());
	var sqr_pname = $.trim($("#sqr_pname").val()); 
	var sqrsex =$.trim( $("#divSqrsex_code").val());
	if(sqrsex!=undefined&&sqrsex!="")
	$("#sqrsex").val(sqrsex);
	var sqr_phone = $.trim($("#sqr_phone").val());
	var sqr_tel = $.trim($("#sqr_tel").val());
	var sqr_contractAddr = $.trim($("#sqr_contractAddr").val());
	var sqr_email = $.trim($("#sqr_email").val());
	var sqr_postCode = $.trim($("#sqr_postCode").val());
	//出险信息
	var accidentDate = $("#accidentDate").val();
	var firstDiagnoseDate = $("#firstDiagnoseDate").val();
	var claimDate = $("#claimDate").val();
	var accidentaddrtype = $("#divaccidentaddrtype_code").val();
	if(accidentaddrtype!=undefined&&accidentaddrtype!="")
		$("#accidentaddrtype").val(accidentaddrtype);
	var claimIllsBy_ = $("#claimIllsBy_").val();
	var accidentDesc = reg($("#accidentDesc").val());
	var accTypesBy_ = $("#accTypesBy_").val();
	
	//原来的字段
	var claimNoOld =$.trim($("#claimNoOld").val());
	var reportDateOld = $.trim($("#reportDateOld").val());
	var repInsRelationshipOld = $("#repInsRelationshipOld").val();
	var idtypeOld = $.trim($("#idtypeOld").val());
	var pidOld = $.trim($("#pidOld").val());
	var pnameOld = $.trim($("#pnameOld").val());
	var sexOld = $.trim($("#sexOld").val());
	var phoneOld = $.trim($("#phoneOld").val());
	var telOld = $("#telOld").val();
	var contractAddrOld = $.trim($("#contractAddrOld").val());
	var postCodeOld = $.trim($("#postCodeOld").val());
	var emailOld = $.trim($("#emailOld").val());
	//申请人信息
	var sqrappInsRelationshipOld = $("#sqrappInsRelationshipOld").val();
	var sqridtypeOld = $.trim($("#sqridtypeOld").val());
	var sqr_pidOld = $.trim($("#sqr_pidOld").val());
	var sqr_pnameOld = $.trim($("#sqr_pnameOld").val()); 
	var sqrsexOld =$.trim( $("#sqrsexOld").val());
	var sqr_phoneOld = $.trim($("#sqr_phoneOld").val());
	var sqr_telOld = $.trim($("#sqr_telOld").val());
	var sqr_contractAddrOld = $.trim($("#sqr_contractAddrOld").val());
	var sqr_emailOld = $.trim($("#sqr_emailOld").val());
	var sqr_postCodeOld = $.trim($("#sqr_postCodeOld").val());
	//出险信息
	var accidentDateOld = $("#accidentDateOld").val();
	var firstDiagnoseDateOld = $("#firstDiagnoseDateOld").val();
	var claimDateOld = $("#claimDateOld").val();
	var accidentaddrtypeOld = $("#accidentaddrtypeOld").val();
	var claimIllsBy_Old = $("#claimIllsBy_Old").val();
	var accidentCodeOld = $("#accidentCodeOld").val();
	var accTypesBy_Old = $("#accTypesBy_Old").val();
	var accidentDescOld = reg($("#accidentDescOld").val());
	
	//报案不成功修改出险人信息

	var customerInfoName  = $.trim($("#customerInfoName").val());   
	var customerInfoSex   = $.trim($("#customerInfoSex").attr("code"));
	var customerInfoIdtype= $.trim($("#customerInfoIdtype").attr("code"));
	var customerInfoPid   = $.trim($("#customerInfoPid").val());
	var customerno        = $.trim($("#customerno").val());
	
	if(lifeReportNo !=null && lifeReportNo !=""){
		customerInfoName = $.trim($("#customerInfoName").html());
		customerInfoPid   = $.trim($("#customerInfoPid").html());
	}
	
	var isAppInsruedSame = null;
	var isAppRepSame = null;
	var isAppInsruedSameCheck = $("#check_sqrBbr").attr("class");
	var isAppRepSameCheck = $("#check_sqrBar").attr("class");
	
	if(isAppInsruedSameCheck == "check_yes"){
		isAppInsruedSame = "Y";
	}else{
		isAppInsruedSame = "N";
	}
	
	if(isAppRepSameCheck == "check_yes"){
		isAppRepSame = "Y";
	}else{
		isAppRepSame = "N";
	}
	

	
	if(accidentFlag==undefined){
		accidentFlag = "";
	}
	if(isToOutSysReport==undefined){
		isToOutSysReport = "";
	}
	var isError;
	
	var isBpo = $("#isBpo").val();
	
	if(isBpo=="Y"){
		if($("#isErrorVal").is(".check_yes")){
			isError = "Y";
		}else{
			isError = "N";
			
		}
	}
	var isQuest=$("#quest").attr("value");
	
	var is_mail="";
	if($("#is_mail").hasClass("check_yes")){
		is_mail = "Y";
	}else if($("#is_mail").hasClass("check_no")){
		is_mail = "N";
	}
	
	if($("#humanReviewCause").val()!=undefined&&$("#humanReviewCause").val().length>200){
		alert("人工审核原因超出200个字数范围。");
		return;
	}
	
	//小额审核
	var isnoaudit = "";
	var humanReviewCause ="";
	if($("#humanReview").hasClass("check_no")){
		isnoaudit = "2";
	}else if($("#humanReview").hasClass("check_yes")){
		isnoaudit = "1";
	}
	humanReviewCause = $.trim($("#humanReviewCause").val());
	
	
	
	var jsonStr= '{"claimNo":"' + claimNo + '","reportDate":"' + reportDate+ '","repInsRelationship":"' + $("#repInsRelationship").val()  + 
	'","idtype":"' + $("#idtype").val()  +'","pid":"' + pid  +'","pname":"' + pname  +'","sex":"' + $("#sex").val()  +'","phone":"' + phone  +'","tel":"' + tel  +
	'","contractAddr":"' + contractAddr  +'","postCode":"' + postCode  +'","email":"' + email  +
	'","sqrappInsRelationship":"' + $("#sqrappInsRelationship").val()  +'","sqridtype":"' + $("#sqridtype").val()  +'","sqr_pid":"' + sqr_pid +
	'","sqr_pname":"' + sqr_pname  +'","sqrsex":"' + $("#sqrsex").val()  +'","sqr_phone":"' + sqr_phone +
	'","sqr_tel":"' + sqr_tel  +'","sqr_contractAddr":"' + sqr_contractAddr +'","claimIllsBy_":"' + $("#claimIllsBy_").val()+
	'","sqr_email":"' + sqr_email  +'","sqr_postCode":"' + sqr_postCode +'","sqrApplicantId":"' + $("#sqrPersonId").val() +
	'","accTypesBy_":"' + $("#accTypesBy_").val()  +'","accidentDate":"' + accidentDate  +'","firstDiagnoseDate":"' + firstDiagnoseDate+'","claimDate":"'+ claimDate +'","accidentAddrType":"' + $("#accidentaddrtype").val()  +
	'","claimIllsBy_":"' + claimIllsBy_ +'","accidentCode":"' + $("#accidentCode").val() +'","accTypesBy_":"' + accTypesBy_ +'","accidentDesc":"' + accidentDesc +
	'","claimNoOld":"' + claimNoOld+ '","reportDateOld":"' + reportDateOld+ '","repInsRelationshipOld":"' + repInsRelationshipOld  + 
	'","idtypeOld":"' + idtypeOld  +'","pidOld":"' + pidOld  +'","pnameOld":"' + pnameOld  +'","sexOld":"' + sexOld  +'","phoneOld":"' + phoneOld  +'","telOld":"' + telOld  +
	'","contractAddrOld":"' + contractAddrOld  +'","postCodeOld":"' + postCodeOld  +'","emailOld":"' + emailOld  +
	'","sqrappInsRelationshipOld":"' + sqrappInsRelationshipOld  +'","sqridtypeOld":"' + sqridtypeOld  +'","sqr_pidOld":"' + sqr_pidOld +
	'","sqr_pnameOld":"' + sqr_pnameOld  +'","sqrsexOld":"' + sqrsexOld  +'","sqr_phoneOld":"' + sqr_phoneOld +
	'","sqr_telOld":"' + sqr_telOld  +'","sqr_contractAddrOld":"' + sqr_contractAddrOld +
	'","sqr_emailOld":"' + sqr_emailOld  +'","sqr_postCodeOld":"' + sqr_postCodeOld +
	'","accidentDateOld":"' + accidentDateOld  +'","firstDiagnoseDateOld":"' + firstDiagnoseDateOld +'","claimDateOld":"'+ claimDateOld +'","accidentaddrtypeOld":"' + accidentaddrtypeOld  +
	'","claimIllsBy_Old":"' + claimIllsBy_Old +'","accidentCodeOld":"' + accidentCodeOld +'","accTypesBy_Old":"' + accTypesBy_Old +'","accidentDescOld":"' + accidentDescOld +
	'","accidentFlag":"' + accidentFlag +
	'","pageFrom":"' + $(".pageFrom").val() +
	'","isBpo":"' +isBpo +'","isQuest":"'+isQuest+
	'","isError":"' +isError + '","is_mail":"' + is_mail +
	'","isToOutSysReport":"' +isToOutSysReport +
	'","isAppInsruedSame":"' +isAppInsruedSame +
	'","isAppRepSame":"' +isAppRepSame +
	'","customerInfoName":"' + customerInfoName +'","customerInfoSex":"' + customerInfoSex +'","customerInfoIdtype":"' + customerInfoIdtype +
	'","customerInfoPid":"' + customerInfoPid +'","customerno":"' + customerno  +'","isnoaudit":"' + isnoaudit +'","humanReviewCause":"' + humanReviewCause  + 
	'","customerInfoPhone":"' + customerInfoPhone + '","customerInfoFtele":"' + customerInfoFtele+
	'","customerInfoFaddr":"' + customerInfoFaddr+ '","customerInfoFzip":"' + customerInfoFzip+ '","customerInfoEmail":"' + customerInfoEmail +	'","claimType":"' + claimType +	'"}';
	return jsonStr;
}

function reg(s){
    var re=new RegExp("\"","g");
    var s2 =s.replace(re,"\\\"");
    re=new RegExp("[\r\n]","g");
    s3=s2.replace(re,"");
    var re1=new RegExp("(^\\s*)|(\\s*$)","g");
    s4=s3.replace(re1,"");
    s4=s4.replace(/[\r\n\t]/g,"\/");//去掉回车换行
    return s4;
}
//保存
function saveAllInfo(isToOutSysReport){
	var jsonStr = operAllInfo('',isToOutSysReport);
	//debugger;
	if($("#accidentDate").val().length==0){
		alert("请填写出险日期。");
		return;
	} 
	if(blg){
		/*if($("#firstDiagnoseDate").val().length==0){
			alert("请填写初次就诊日期。");
			return;
		}*/
		if($("#claimIllsBy_").val().length==0){
			alert("请选择疾病诊断信息。");
			return;
		}
	}
	if($("#claimDate").val().length==0){
		alert("请选择索赔日期。");
		return;
	}
	if($("#accidentaddrtype").val().length==0){
		alert("请选择出险地区。");
		return;
	}
	
	var accidentDateTxt = $("#accidentDate").val();
	var firstDiagnoseDateTxt = $("#firstDiagnoseDate").val();
	var fdd = parseInt(firstDiagnoseDateTxt.replace("-","").replace("-",""));
	var adt = parseInt(accidentDateTxt.replace("-","").replace("-",""));
	var reportDateTxt = $("#reportDate").val();
	var claimDateTxt = $("#claimDate").val();
	var rdt = parseInt(reportDateTxt.replace("-", "").replace("-", ""));
	var cdt = parseInt(claimDateTxt.replace("-", "").replace("-", ""));
	if( cdt< rdt){
		alert("索赔日期不能早于报案日期。");
		return;
	}
	if(fdd<adt){
		alert("初次就诊日期不能早于出险日期。");
		return;
	}
	if($("#accidentCode").val().length==0){
		alert("请选择出险类型。");
		return;
	}
	if($("#accTypesBy_").val().length==0){
		alert("请选择索赔事故性质。");
		return;
	}
	if($.trim($("#accidentDesc").val()).length==0){
		alert("请填写出险经过。");
		return;
	} 
	if($("#accidentDesc").val().length>200){
		alert("出险经过超出200个字数范围。");
		return;
	}
	showLoading();//加载进度条
	$("#saveInfo").removeAttr("onclick");
	$.ajax({
		type:"POST",
		contentType:"application/json; charset=UTF-8",
		url:"inspectionSaveAllInfo.do",
		data:jsonStr,
		error :function(){
        	closeLoading();
		},
		success :function(data){
        	closeLoading();
			if(data.errorCode=="00"){
				alert("成功。");
				$("#saveInfo").attr("onclick","saveAllInfo()");
				if ("Y"==isToOutSysReport) {
					$("#reportBtnSpan_id").html("");
					$("#reportBtnSpan_id").html("<a class=\"bot_btn_02\"  onclick=\"doneAllInfo();\">完成</a>");
				}
			}else{
				if(data.errorCode=="02"){ 
					alert(data.errorMsg);
				} else {
					alert("失败。");
				}
				$("#saveInfo").attr("onclick","saveAllInfo()");
			}
		}
	});
}

//完成
function doneAllInfo(accidentFlag){
	var isQuest=$("#quest").attr("value");
	var jsonStr = operAllInfo(accidentFlag,'');
	if($("#reportDate").val().length==0){
		alert("请填写报案人报案日期。");
		return;
	}
	if($("#repRelationshipSpan").html()=="请选择关系"){
		alert("请选择报案人与被保人关系。");
		return;
	}
	if($("#cardType").html()=="请选择类型"){
		alert("请选择报案人证件类型。");
		return;
	}
	if($("#spansex").html()=="请选择性别"){
		alert("请选择报案人性别。");
		return;
	}
	 
	if($("#idtype").val().length==0){
		alert("请选择报案人人证件类型。");
		return;
	}
	if($.trim($("#pid").val()).length==0){
		alert("请填写报案人证件号码。");
		return;
	}
	if($("#idtype").val()=="a"){
		if(!checkIdentityCardTrueOrFalse($("#pid").val())){
			alert("报案人身份证号码格式有误，请重新录入。");
			return;
		}
	}
	if($.trim($("#pname").val()).length==0){
		alert("请填写报案人姓名。");
		return;
	}
	if($("#sex").val().length==0){
		alert("请选择报案人性别。");
		return;
	}
	if($.trim($("#phone").val()).length==0&&$.trim($("#tel").val()).length==0){
		alert("请填写报案人移动电话或固话。");
		return;
	}
//	var reg = /^1[358][0-9]{9}$/;
	var reg = /^1[0-9]{10}$/;
	if($.trim($("#phone").val()).length!=0&&$.trim($("#phone").val()).length!=11){
		alert("报案人手机号码长度必须为11位。");
		return;
	}
	if($.trim($("#phone").val()).length!=0){
		if(!reg.test($.trim($("#phone").val()))){
			alert("报案人手机号码 填写格式不正确，请重新填写。");
			return;
		}
	}
	if($("#postCode").val().length!=0){
		if($("#postCode").val().length!=6){
			alert("报案人邮编需为6位数字。");
			return;
		}else{
			var regpc = /^[0-9]*$/;
			if(!regpc.test($("#postCode").val())){
				alert("报案人邮编录入格式不正确，请重新录入。");
				return;
			}
		}
	}
	if($("#email").val().length!=0){
		if(!emailCheck($("#email").val())){
			alert("报案人邮箱格式不正确，请重新录入。");
			return;
		}
	}
	if($("#spanSqrappInsRelationship").html()=="请选择关系"){
		alert("请选择申请人与被保人关系。");
		return;
	}
	if($("#spanSqrIdType").html()=="请选择类型"){
		alert("请选择申请人证件类型。");
		return;
	}
	if($("#spansqrsex").html()=="请选择性别"){
		alert("请选择申请人性别。");
		return;
	}	
	if($("#sqrappInsRelationship").val().length==0){
		alert("请选择申请人与被保人关系。");
		return;
	} 
	if($("#sqridtype").val().length==0){
		alert("请选择申请人证件类型。");
		return;
	} 
	if($("#sqrsex").val().length==0){
		alert("请选择申请人性别。");
		return;
	} 
	if($.trim($("#sqr_pid").val()).length==0){
		alert("请填写申请人证件号码。");
		return;
	} 
	if($("#sqridtype").val()=="a"){
		if(!checkIdentityCardTrueOrFalse($("#sqr_pid").val())){
			alert("申请人身份证号码格式有误，请重新录入。");
			return;
		}
	}
	 
	if($.trim($("#sqr_pname").val()).length==0){
		alert("请填写申请人姓名。");
		return;
	} 
	if($.trim($("#sqr_phone").val()).length==0&&$.trim($("#sqr_tel").val()).length==0){
		alert("请填写申请人移动电话或固话。");
		return;
	}
	if($.trim($("#sqr_phone").val()).length!=0&&$.trim($("#sqr_phone").val()).length!=11){
		alert("申请人手机号码长度必须为11位。");
		return;
	}
	if($.trim($("#sqr_phone").val()).length!=0){
		if(!reg.test($("#sqr_phone").val())){
			alert("申请人手机号码 填写格式不正确，请重新填写。");
			return;
		}
	}
//	if($.trim($("#sqr_contractAddr").val()).length==0){
//		alert("请填写申请人地址。");
//		return;
//	}
//	if($.trim($("#sqr_postCode").val()).length==0){
//		alert("请填写申请人邮编。");
//		return;
//	}
	if($.trim($("#sqr_postCode").val()).length!=0){
		if($("#sqr_postCode").val().length!=6){
			alert("申请人邮编需为6位数字。");
			return;
		}else{
			var regpc = /^[0-9]*$/;
			if(!regpc.test($("#sqr_postCode").val())){
				alert("申请人邮编录入格式不正确，请重新录入。");
				return;
			}
		}
	}
	if($("#sqr_email").val().length!=0){
		if(!emailCheck($("#sqr_email").val())){
			alert("申请人邮箱格式不正确，请重新录入。");
			return;
		}
	}
	if($("#payTbbody").find("tr").length==0){
		alert("请录入至少一位领款人信息。");
		return;
	}
	if($("#accidentDate").val().length==0){
		alert("请填写出险日期。");
		return;
	} 
	/*if($("#firstDiagnoseDate").val().length==0){
		alert("请填写初次就诊日期。");
		return;
	}*/
	
	if ($("#claimDate").val().length == 0) {
		alert("请填写索赔日期。");
		return;
	}
	var accidentDateTxt = $("#accidentDate").val();
	var firstDiagnoseDateTxt = $("#firstDiagnoseDate").val();
	var fdd = parseInt(firstDiagnoseDateTxt.replace("-","").replace("-",""));
	var adt = parseInt(accidentDateTxt.replace("-","").replace("-",""));
	var reportDateTxt = $("#reportDate").val();
	var claimDateTxt = $("#claimDate").val();
	var rdt = parseInt(reportDateTxt.replace("-", "").replace("-", ""));
	var cdt = parseInt(claimDateTxt.replace("-", "").replace("-", ""));
	if( cdt< rdt){
		alert("索赔日期不能早于报案日期。");
		return;
	}
	if(fdd<adt){
		alert("初次就诊日期不能早于出险日期。");
		return;
	}
	if($("#accidentaddrtype").val().length==0){
		alert("请选择出险地区。");
		return;
	}
	if($("#claimIllsBy_").val().length==0){
		alert("请选择疾病诊断信息。");
		return;
	}
	if($("#accidentCode").val().length==0){
		alert("请选择出险类型。");
		return;
	}
	if($("#accTypesBy_").val().length==0){
		alert("请选择索赔事故性质。");
		return;
	}
	if($.trim($("#accidentDesc").val()).length==0){
		alert("请填写出险经过。");
		return;
	} 
	if($("#accidentDesc").val().length>200){
		alert("出险经过超出200个字数范围。");
		return;
	} 
	showLoading();//加载进度条
//	//查看事件的索赔事故是否为空
//	$.ajax({
//		type:"POST",
//		url:"queryisBpoE.do",
//		data:{"claimNo":$("#claimNo").val()},
//		success :function(data){
//			if(data!=""){
//				if(confirm(data.claimEventNo+"（事件号）事件无索赔事故性质!")){
//						return false;
//				}
//			}
//		}
//	});
	
	var insName = "";
	var insIdtype= "";
	var insPid ="";
	if($.trim($("#customerInfoName").val()) ==""){
		insName = $("#customerInfoName").html();
	}else{
		insName= $.trim($("#customerInfoName").val());
	}
	
	if($.trim($("#customerInfoIdtype").attr("code")) ==""){
		insIdtype = $("#customerInfoIdtype").attr("code");
	}else{
		insIdtype= $.trim($("#customerInfoIdtype").attr("code"));
	}
	
	if($.trim($("#customerInfoPid").val()) ==""){
		insPid = $("#customerInfoPid").html();
	}else{
		insPid= $.trim($("#customerInfoPid").val());
	}
	
	$.ajax({
		type:"POST",
		url:"../../dataenter/checkedRcptBilldetails.do",
		data:{"claimNo":$("#claimNo").val(),"isQuest":isQuest,"insIdtype":$("#sqridtype").val(),"insName" : insName,"insIdtype":insIdtype,
			"insPid"  : insPid},
		error :function(){
        	closeLoading();
			alert("数据录入信息保存失败。");
		},
		success :function(data){
        	closeLoading();
        	if(data == "errorName"){
				alert("被保人姓名不匹配,请修改!");
				return;

			}else if(data== "errorId"){
				alert("被保人证件信息不匹配,请修改!");
				return;
			}else if(data == "error"){
				alert("系统异常,请联系开发人员进行协助解决");
				return;
			}else if(data == "errorRcpt"){
				alert("请录入大于0的重症监护天数！");
				return;
			}else if(data == "errorBankCode"){
				alert("领款人银行代码为空，请修改!");
				applyDataEnterAjaxFn(jsonStr);
			}else if(data == "errorBankAccountNo"){
				alert("领款人银行账号为空，请修改!");
				applyDataEnterAjaxFn(jsonStr);
			}else if(data == "errorBankName"){
				alert("银行名称为空，请修改！");
				applyDataEnterAjaxFn(jsonStr);
			}else if(data == "Y"){
				applyDataEnterAjaxFn(jsonStr);
			}
		}
	});		
}
function applyDataEnterAjaxFn(jsonStr){
	$("#doneInfo").removeAttr("onclick");
	$.ajax({
		type:"POST",
		contentType:"application/json; charset=UTF-8",
		url:"inspectionDoneDataEnterInfo.do",
		data:jsonStr,
		error :function(data){
			alert("数据保存出现异常。");
		},
		success :function(data){
			if (data.flag == "010"){
				alert("没有查到保单！");
				$("#doneInfo").attr("onclick","doneAllInfo()");
				return;
			}
			if(data.flag=="02"){
				//alert($(".pageFrom").val());
				alert("完成！");
				if($(".pageFrom").val()!='2'){
					location.href='../clmtask/myClaimStateAndCurrentOperater.do';
					document.onmousedown=click;
				}
			}else if(data.flag=="03"){
				alert("此数据信息已提交，请做后续处理。");
				$("#doneInfo").attr("onclick","doneAllInfo()");
			}else if(data.flag=="01"||data.flag=="04"){
				alert(data.msg);
				$("#doneInfo").attr("onclick","doneAllInfo()");
			}else{
				if(data.errorMsg!=null){
					alert(data.errorMsg);
				}else{
					alert("失败。");					
				}
				
				$("#doneInfo").attr("onclick","doneAllInfo()");
			}
		}
	});
}
/**小额理赔人工审核*/
function isNoArtificiAlaudit(isno){
	if(isno=='1'){
		$('#humanReview').attr('class','check_yes txt_blue');
	}else{
		$('#humanReview').attr('class','check_yes txt_blue');
	}
}


/**
 * 索赔事故性质
**/

function initclaimacc(skipFlag){
	if(skipFlag!=undefined&&skipFlag!=""){
		$("#SHcon10").css("display","block");
		
	}
	//accTypesBy_
	var accTypesStr = $("#accTypesBy_").val();
	var accTypes = accTypesStr.split("_");
	var i = 0 ;
	for(; accTypes != '' && i < accTypes.length ; i++ ){
		if(accTypes[i]=="01"){
			$('#shenggu').attr('class','re_icon1 re_icon1_cur');
		}
		if(accTypes[i]=="02"){
			$('#shangchang').attr('class','re_icon2 re_icon2_cur'); 
		}
		if(accTypes[i]=="03"){
			$('#zhongda').attr('class','re_icon3 re_icon3_cur');
		}
		if(accTypes[i]=="04"){
			$('#menzhen').attr('class','re_icon4 re_icon4_cur');
		}
		if(accTypes[i]=="05"){
			$('#zhuyuanyiliao').attr('class','re_icon5 re_icon5_cur');
		}
		if(accTypes[i]=="06"){
			$('#zhuyuanbutie').attr('class','re_icon6 re_icon6_cur');
		}
		if(accTypes[i]=="07"){
			$('#nvxingshengyu').attr('class','re_icon7 re_icon7_cur');
		}
		if(accTypes[i]=="08"){
			$('#dentisty').attr('class','re_icon8 re_icon8_cur');
		}
		if(accTypes[i]=="09"){
			$('#onculist').attr('class','re_icon9 re_icon9_cur');
		}
		if(accTypes[i]=="10"){
			$('#menzhendabing').attr('class','re_icon11 re_icon11_cur');
		}
		if(accTypes[i]=="11"){
			$('#jinjiyake').attr('class','re_icon10 re_icon10_cur');
		}
		if(accTypes[i]=="12"){
			$('#buymedicine').attr('class','re_icon12 re_icon12_cur');
		}
		if(accTypes[i]=="13"){
			$('#medical').attr('class','re_icon13 re_icon13_cur');
		}
		if(accTypes[i]=="14"){
			$('#girlDisease').attr('class','re_icon14 re_icon14_cur');
		}
		if(accTypes[i]=="15"){
			$('#aids').attr('class','re_icon15 re_icon15_cur');
		}
		if(accTypes[i]=="16"){
			$('#emergencymedical').attr('class','re_icon16 re_icon16_cur');
		}
		if(accTypes[i]=="17"){
			$('#medicalvaccine').attr('class','re_icon17 re_icon17_cur');
		}
		if(accTypes[i]=="18"){
			$('#congenitaldisease').attr('class','re_icon18 re_icon18_cur');
		}
		if(accTypes[i]=="19"){
			$('#xinxueguan').attr('class','re_icon19 re_icon19_cur');
		}
		if(accTypes[i]=="20"){
			$('#guzhe').attr('class','re_icon20 re_icon20_cur');
		}
	}
	
}

function saveClaimAcc(method,value){
	if(method=='add'){
		var accTypesStr = $("#accTypesBy_").val();
		var accTypes = accTypesStr.split("_");
		var i = 0 ;
		//判断是否已经保存了这个 索赔事故性质
		var flag = 0;
		for(; accTypes != '' && i < accTypes.length ; i++ ){
			if(accTypes[i]==value){
				flag = 1;
				break;
			}
		}
		if(flag==0){
			if($("#accTypesBy_").val()==''){
				$("#accTypesBy_").val(value);
			}else{
				$("#accTypesBy_").val($("#accTypesBy_").val()+"_"+value);
			}
		}
	}
	
	if(method=='del'){
		var accTypesStr = $("#accTypesBy_").val();
		var accTypes = accTypesStr.split("_");
		var i = 0 ;
		//判断是否已经保存了这个 索赔事故性质
		var flag = 0;
		for(; accTypes != '' && i < accTypes.length ; i++ ){
			if(accTypes[i]==value){
				accTypes[i] = '00';
				flag = 1;
				break;
			}
		}
		if(flag==1){
			var accTypesNew = '';
			i = 0;
			var position = 0;
			for(; accTypes != '' && i < accTypes.length ; i++ ){
				if(accTypes[i]!='00'){
					if(position==0){
						accTypesNew = accTypes[i];
					}else{
						accTypesNew = accTypesNew + '_' + accTypes[i];
					}
					position++; 
				}
			}
			
			$("#accTypesBy_").val(accTypesNew);
		}
	}
	
}
//事件删除
var otherIndex=0;
function delEventTr(){ 
		var tr = $("#eventInfoTbl tr:eq("+otherIndex+")");
		var claimNo = $("#evntForClaimNo").val(); 
		var trId=tr.attr("id");
		if(trId!=""&&trId!=undefined){
			if(confirm("是否确认删除该事件及收据信息？")){
				$.ajax({
					type:"POST",
					url:"delEventInfoForClaim.do",
					data:'claimNo='+claimNo+'&&eventNo='+trId,
					error :function(){
					},
					success :function(data){
						if(data=="00"){
							alert("系统异常，删除事件信息失败！");
							
						}else{
							var accs = [];
							accs = data.split("_");
							$("#accTypesBy_").val(data);
							$('#shenggu').attr('class','re_icon1 re_icon1');
							$('#shangchang').attr('class','re_icon2');
							$('#zhongda').attr('class','re_icon3');
							$('#menzhen').attr('class','re_icon4');
							$('#zhuyuanyiliao').attr('class','re_icon5');
							$('#zhuyuanbutie').attr('class','re_icon6');
							$('#nvxingshengyu').attr('class','re_icon7');
							$('#dentisty').attr('class','re_icon8');
							$('#onculist').attr('class','re_icon9');
							$('#menzhendabing').attr('class','re_icon11');
							$('#jinjiyake').attr('class','re_icon10');
							$('#buymedicine').attr('class','re_icon12');
							$('#medical').attr('class','re_icon13');
							$('#girlDisease').attr('class','re_icon14');
							$('#aids').attr('class','re_icon15');
							$('#emergencymedical').attr('class','re_icon16');
							$('#medicalvaccine').attr('class','re_icon17');
							$('#congenitaldisease').attr('class','re_icon18');
							$('#xinxueguan').attr('class','re_icon19');
							for ( var int = 0; int < accs.length; int++) {
								var type = accs[int];
								if(type=="01"){
									$('#shenggu').attr('class','re_icon1 re_icon1_cur');
								}else if(type=="02"){
									$('#shangchang').attr('class','re_icon2 re_icon2_cur');
								}else if(type=="03"){
									$('#zhongda').attr('class','re_icon3 re_icon3_cur');
								}else if(type=="04"){
									$('#menzhen').attr('class','re_icon4 re_icon4_cur');
								}else if(type=="05"){
									$('#zhuyuanyiliao').attr('class','re_icon5 re_icon5_cur');
								}else if(type=="06"){
									$('#zhuyuanbutie').attr('class','re_icon6 re_icon6_cur');
								}else if(type=="07"){
									$('#nvxingshengyu').attr('class','re_icon7 re_icon7_cur');
								}else if(type=="08"){
									$('#dentisty').attr('class','re_icon8 re_icon8_cur');
								}else if(type=="09"){
									$('#onculist').attr('class','re_icon9 re_icon9_cur');
								}else if(type=="11"){
									$('#jinjiyake').attr('class','re_icon10 re_icon10_cur');
								}else if(type=="10"){
									$('#menzhendabing').attr('class','re_icon11 re_icon11_cur');
								}else if(type=="12"){
									$('#buymedicine').attr('class','re_icon12 re_icon12_cur');
								}else if(type=="13"){
									$('#medical').attr('class','re_icon13 re_icon13_cur');
								}else if(type=="14"){
									$('#girlDisease').attr('class','re_icon14 re_icon14_cur');
								}else if(type=="15"){
									$('#aids').attr('class','re_icon15 re_icon15_cur');
								}else if(type=="16"){
									$('#emergencymedical').attr('class','re_icon16 re_icon16_cur');
								}else if(type=="17"){
									$('#medicalvaccine').attr('class','re_icon17 re_icon17_cur');
								}else if(type=="18"){
									$('#congenitaldisease').attr('class','re_icon18 re_icon18_cur');
								}else if(type=="19"){
									$('#xinxueguan').attr('class','re_icon19 re_icon19_cur');
								}else if(type=="20"){
									$('#guzhe').attr('class','re_icon20 re_icon20_cur');
								}
								
							}
							alert("删除事件信息成功。");
							if(otherIndex!=0){
								$("#eventInfoTbl tr:eq("+otherIndex+")").remove();
								otherIndex=0;
							}
						}
					}
				});
			}
			
		}
}
function choosEventEd(flag){
	 
	$(flag).css("background-color", "#e5e5e5").siblings().css("background-color", "#FFFFFF");
	otherIndex=$(flag).index();
}

function onlychoose(obj){
	if($(obj).hasClass("check_no")){
		$(obj).attr("class","check_yes");
	}else{
		$(obj).attr("class","check_no");
	}
	
}
function checkMoney(moneyInput){
	if($(moneyInput).val()!=""){
//		var mny = /(^\d+$)|(^\d+.\d+$)/g;
		var mny = /^([1-9][\d]{0,7}|0)(\.[\d]{1,2})?$/;
		if(!mny.test($(moneyInput).val())){
			$(moneyInput).val("");
		}
	}
}
//邮箱校验
function emailCheck(str){
//  var pattern =/^(\w)+(\.\w+)*@(\w)+((\.\w+)+)$/;
  var pattern =/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
   return pattern.test(str);  
   
}
/**差错案件的显示**/
function check_is_error(iserror){
	if(iserror=="Y"){
		check_is_error.styple.display = "block";
	}
}

function skipTo(str){
	var params={};
	params['preno'] = str;
	//SkipByPost("../../dataenter/checkgrant.do",params);
	SkipByPost("openWindow('../dataenter/checkgrant.do')",params);
}

function queryInsurancePolicyInfo(){
	if($("#stype").val()=='1'){
		if($("#content").val().length!=15 && $("#content").val().length!=18){
			alert("身份证长度必须为15位或18位");
			return false;
		}
	}
	if($("#stype").val()=='3'){
		if($("#content").val().length!=15){
			alert("保单号长度必须为15位");
			return false;
		}
	}
	if($("#stype").val()=='2'){
		if($("#sername").val()==null || $("#sername").val()==""){
			alert("姓不能为空");
			return false;
		}
		if($("#name").val()==null || $("#name").val()==""){
			alert("名不能为空");
			return false;
		}
		if($("#sex").val()==null || $("#sex").val()==""){
			alert("性别不能为空");
			return false;
		}
		if($("#birthday").val()==null || $("#birthday").val()==""){
			alert("生日不能为空");
			return false;
		}
	}
	
	$("#insureData").html("");
	showLoading();//加载进度条claimserver/inspection/claim/notification/clmInsureQuery.do 
    $.ajax({  
        type: "POST",  
        async: false, 
        url: "/claimserver/claim/notification/queryInsurce.do",  
        data: {stype:"1",content:$("#content").val(),sername:$("#sername").val(),name:$("#name").val(),sex:$("#sex").val(),birthday:$("#birthday").val()},  
        error: function () {
        	closeLoading();
        	alert("查询出现异常！ ");
        },
        success: function(data){  
        	closeLoading();//去掉进度条
        	if(data.errorMsg!=null && data.errorMsg!=""){
        		$("#insureData").append("<tr><td>查询不到相关内容，请检查查询条件</td></tr>");
        	}else if(data.insureList==null || data.insureList==null){
        		$("#insureData").append("<tr><td>查询不到相关内容，请检查查询条件</td></tr>");
        	}else{
        		var items = data.insureList;  
                
                $.each(items, function(i, n){
                 	$("#insureData").append("<tr  ondblclick=\"dbclickForword('"+items[i].pid+"',this)\"><td width=\"23%\">"+items[i].name+"</td><td width=\"45%\">"+items[i].pid+"</td><td width=\"21%\">"+items[i].sexName+"</td></tr>");
                });  
        	}
            
        }  
    });   
} 
function checkInsure(){
	//姓名+性别+出生日期查询类型为2，如果不为2时需要校验查询内容content
	if($("#stype").val()!="2"){ 
		if($("#content").val()==null || $("#content").val()==""){
			alert("查询内容不能为空！");
			return false;
		}
	}
	queryInsurancePolicyInfo();
}
function dbclickForword(pid,value){
	showLoading();//加载进度条
	//$(value).unbind("ondblclick"); //移除ondblclick
	$("#pidBpo").val(pid);
	$("#myClaimId").submit();
}
function insureSelectChange(val){
	if(val=="2"){
		divCustomInfo.style.display="block";//选怪姓+名+性别+出生日期
		$("#content").hide();//隐藏上面的输入框
	}else{
		$("#content").val("");
		$("#content").show();
		divCustomInfo.style.display="none";
	}
	$("#stype").val(val);//默认为被保险人身份证号查询
}
function doOutSystemReport() {
	saveAllInfo('Y');
}
function submitPageForm(){
//	var claimNo = $(".inspectionClaimNo").val();
	SkipByPost("findByOrgAndClaimState.do");
//	$("#formId").attr("action","findByOrgAndClaimState.do");
//	$("#formId").attr("method","POST");
//	$("#formId").submit();
}
/**
 * 撤案
 */
function revokedFiledCase(claimNo){
	if (window.confirm("是否确认撤案？")) {
		$("#revokedFiledCase").removeAttr("onclick");
		 $.ajax({
		      type: "POST",		      
//		      url:"../../claim/filedCase/requestRevokedFiledCase.do",
		      url:"requestRevokedFiledCase.do",
		      data:{"claimNo":claimNo},	
		      error :function(){
				alert("撤案失败！");
				},
				success :function(data){
					$("#revokedFiledCase").attr("onclick","revokedFiledCase()");
					if(eval(data.isBool)){
						alert("撤案完成，待结案！");
						showDiv('P0000011');
						setDataRevokedFn(data.np11);
					}else{
						alert(data.errMsg);
					}
				}
			});
			
		}
	}

function tipSearch(flag){
	var bankname = null;
	if(flag=='1'){
		bankname = $("#propertyBankName").val();
	}else if(flag=='2'){
		bankname = $("#propertyCenterBankName").val();
	}
	$.ajax({
		type:"POST",
		url:"../../virementoperation/queryPropertyBank.do",
		data:{"bankname":bankname},
		error:function(){
		},
		success:function(data){
			if(flag=='1'){
				var ul=$("<ul id=\"tip\"></ul>");
				if(data.length>0){
					for ( var i = 0; i < data.length; i++) {
						$(ul).append("<li style=\"background-color:#FFFFFF\" onmouseover=\"changbackclrFn(this)\" onblur=\"displayNone('1')\" onclick=\"selectedCompanyInfoFn('"+data[i].bankName+"','"+data[i].bankGroupCode+"','1')\">"+data[i].bankName+"</li>");
					}
					$("#tip-div").html(ul);
					$("#tip-div").css("display","");
				}else{
					$("#tip-div").css("display","none");
				}
			}else if(flag=='2'){
				var ul=$("<ul id=\"top\"></ul>");
				if(data.length>0){
					for ( var i = 0; i < data.length; i++) {
						$(ul).append("<li style=\"background-color:#FFFFFF\" onmouseover=\"changbackclrFn(this)\" onblur=\"displayNone('2')\" onclick=\"selectedCompanyInfoFn('"+data[i].bankName+"','"+data[i].bankGroupCode+"','2')\">"+data[i].bankName+"</li>");
					}
					$("#top-div").html(ul);
					$("#top-div").css("display","");
				}else{
					$("#top-div").css("display","none");
				}
			}
			
		}
	});
}


function selectedCompanyInfoFn(bankName,bankGroupCode,flag){
	if(flag=='1'){
		$("#isnoPropertyBankName").val(bankName);
		$("#propertyBankName").val(bankName);
		$("#propertyBankType").val(bankGroupCode);
		$("#tip-div").css("display","none");
	}else if(flag=='2'){
		$("#isnoBankName").val(bankName);
		$("#propertyCenterBankName").val(bankName);
		$("#propertyCenterBankType").val(bankGroupCode);
		$("#top-div").css("display","none");
	}
	
}

function changbackclrFn(flag){
	$(flag).css("background-color", "#e5e5e5").siblings().css("background-color", "#FFFFFF");
}
function displayNone(flag){
	if(flag=='1'){
		$("#tip").css("display","none");
	}else if(flag=='2'){
		$("#top").css("display","none");
	}
	
}

//根据证件类型修改性别
function onclickIdtype(Idtype){
	if (Idtype!= "a") {
		$("#customerInfoPid").val("");
		$("#customerInfoSex1").attr("class","sel_list i_ul_265");
	}
}

//根据身份证号显示性别
function changSex(){
	var clamTaskClaimState = $("#clamTaskClaimState").val();
	if (clamTaskClaimState == '03') {
		if ($("#customerInfoIdtype").attr("code") == "a") {
			if (!checkIdentityCardTrueOrFalse($.trim($("#customerInfoPid").val()))) {
				alert("被保人身份证号码格式有误，请重新录入。");
				return;
			} else {
				var pid = $.trim($("#customerInfoPid").val());
				if (pid.length == "15") {
					var i = pid.substr(pid.length - 1, 1);
					ismanandwoman(i);
				} else if (pid.length == "18") {
					var i = pid.substr(pid.length - 2, 1);
					ismanandwoman(i);
				}
			}

		}
	}
}

function ismanandwoman(i){
	if(i%2==0){
		$("#customerInfoSex").html("女");
		$("#customerInfoSex").attr("code","2");
		$("#customerInfoSex1").removeAttr("class");
	}else{
		$("#customerInfoSex").html("男");
		$("#customerInfoSex").attr("code","1");
		$("#customerInfoSex1").removeAttr("class");
	}
}
function queryCheckReason(claimNo){
	$.ajax({
		type:"POST",
		url:"queryCheckReason.do",
		data:{"claimNo":claimNo},
		error:function(){
			alert("查询转质检原因失败！");
			return;
		},
		success:function(data){
			$("#checkReason").html('');
			
			if(data==null || data==""){				
				$("#checkReason").append("<tr><td colspan=\"7\">没有转质检原因！</td></tr>");
			}else{
				for(var i= 0; i < data.length; i++){
					var h = data[i];
					$("#checkReason").append("<tr>" +
					"<td>"+isNull(h.qctreason)+"</td></tr>");
				}
			}
		}
	});
}


//不予受理
function  willnotbeaccepted(claimNo){
	var isQuest=$("#quest").attr("value");
	if(confirm("是否确认不予受理？")){
		$.ajax({
  		type:"POST",
  		url:"/claimserver/claim/filedCase/requestRevokedFiledCase.do",
  		data:{"claimNo":claimNo,"isQuest":isQuest},
  		error:function(data){
  			alert("不予受理失败");
  		},
  		success :function(data){
  			if(data.errMsg==""||data.errMsg==null){
  				var insureName =data.reMap.insureName;
      			var xzName =data.reMap.xzName;
      			var policyno = data.reMap.policyno;
      			var reportName = data.reMap.reportName;
      			var idcard = data.reMap.idcard;
      			var currentDate = data.reMap.currentDate;
      			var branchName = data.reMap.branchName;
      			var clmAccAndReportType = data.reMap.clmAccAndReportType;
      			$("#notGrantOp").find("#policyno").html(policyno);
      			$("#notGrantOp").find("#insureName").html(insureName);
      			$("#notGrantOp").find("#reportName").html(reportName);
      			$("#notGrantOp").find("#idcard").html(idcard);
      			$("#notGrantOp").find("#currentDate").val(currentDate);
      			$("#notGrantOp").find("#clmAccAndReportType").html(xzName);
      			$("#notGrantOp").find("#branchName").html(branchName);
      			//REQHOP1-161014-1427 理赔通知书优化 lujibin 20161226 
      			$("#notGrantOp").find("#name1").val(data.reMap.appName);
    			$("#notGrantOp").find("#cNo1").val(data.reMap.claimNo);
    			$("#notGrantOp").find("#cDate1").val(data.reMap.applyDate);
    			$("#notGrantOp").find("#iName1").val(insureName);
    			$("#notGrantOp").find("#pid1").val(idcard);
    			$("#notGrantOp").find("#iName2").val(insureName);
    			$("#notGrantOp").find("#pid2").val(idcard);
    			$("#notGrantOp").find("#p0000001InfoTel").val(data.reMap.p0000001InfoTel);
    			//REQHOP1-161014-1427 理赔通知书优化 lujibin 20161226 
  				showDiv('notGrantOp');
  			}else{
  				alert(data.errMsg);
  			}
  		}
  	});
		
	}
}



/**不予受理通知书打印*/
function printBYCL(){
	var reason=$("#reason").val();
	if(reason==""||reason==null){
		alert("不予受理原因不能为空");
		return;
	}
	var param={};
	var claimNo = $("#notGrantOp").find("#cNo1").val();
	var policyno = $("#notGrantOp").find("#policyno").html();
	var insureName = $("#notGrantOp").find("#insureName").html();
	var reportName = $("#notGrantOp").find("#reportName").html();
	var idcard = $("#notGrantOp").find("#idcard").html();
	var reason =$("#notGrantOp").find("#reason").val();
	var currentDate = $("#notGrantOp").find("#currentDate").val();
	var clmAccAndReportType = $("#notGrantOp").find("#clmAccAndReportType").html();
	var branchName = $("#notGrantOp").find("#branchName").html();
	var appName=$("#notGrantOp").find("#name1").val();
	
	param['claimNo']=claimNo;
	param['idcard']=idcard;
	param['insureName']=insureName;
	param['currentDate']=currentDate;
	param['policyno']=policyno;
	param['reason'] = reason;
	param['reportName'] = reportName;
	param['clmAccAndReportType'] = clmAccAndReportType;
	param['branchName'] = branchName;
	param['infoTel']=$("#p0000001InfoTel").val();
	param['appName']=appName;
	$.ajax({
		 type: "POST", 
	     url: "/claimserver/claim/notification/printBYSL.do",
	     data:param,
	     async : false,
	     success:function(data){
	    	 if(data =='0000000'){
	    		 alert("操作成功");
		    	 window.location="/claimserver/inspection/clmtask/showMyTask.do";
	    	 }else{
	    		 alert("操作失败");
	    	 }
	     },
	     error:function(data){
	    	alert("操作失败") ;
	     }
	});
}



/*下载影像*/
function downImage(){
	var ipAddress=$("#ipAddress").val();
	var claimNo = $(".inspectionClaimNo").val();
	$.ajax({
		type:"post",
		url:"/claimserver/epiboly/hasImageFileOfClaimNo.do",
		data:{"claimNo":claimNo},
		error:function(){
		},
		success:function(data){
			if(data=="1"){
//				SkipByPost("http://localhost:8081/claimserver/epiboly/imageDownload.do",{claimNo:claimNo});
				
				
				SkipByPost(ipAddress+"/claimserver/epiboly/imageDownload.do",{claimNo:claimNo});
				
				$("#botOpenImage").removeAttr("onclick");	
			}else{
				alert("没有影像！");
			}
		}
	});
}


$(function(){
	
	
	var errFlag="";
	var errCause="";
	$("#isErrorVal").click(function(){
		
		if($("#isErrorVal").attr("class")=='check_yes'){
			var errCauseStr=$("#errorCauseStr").val();
			for(var i=1;i<8;i++){
				if(errCauseStr.charAt(i-1)=='1'){
					$("#cause"+i).attr("checked","checked");
				}
				
				
			}
			showDiv('error_cause');
			//is_error设为y
			errFlag="yes";
			
		}else if($("#isErrorVal").attr("class")=='check_no'){
			//is_error设为n
			errFlag="no"; 
		}
		
		$.ajax({
			type:"post",
			url:"/claimserver/inspection/clmtask/isErrorButton.do",
			data:{"claimNo":$("#claimNo").val(),"flag":errFlag ,"isErrorCause":errCause,"isErrorInfo":$("#error_cause_info").val()},
			error:function(){
				
			},
			success:function(data){
				
				if(data.errMassage=="success"){
					
				}
			}
		});
	});
	
	$("#error_commit").click(function(){
		
		errCause="";
		for(var i=1;i<8;i++){
			if($("#cause"+i).prop("checked")){
				errCause=errCause+"1";
			}else{
				errCause=errCause+"0";
			}
			
		}
		errFlag="yescommit";
		$.ajax({
			type:"post",
			url:"/claimserver/inspection/clmtask/isErrorButton.do",
			data:{"claimNo":$("#claimNo").val(),"flag":errFlag ,"isErrorCause":errCause,"isErrorInfo":$("#error_cause_info").val()},
			success:function(data){
				
				if(data.errMassage=="success"){
					
				}
			}
		});
	});
	
	
});

function openNewWindow(tbrxm){
	var url = "/claimserver/claimpolicyInfoController/claimpolicyInfoQueryPage.do?tbrxm="+tbrxm+"&flag=1";
	
	window.open(url,"被保险人查询");
}






/**
 * 729需求 cyj新增
 */
  function showHospitalDetailDiv(hospitalCode){
        if(hospitalCode==undefined){
        	hospitalCode="";
        }
		$.ajax({
			type : "POST", 
			url : "showHospitalDetail.do",
			data : {'hospitalCode':hospitalCode},
			error : function(){
				alert("系统错误，请稍后再试。");
			},
			success : function(data){
				$('#hospitalTbList').empty();
               var hospitalCapitalString="";
               var hospitalLevelString  ="";
               if(data!=null&&data.length>0){
            	   hospitalCapitalString = data[0].hospitalCapitalString;
            	   hospitalLevelString   = data[0].hospitalLevelString;
               }
               if(hospitalCapitalString==undefined){
            	   hospitalCapitalString="";
               }
               if(hospitalLevelString==undefined){
            	   hospitalLevelString="";
               }
               
               var hospitalTitle = $('<tr><th width="50%">医院等级</th><th width="50%">医院性质</th></tr>');
               var hospitalInfo  = $('<tr><td>'+hospitalLevelString+'</td><td>'+hospitalCapitalString+'</td></tr>');
               $('#hospitalTbList').append(hospitalTitle);
               $('#hospitalTbList').append(hospitalInfo);
               showDiv('hospitalResultDivId');
			}
		});
	  
  }


