//公共效果
$(function(){
     
	
		//复选框
		$(".check_yes,.check_no").click(function(){
			  if($(this).is(".check_yes")){
			    
				$(this).removeClass("check_yes");
				$(this).addClass("check_no"); 
			  
			  }else{
					$(this).removeClass("check_no");
			        $(this).addClass("check_yes");
			}
		      
			  
		 });
		 
		 
		 //单选
		 /*
		$(".radio_yes,.radio_no").click(function(){ 
			  if($(this).is(".radio_yes")){
			    
				$(this).removeClass("radio_yes");
				$(this).addClass("radio_no"); 
			  
			  }
			  
			  if($(this).is(".radio_no")){
					var obj=  $(".radio_yes");
					obj.removeClass("radio_yes");          
					obj.addClass("radio_no"); 
					$(this).removeClass("radio_no");
			        $(this).addClass("radio_yes");
					 
			}
		 })
		 */
		  
		 
		 //调用展开收缩
		 autotoggle("showhide","SHcon","icon_stretch","icon_shrinkage");
		
		
		//任务池经过显示信息
		
		$(".sliding_b_r").hover(function(e){var left = $(this).offset().left;
			var top = $(this).offset().top+$(this).height();
			$("#sliOpen").css({"display":"block","left":left,"top":top});
			e.stopPropagation();},function(){$("#sliOpen").hide()});
			
	    
 
	 
		
		
		//切换块1 
		$(".divHide").not(".divHide:first").hide();
		$(".tab_style").find("span").click(function(){
			$(".tab_style").find("span").attr("class","tab_normal");
			$(this).attr("class","tab_cur");
			$(".divHide").hide();
			$("#divTab"+$(this).attr("id").charAt(0)).show();
		});
		
		
	 
		 
		 
		 
		/*selectBox*/
		$(".select").hover( function () {
			$(this).addClass("sel_over");
		},function () {
			$(this).removeClass("sel_over");
		}).on('click',function(){
			var _this = $(this),
				_bthis = $(this).find(".sel_list");
			if ( _this.attr('isopen') ) {
				_bthis.slideUp(0 , function(){
					_this.removeAttr('isopen');
				});			
			} else {
				_bthis.slideDown(0,function(){
					_this.attr('isopen',"1");
				});	
			}
		}).on('mouseleave',function(){
			var _thisa = $(this).find(".sel_list"),
				_this = $(this);
			_thisa.hide();
			_this.removeAttr('isopen');
		}),$(this).find(".sel_list li").hover( function (){
			$(this).addClass("sel_hov");		
		},function (){
			$(this).removeClass("sel_hov");	
		}).on('click',function(){
			var _this = $(this).html();
			var _code=$(this).attr("code");
			var _thisText = $(this).closest(".select").find(".sel_text");
			if(_code != undefined){
				_thisText.attr("code",_code);
			}
			
			_thisText.html(_this);
			var vid =$(this).closest(".select").attr("id")+"_code";
			var vidinput =$(this).closest(".select").attr("id")+"input";
			if($("#"+vid).is("input")){
				$("#"+vid).val($(this).attr("code"));
			}else{
				$("body").append("<input type='hidden' id='"+vid+"'>");
				$("#"+vid).val($(this).attr("code"));
			}
			if($("#"+vidinput).is("input")){
				$("#"+vidinput).val(_this);
			}
		});
	 
	 
	 
	 
	  
	   //初审频道底下弹出筛选样式  
	   $(".cs_bot_open a:last").addClass("cs_bot_last");
	 

});
 
 


// 显示引藏块公用
 function autotoggle(flagid,divid,upclass,downclass,total){
	 if(total){
		for(var i=1;i<=total*1;i++){
			$("#"+flagid+""+i).addClass("flag_id_cla");
		}
	 }
	$(".flag_id_cla").click(function(){
		if($(this).is("."+upclass)){
			$(this).removeClass(upclass);
			$(this).addClass(downclass);
			var id = $(this).attr("id");
			id = id.substring(flagid.length);
			$("#"+divid+id).slideToggle();
		}else{
			var id = $("."+upclass).attr("id");
			if(id){
				id = id.substring(flagid.length);
				var obj = $("."+upclass);
				obj.removeClass(upclass);
				obj.addClass(downclass);
				$("#"+divid+id).hide();
			}
			$(this).removeClass(downclass);
			$(this).addClass(upclass);
			id = $(this).attr("id");
			id = id.substring(flagid.length);
			$("#"+divid+id).slideToggle();
		}
	});
 }

 
 
 
 
