<div class="div_c mobi_top">
	<form action="index.php?c=race&action=race_reg_add&race_id=<?php echo $race_id; ?>&group_id=<?php echo $group_id;?>" method="post"
		  enctype="application/x-www-form-urlencoded">
		<table class="table">
			<?php 
			if($_GET['team_name'])
			{
				?>
				<tr>
					<td >
团队<td>
						<font style="font-size: 1.5em"><?php echo $_GET['team_name']?></font> <a href="index.php?c=race&action=team_select&race_id=<?php echo $race_id?>&group_id=<?php echo $group_id?>" style="font-size: 7pt; color: #666666">重新选择>></a><input type="hidden" name="team_id" value="<?php echo $_GET['team_id']?>"></td>
					</td>		</tr>
				<?php
			}
			?>
			<tr>
				<td width="80">姓名</td>
				<td ><input type="text" value="<?php echo $result[0]['realname'] ?>" name="realname" id="realname" placeholder="请输入姓名" style="width:80%;">
				</td>
			</tr>
			<tr>
				<td>证件类型</td><td>
					<select name="idcard_type"  id="idcard_type">
						<option value="1" <?php if($result[0]['idcard_type']==1){echo "selected";}?>>身份证</option>
						<option value="2" <?php if($result[0]['idcard_type']==2){echo "selected";}?>>军官证</option>
					</select>
					<option>
				</td> 
			</tr>
			<tr>
				<td>证件号码</td>
				<td >
					<input type="text" value="<?php echo $result[0]['idcard'] ?>" name="idcard" placeholder="请输入证件号码" style="width:80%;" id="idcard">
				</td>
			</tr>
			<tr>
				<td>性别</td>
				<td>
					<select name="sex">
						<option value="1" <?php if($result[0]['sex']==1){echo "selected";}?>>男</option>
						<option value="2" <?php if($result[0]['sex']==2){echo "selected";}?>>女</option>
					</select>
				</td>
			</tr>
			<?php if($p_update=='1')
				{?>
        <tr>
				<td>照片</td>
            <td align="center" >
           
                <div id="cert_img_div">
                    <?php if ($result[0]['cert_img'])
                    {?>
                        <img src="<?php echo $result[0]['cert_img'] ?>" style="max-width: 200px"/>
                        <?php
                    }else{
                        ?>
                        <div class="btn" style="width: 80%">
                        <a onclick="setting('cert_img')" href="#" > 
                       <br/><br/> <i class="fa fa-plus fa-4x"></i><br/>请上传您参加过往活动的<br/>号码布、完赛证书或现场照片
                        </a>
                    </div>
                        <?php
                    }?>
                    <input type="hidden" value="<?php echo $result[0]['cert_img'] ?>" name="cert_img" id = "cert_img" >
                </div>
                 
            </td>
        </tr>
		   <?php
		   }?>
			<tr>
				<td>出生日期</td>
				<td > 
				<input type="text" value="<?php echo $result[0]['born'] ?>" name="born" class="Wdate" onclick="WdatePicker()" placeholder="请输入出生日期" id="born" style="height: 50px;">
					<input type="hidden" value="" name="age" id="age"/>
				</td>
			</tr>
			<tr>
				<td>手机号码</td>
				<td ><input type="text" value="<?php echo $result[0]['tel'] ?>" name="tel" placeholder="请输入手机号码" id="tel"></td>
			</tr>
			<tr>
				<td>联系邮箱</td>
				<td  ><input type="email" value="<?php echo $result[0]['email'] ?>" name="email" placeholder="请输入联系邮箱"></td>
			</tr>
			<tr>
				<td>联系地址</td>
				<td  ><input type="text" value="<?php echo $result[0]['address'] ?>" name="address" placeholder="请输入联系地址"></td>
			</tr>
			<tr>
				
		  <?php echo $input_list; ?>
		</table>
	   <?php if($action !='my_reg_msg'){?>
		<input type="submit" value="提交报名" class="btn reg_btn" onclick="return check();">
		<br/><br/><br/><br/>
	</form>
<?php
}
else {
} ?>
</div>
<script language="JavaScript">
    function setting(id) {
    	fon_height = $(window).height(); 
        $("#frame_main").show();
        $("#f_i",parent.document.body).attr("src","plug-in/updateApi.php?image_id="+id);
        $("#frame_main").css("height",fon_height-200);
    }

    function check()
    {
        realname = $("#realname").val();
        idcard= $("#idcard").val();
        born = $("#born").val();
        tel = $("#tel").val();
		cert_img= $("#cert_img").val();
        if(realname == "")
        {
            alert("请输入姓名");
            return false;
        }

        if(idcard=="")
        {
            alert("请输入身份证号码");
            return false;
        }
        //var idcarcheck=IdentityCodeValid(idcard);
        
        //if(!idcarcheck) {
           // return false;
        //}

        if(born == "")
        {
            alert("请输入出生日期");
            return false;
        }
        else
        {
			age= computeAge(born);
			<?php 
			if($s_age)
			{
			?>
			$("#age").val(age);
			if(age < <?php echo $s_age?> || age > <?php echo $b_age?>)
			{
				alert("对不起，本次活动要求<?php echo $s_age?>岁到<?php echo $b_age?>岁参加");
				return false;
			}
			<?php
			}
			?>
        }

        if(tel=="")
        {           
            alert("请填写手机号码");
            return false;
        }
        
        <?php if($p_update=='1')
				{?>
        if(cert_img == "")
        {
            alert("请上传图片");
            return false;
        }
        <?php } ?>
        if(!(/^1(3|4|5|7|8)\d{9}$/.test(tel))){
            alert("手机号码有误，请重填");
            return false;
        }
         //自定义表单必填判断
         <?php echo $race->input_list_can_null($race_id)?>
        return true;
    }
    
	function computeAge(startDate) 
	{
		// 获得今天的时间
		var date = new Date();
		startDate = new Date(startDate);
		var newDate = date.getTime() - startDate.getTime();
		// 向下取整  例如 10岁 20天 会计算成 10岁
		// 如果要向上取整 计算成11岁，把floor替换成 ceil
		return Math.floor(newDate / 1000 / 60 / 60 / 24 / 365);
	}
</script>
<style type="text/css">
    form input {width: 100%; padding: 10px; font-size: 12pt;}
    form select {padding: 10px;height:50px;}
    .reg_btn{width: 98%; text-align:center;background-color: #00a0e9}
    .upload_btn{padding:10px;background-color: orangered; color: white; text-align: center}
    .table{width: 95%; background: white}
    .table input{width: 80%}
</style>