$(function() {
	if($("#sumAmtApp").html()==null || $("#sumAmtApp").html()==""){
		var sumAmtApp=0;
		$(".preapp").each(function() {
			sumAmtApp=Number(sumAmtApp)+Number(this.value);
		});
		$("#sumAmtApp").html(sumAmtApp);
	}
	if($("#sumAmtPre").html()==null || $("#sumAmtPre").html()==""){
		var sumAmtPre=0;
		$(".amtpre").each(function() {
			sumAmtPre=Number(sumAmtPre)+Number(this.innerHTML);
		});
		$("#sumAmtPre").html(sumAmtPre);
	}
	$(function(){
		if($("#ylxxIllsBy_").val() !=''){
			showylxxDiv('init');
		}
		if($("#claimIllsBy_").val() !=''){
			showjvDiv('init');
		}
		if($("#sqxmIllsBy_").val() !=''){
			showsqxmDiv('init');
		}
	});
});

function steppage(){
	SkipByPost(getRootPath()+"/preauthorization/grantPoolsQuery.do",{});
}

function agress(){
	var verDescribe= $("#verDescribe").val();
	if(strlen(verDescribe)>200){	
		alert("输入字符长度不能超过200个字符");
		return;
	}
	
	var params={};
	params["preno"]=$("#preno").val();
	params["verDescribe"]=verDescribe;
	$.ajax({
		type : "POST",
		url : "savegrant.do",
		//contentType : "application/json; charset=UTF-8",
		data : params,
		success : function(data) {
			SkipByPost(getRootPath()+"/preauthorization/examinePoolsQuery.do",{});
		},
		error : function() {
			alert("保存失败！");
		}
	});
}
function disagress(){
	var verDescribe= $("#verDescribe").val();
	if(strlen(verDescribe)==0){
		alert("请输入“复核意见”且不能超过200个字符");
		return;
	}
	if(strlen(verDescribe)>200){		
		alert("输入字符长度不能超过200个字符");
		return;
	}
	var params={};
	params["preno"]=$("#preno").val();
	params["verDescribe"]=verDescribe;
	$.ajax({
		type : "POST",
		url : "disgrant.do",
		//contentType : "application/json; charset=UTF-8",
		data : params,
		success : function(data) {
			SkipByPost(getRootPath()+"/preauthorization/examinePoolsQuery.do",{});
		},
		error : function() {
			alert("保存失败！");
		}
	});
}


function showsqxmDiv(flag){
	$("#sqxmresultData").html("");
	var claimIllsBy_ = $("#sqxmIllsBy_").val();
	var illTypes = claimIllsBy_.split("_");
	for(var i=0;i<illTypes.length;i++){
		var ill = illTypes[i].split(",");
		$("#sqxmresultData").append("<tr>" +
				"<td width=\"23%\">"+ill[0]+"</td>" +
				"<td width=\"45%\">"+ill[1]+"</td>" +
				"</tr>");
	}
	if(flag!='init'){
		showDiv("sqxmresult");
	}
	
	
}
//-----------------------------------------------医疗信息 医疗诊断


function showylxxDiv(flag){
	$("#ylxxresultData").html("");
	var claimIllsBy_ = $("#ylxxIllsBy_").val();
	var illTypes = claimIllsBy_.split("_");
	for(var i=0;i<illTypes.length;i++){
		var ill = illTypes[i].split(",");
		$("#ylxxresultData").append("<tr>" +
				"<td width=\"23%\">"+ill[0]+"</td>" +
				"<td width=\"45%\">"+ill[1]+"</td>" +
				"</tr>");
	}
	if(flag!='init'){
		showDiv("ylxxresult");
	}
}

//-----------------------------------------------医疗信息 医疗诊断

function showjvDiv(flag){
	$("#jbresultData").html("");
	var claimIllsBy_ = $("#claimIllsBy_").val();
	var illTypes = claimIllsBy_.split("_");
	for(var i=0;i<illTypes.length;i++){
		var ill = illTypes[i].split(",");
		$("#jbresultData").append("<tr>" +
				"<td width=\"23%\">"+ill[0]+"</td>" +
				"<td width=\"45%\">"+ill[1]+"</td>" +
				"</tr>");
	}
	if(flag!='init'){
		showDiv("jbresult");
	}
	
	
}

//-----------------------------------------------医疗授权信息 医疗诊断


function strlen(str) {
    var len = 0;
    for (var i = 0; i < str.length; i++) {
        var c = str.charCodeAt(i);
        //单字节加1 
        if ((c >= 0x0001 && c <= 0x007e) || (0xff60 <= c && c <= 0xff9f)) {
            len++;
        }
        else {
            len += 2;
        }
    }
    return len;
}
//校验电子邮箱
function checkMail(flag){
	if(flag==null || flag==""){
		return true;
	}
	 var reg=/^([a-zA-Z0-9]+[_|-|.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|-|.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/gi;
	  if(!reg.test(flag)){
	   alert("电子邮箱格式不正确，请重新输入!");
	   return false;
	  }else{
		  return true;
	  }
	  
}
//打开影像
function openImage(sModino){//sModino预授权号
	var branchid = null;
	var inputSource = $("#inputSource").val();
	var casesource = $("#casesource").val();
	if(inputSource=='05'){
		branchid = $("#branchid").val();
	}else{
		branchid='80000000000009';
	}
	   //获取当前网址
    var curWwwPath = window.document.location.href;
    //获取主机地址之后的目录
    var pathName = window.document.location.pathname;
    var pos = curWwwPath.indexOf(pathName);
    //获取主机地址
    var localhostPath = curWwwPath.substring(0, pos);
	 
	//预授权影像
    window.open(localhostPath+'/claimserver/inspection/clmtask/imageInfo.do?claimNo='+sModino+'&flag=4&branchid='+branchid+'&inputSource='+inputSource+'&casesource='+casesource+'',"预授权影像");
	
	
}