// 弹出层调用 
 
function showDiv(id,e){
  $.openPopupLayer({
		name: id,
		target: id
	});
  
  }
  
function closeDiv(id){
  $.closePopupLayer(id);
  }
  












//鼠标经过显示隐藏弹出小层
function createBg(){
	if($("#lock_click_bg").is(".lock_click_bg")){
		$("#lock_click_bg").show();
	}else{
		$("body").append("<div id='lock_click_bg' class='lock_click_bg' style='position:absolute;left: 0px; top: 0px;display:none'></div>");
		$("#lock_click_bg").show();
		var lock = $("#lock_click_bg");
		var height = $(document).height();
		var width = $(document).width();
		lock.css("height", height);
		lock.css("width", width);
		lock.css("background","#000");
		lock.css("opacity", 0);
		lock.css("z-index",100);
	}
}



function showLockDialog(id){
	$("#"+id).css({"display":"block","z-index":101});
	createBg();
	$("#lock_click_bg").unbind();
	$("#lock_click_bg").bind("click",function(){$("#lock_click_bg").hide();$("#"+id).hide()});
}  
  
  
  

//初审底部点击弹出
function showBotOpen(id,obj){
	
		createBg();
		var left = $(obj).offset().left;
		var top = $(obj).offset().top-$("#"+id).height()-10;
		$("#"+id).css({"display":"block","left":left,"top":top});
		
		$("#lock_click_bg").unbind();
		$("#lock_click_bg").bind("click",function(){$("#lock_click_bg").hide();$("#"+id).hide()});
	
}    
  
//弹出箭头向上  
function showTopArr(id,obj){
	
		createBg();
		var left = $(obj).offset().left;
		var top = $(obj).offset().top-$("#"+id).height();
		$("#"+id).css({"display":"block","left":left,"top":top});
		
		$("#lock_click_bg").unbind();
		$("#lock_click_bg").bind("click",function(){$("#lock_click_bg").hide();$("#"+id).hide()});
	
}  

//用来得到url地址里面的参数
function getParam(paras) {
	var url = location.href;
	url = url.charAt(url.length-1)=="#"?url.substring(0,url.length-1):url;
	var paraString = url.substring(url.indexOf("?") + 1, url.length).split("&");
	var paraObj = {};
	for (i = 0; j = paraString[i]; i++) {
		paraObj[j.substring(0, j.indexOf("=")).toLowerCase()] = j.substring(j
				.indexOf("=") + 1, j.length);
	}
	var returnValue = paraObj[paras.toLowerCase()];
	if (typeof (returnValue) == "undefined") {
		return "";
	} else {
		return returnValue;
	}
}

Date.prototype.format = function (format) {
    var o = {
        "M+": this.getMonth() + 1,
        "d+": this.getDate(),
        "h+": this.getHours(),
        "m+": this.getMinutes(),
        "s+": this.getSeconds(),
        "q+": Math.floor((this.getMonth() + 3) / 3),
        "S": this.getMilliseconds()
    }
    if (/(y+)/.test(format)) {
        format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    }
    for (var k in o) {
        if (new RegExp("(" + k + ")").test(format)) {
            format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
        }
    }
    return format;
}
function createSelectBg() {
	if ($("#lock_select_bg").is(".lock_select_bg")) {
		$("#lock_select_bg").show();
	} else {
		$("body")
				.append(
						"<div id='lock_select_bg' class='lock_select_bg' style='position:absolute;left: 0px; top: 0px;display:none'></div>");
		$("#lock_select_bg").show();
		var lock = $("#lock_select_bg");
		var height = $(document).height();
		var width = $(document).width();
		lock.css("height", height);
		lock.css("width", width);
		lock.css("opacity", 0.5);
		lock.css("z-index", 10000);
		lock.css("background", "#000");
	}
}

