$(function(){

	$(".check_no,.check_yes").click(function(){
		if($(this).is(".check_yes")){
			$(this).removeClass("check_yes");
			$(this).addClass("check_no"); 
			$("#applyConsult").val("N");
		} else{
			$(this).removeClass("check_no");
			$(this).addClass("check_yes"); 
			$("#applyConsult").val("Y");
		}
	});

});

function showDivrider(id, e) {
	$.openPopupLayer({
		name : id,
		target : id
	});
	$("#botOpen1").hide();
}

function closeDivAndGoToWorkbench(id){
	$("#"+id).hide();
	window.location.href = 'queryWorkbench.do';
}

function saveNoticeP0000011() {
	var objId = $("#noticeP0000011_objId").val();
	var moveReasonDesc = $("#noticeP0000011_moveReasonDesc").val();
	var printDate = $("#noticeP0000011_printDate").val();
	var infoTel = $("#noticeP0000011_phoneNo").val();
	var claimNo=$("#noticeP0000011_claimNo").val();
	var appName=$("#name1").val();
	var accTypeName = $("#noticeP0000011_accTypeName").html();
	var jsonStr = '{"objId":"' + objId +'","printDate":"' +printDate+'","moveReasonDesc":"' +moveReasonDesc+'","infoTel":"' +infoTel+'","claimNo":"'+claimNo+'","accTypeName":"'+accTypeName+'","appName":"'+appName+'"}';
	$.ajax({
		type:"POST",
		contentType:"application/json; charset=UTF-8",
		url:"/claimserver/claim/notice/savecanoticeInfo.do",
		data:jsonStr,
		error :function(){
			alert("系统错误，请稍后再试。");
		},
		success :function(data){
			if(data=="00"){
				alert("撤案通知单保存成功。");
			}else{
				alert("撤案通知单保存失败。");
			}
		}
	});
}

function printP0000011Info() {
	var haveEmail = $("#haveEmail").val();
	var isMail = $("#isMail").val();
	if (isMail == 'Y') {
		if (haveEmail == 'Y') {
			if (!confirm("客户选择电子邮件方式接收，是否继续打印？")) {
				return;
			}
		} else if (haveEmail == 'N') {
			if (!confirm("客户选择电子邮件方式接收，但邮箱地址为空，是否继续打印？")) {
				return;
			}
		}
	}
//	if(haveEmail == 'Y'){
//		if(!confirm("客户选择电子邮件方式接收，是否继续打印？")){
//			return ;
//		}
//	}else if(haveEmail == 'N'){
//		if(!confirm("客户选择电子邮件方式接收，但邮箱地址为空，是否继续打印？")){
//			return ;
//		}
//	}
	var objId = $("#noticeP0000011_objId").val();
	$.ajax({
		type:"POST",
		url:"/claimserver/claim/notice/printP0000011Info.do",
		data:"objId="+objId,
		error :function(){
			alert("系统错误，请稍后再试。");
		},
		success :function(data){
			if(data=="00"){
				alert("打印通知单成功。");
			}else{
				alert("打印通知单失败。");
			}
		}
	});
	
}

function saveNoticeP0000006Info(){
	var objId = $("#noticeP0000006_objId").val();
	var denying = $("#noticeP0000006_denying").val();
	var printDate = $("#noticeP0000006_printDate").val();
	var infoTel = $("#p0000006InfoTel").val();
	var appName=$("#Name2").val();
	var jsonStr = '{"objId":"' + objId +'","pringDate":"' +printDate+'","denying":"' +denying+'","infoTel":"' +infoTel+'"}';
	var paramStr = "objId=" + objId + "&pringDate=" + printDate + "&denying=" + denying + "&p0000006InfoTel=" + infoTel+ "&appName=" + appName;
	$.ajax({
		type:"POST",
		url:"/claimserver/claim/notice/saveNoticeP0000006Info.do",
		//data:jsonStr,
		data:paramStr,
		async:false,
		error :function(){
			alert("系统错误，请稍后再试。");
		},
		success :function(data){
			if(data=="00"){
				alert("理赔决定通知书保存成功。");
			}else{
				alert("理赔决定通知书保存失败。");
			}
		}
	});
}

function printP0000006Info(){
	var objId = $("#noticeP0000006_objId").val();
	$.ajax({
		type:"POST",
		url:"/claimserver/claim/notice/printP0000006Info.do",
		data:"objId="+objId,
		error :function(){
			alert("系统错误，请稍后再试。");
		},
		success :function(data){
			if(data=="00"){
				alert("打印通知书成功。");
			}else{
				alert("打印通知书失败。");
			}
		}
	});
}


function completeP0000006Info(){
	var applyConsult = $("#applyConsult").val();
	var claimNo = $("#claimNoP0000006").val();
	//***var recheck = "N";
	if (applyConsult == 'Y') {
		//跳转到协谈申请页面
		var params = new Array();
		params["claimNo"] = claimNo;
		params["resCode"] = "03";//审核结论03拒赔
		SkipByPost("queryConsultApply.do", params);
	} else {		
		//flag:01撤案、02拒赔
		 $.ajax({
		      type: "POST",
		      url:"rejectTheClaim.do",
		      data:{"claimNo":claimNo},	
				 error:function(){
					 alert("拒赔出现异常 ！");
					 return;
				 },
				 success:function(data){
					 if (data.successFlag != "Y") {
						 alert(data.errorMsg);
					 } else {
						alert("操作成功！");
						window.location.href = 'queryWorkbench.do';
					 }
				 }
			 });
		}
}