function showLoading(){
	$("body").append("<div id='loading_cen' class='loading_cen'></div>");
	createSelectBg();
	var select_content = $("#loading_cen");
	var top = ($(window).height()- select_content.height())/2;
	var left = ($(window).width()-select_content.width())/2;
	select_content.css("top",top);
	select_content.css("left",left);
	select_content.css("z-index",10001);
	select_content.show();
}

function closeLoading(){
	if($("#loading_cen").is(".loading_cen")){
		$("#loading_cen").remove();
		$("#lock_select_bg").remove();
	}
}

//箭头朝上显示隐藏
function showTopOpen(id,obj){
		createBg();
		var left = $(obj).offset().left-$("#"+id).width()/2+15;
		var top = $(obj).offset().top+$(obj).height()+5;
		$("#"+id).css({"display":"block","left":left,"top":top});
		
		$("#lock_click_bg").unbind();
		$("#lock_click_bg").bind("click",function(){$("#lock_click_bg").hide();$("#"+id).hide()});
	
}  

//trim方法
String.prototype.trim=function(){
    return this.replace(/(^\s*)|(\s*$)/g, "");
 };

 function openWindow(url, claimNo) {
 	url = url + "?claimNo=" + claimNo;
 	window.open (url,'newwindow','top=0,left=0,toolbar=no,menubar=no,scrollbars=yes, resizable=no,location=no, status=no');
 }
 function openPreWindow(url, preno) {
	 	url = url + "?preno=" + preno;
	 	window.open (url,'newwindow','top=0,left=0,toolbar=no,menubar=no,scrollbars=yes, resizable=no,location=no, status=no');
	 }
 
 function openWindows(url, claimNo) {
	 	url = url + "?claimNo=" + claimNo;
	 	window.open (url,'newwindow','top=0,left=0,toolbar=yes,menubar=yes,scrollbars=yes, resizable=yes,location=yes, status=no');
	 }
//身份证 号码校验
 function checkIdentityCard(idcard){
 	
 	if(idcard==""||idcard==null){
 		
 		return false;
 		
 	}
 	
 	if(idcard!=""){
 		idcard=idcard.trim();
 	}
     /**
      "验证通过!",
      "身份证号码位数不对!",
      "身份证号码出生日期超出范围或含有非法字符!",
      "身份证号码校验错误!",
      "身份证地区非法!"
      */
     var Errors = new Array("\u9a8c\u8bc1\u901a\u8fc7!", "\u8eab\u4efd\u8bc1\u53f7\u7801\u4f4d\u6570\u4e0d\u5bf9!", "\u8eab\u4efd\u8bc1\u53f7\u7801\u51fa\u751f\u65e5\u671f\u8d85\u51fa\u8303\u56f4\u6216\u542b\u6709\u975e\u6cd5\u5b57\u7b26!", "\u8eab\u4efd\u8bc1\u53f7\u7801\u6821\u9a8c\u9519\u8bef!", "\u8eab\u4efd\u8bc1\u5730\u533a\u975e\u6cd5!");
     //
     var area = {
         11: "北京",
         12: "天津",
         13: "河北",
         14: "山西",
         15: "内蒙古",
         21: "辽宁",
         22: "吉林",
         23: "黑龙江",
         31: "上海",
         32: "江苏",
         33: "浙江",
         34: "安徽",
         35: "福建",
         36: "江西",
         37: "山东",
         41: "河南",
         42: "湖北",
         43: "湖南",
         44: "广东",
         45: "广西",
         46: "海南",
         50: "重庆",
         51: "四川",
         52: "贵州",
         53: "云南",
         54: "西藏",
         61: "陕西",
         62: "甘肃",
         63: "青海",
         64: "宁夏",
         65: "新疆",
         71: "台湾",
         81: "香港",
         82: "澳门",
         91: "国外"
     }
     
     var idcard, Y, JYM;
     var S, M;
     var idcard_array = new Array();
     idcard_array = idcard.split("");
     /*地区检验*/
     if (area[parseInt(idcard.substr(0, 2))] == null) {
         alert(Errors[4]);
         return false;
     }
     /*身份号码位数及格式检验*/
     switch (idcard.length) {
         case 15:
             if ((parseInt(idcard.substr(6, 2)) + 1900) % 4 == 0 || ((parseInt(idcard.substr(6, 2)) + 1900) % 100 == 0 && (parseInt(idcard.substr(6, 2)) + 1900) % 4 == 0)) {
                 ereg = /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}$/;//测试出生日期的合法性 
             }
             else {
                 ereg = /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}$/;//测试出生日期的合法性 
             }
             if (ereg.test(idcard)) {
                 return true;
             }
             else {
                 alert(Errors[2]);
                 return false;
             }
             break;
             
         case 18:
             //18位身份号码检测 
             //出生日期的合法性检查  
             //闰年月日:((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9])) 
             //平年月日:((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8])) 
             if (parseInt(idcard.substr(6, 4)) % 4 == 0 || (parseInt(idcard.substr(6, 4)) % 100 == 0 && parseInt(idcard.substr(6, 4)) % 4 == 0)) {
                 ereg = /^[1-9][0-9]{5}(19|20|21)[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}[0-9Xx]$/;//闰年出生日期的合法性正则表达式 
             }
             else {
                 ereg = /^[1-9][0-9]{5}(19|20|21)[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}[0-9Xx]$/;//平年出生日期的合法性正则表达式 
             }
             if (ereg.test(idcard)) {//测试出生日期的合法性
                //在录单时有些身份证不符合校验位的校验规则，但这种身份证确实存在先不要此校验
                /**
                 //计算校验位
                 S = (parseInt(idcard_array[0]) + parseInt(idcard_array[10])) * 7 +
                 (parseInt(idcard_array[1]) + parseInt(idcard_array[11])) * 9 +
                 (parseInt(idcard_array[2]) + parseInt(idcard_array[12])) * 10 +
                 (parseInt(idcard_array[3]) + parseInt(idcard_array[13])) * 5 +
                 (parseInt(idcard_array[4]) + parseInt(idcard_array[14])) * 8 +
                 (parseInt(idcard_array[5]) + parseInt(idcard_array[15])) * 4 +
                 (parseInt(idcard_array[6]) + parseInt(idcard_array[16])) * 2 +
                 parseInt(idcard_array[7]) * 1 +
                 parseInt(idcard_array[8]) * 6 +
                 parseInt(idcard_array[9]) * 3;
                 Y = S % 11;
                 M = "F";
                 JYM = "10X98765432";
                 M = JYM.substr(Y, 1);//判断校验位
                 if (M == idcard_array[17]) {
                     return true; //检测ID的校验位
                 }
                 else {
                     alert(Errors[3]);
                     return false;
                  }
                  */
 				return true;
             }
             else {
                 alert(Errors[2]);
                 return false;
             }
             break;
             
         default:
             alert(Errors[1]);
             return false;
     }
 }
 //身份证 号码校验 返回true或false
 function checkIdentityCardTrueOrFalse(idcard){
     /**
      "验证通过!",
      "身份证号码位数不对!",
      "身份证号码出生日期超出范围或含有非法字符!",
      "身份证号码校验错误!",
      "身份证地区非法!"
      */
     var Errors = new Array("\u9a8c\u8bc1\u901a\u8fc7!", "\u8eab\u4efd\u8bc1\u53f7\u7801\u4f4d\u6570\u4e0d\u5bf9!", "\u8eab\u4efd\u8bc1\u53f7\u7801\u51fa\u751f\u65e5\u671f\u8d85\u51fa\u8303\u56f4\u6216\u542b\u6709\u975e\u6cd5\u5b57\u7b26!", "\u8eab\u4efd\u8bc1\u53f7\u7801\u6821\u9a8c\u9519\u8bef!", "\u8eab\u4efd\u8bc1\u5730\u533a\u975e\u6cd5!");
     //
     var area = { 
         11: "北京",
         12: "天津",
         13: "河北",
         14: "山西",
         15: "内蒙古",
         21: "辽宁",
         22: "吉林",
         23: "黑龙江",
         31: "上海",
         32: "江苏",
         33: "浙江",
         34: "安徽",
         35: "福建",
         36: "江西",
         37: "山东",
         41: "河南",
         42: "湖北",
         43: "湖南",
         44: "广东",
         45: "广西",
         46: "海南",
         50: "重庆",
         51: "四川",
         52: "贵州",
         53: "云南",
         54: "西藏",
         61: "陕西",
         62: "甘肃",
         63: "青海",
         64: "宁夏",
         65: "新疆",
         71: "台湾",
         81: "香港",
         82: "澳门",
         91: "国外"
     }
     
     var idcard, Y, JYM;
     var S, M;
     var idcard_array = new Array();
     idcard_array = idcard.split("");
     /*地区检验*/
     if (area[parseInt(idcard.substr(0, 2))] == null) {
         return false;
     }
     /*身份号码位数及格式检验*/
     switch (idcard.length) {
         case 15:
             if ((parseInt(idcard.substr(6, 2)) + 1900) % 4 == 0 || ((parseInt(idcard.substr(6, 2)) + 1900) % 100 == 0 && (parseInt(idcard.substr(6, 2)) + 1900) % 4 == 0)) {
                 ereg = /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}$/;//测试出生日期的合法性 
             }
             else {
                 ereg = /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}$/;//测试出生日期的合法性 
             }
             if (ereg.test(idcard)) {
                 return true;
             }
             else {
                 return false;
             }
             break;
             
         case 18:
             //18位身份号码检测 
             //出生日期的合法性检查  
             //闰年月日:((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9])) 
             //平年月日:((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8])) 
             if (parseInt(idcard.substr(6, 4)) % 4 == 0 || (parseInt(idcard.substr(6, 4)) % 100 == 0 && parseInt(idcard.substr(6, 4)) % 4 == 0)) {
                 ereg = /^[1-9][0-9]{5}(19|20|21)[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}[0-9Xx]$/;//闰年出生日期的合法性正则表达式 
             }
             else {
                 ereg = /^[1-9][0-9]{5}(19|20|21)[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}[0-9Xx]$/;//平年出生日期的合法性正则表达式 
             }
             if (ereg.test(idcard)) {//测试出生日期的合法性
                 
 				//在录单时有些身份证不符合校验位的校验规则，但这种身份证确实存在先不要此校验
 				//计算校验位
                 S = (parseInt(idcard_array[0]) + parseInt(idcard_array[10])) * 7 +
                 (parseInt(idcard_array[1]) + parseInt(idcard_array[11])) * 9 +
                 (parseInt(idcard_array[2]) + parseInt(idcard_array[12])) * 10 +
                 (parseInt(idcard_array[3]) + parseInt(idcard_array[13])) * 5 +
                 (parseInt(idcard_array[4]) + parseInt(idcard_array[14])) * 8 +
                 (parseInt(idcard_array[5]) + parseInt(idcard_array[15])) * 4 +
                 (parseInt(idcard_array[6]) + parseInt(idcard_array[16])) * 2 +
                 parseInt(idcard_array[7]) * 1 +
                 parseInt(idcard_array[8]) * 6 +
                 parseInt(idcard_array[9]) * 3;
                 Y = S % 11;
                 M = "F";
                 JYM = "10X98765432";
                 JYJ = "10x98765432";
                 M = JYM.substr(Y, 1);//判断校验位
                 J = JYJ.substr(Y,1);
                 if (M == idcard_array[17]||J == idcard_array[17]) {
                     return true; //检测ID的校验位
                 }
                 else {
                     return false;
                 }
                 
 				return true;
             }
             else {
                 return false;
             }
             break;
             
         default:
             return false;
     }
 }
 /*统计字符个数(一个汉字算2个)*/  
 function strlength(str) {  
     var strl = 0;  
     var l = str.length;  
     for (var i = 0; i < l; i++) {  
         //全角字符  
         if (str.charCodeAt(i) < 0 ||  str.charCodeAt(i) > 255)   
             strl = strl + 2;   
         else   
             strl++;       
     }  
     return strl;
 }  
 