<!DOCTYPE html>
<% language=javascript %>
<html style="width: 100%; height:100%">
<head lang="en">
    <meta charset="GB2312">
    <title></title>
    <link href="css/style.css" title="style" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="css/jquery-ui.css" />
    <script src="js/jquery-1.6.3.min.js"></script>
    <script src="js/jquery.form.js"></script>
    <script type="text/javascript" src="js/jquery-ui-datepicker.js"></script>
    <meta name="robots" content="noindex, nofollow" />
    <meta http-equiv="Pragma" CONTENT="no-cache" />
    <meta http-equiv="Cache-Control" CONTENT="no-cache" />
    <meta http-equiv="expires" content="0" />

    <style>
        i{font-style:normal}
        .kaiguanTD td{text-align: center;}
    </style>

</head>
<body style="width: 100%;background: #F3F3F3; height:100%">

<div class='type3328 empty' style=' margin: 10px;'>
  <table width="100%">
    <tr>
    <td width="300px" style="text-align: center;"><img src="img/ico-card1.png" style="width: 70%;text-align: center;"></td>
    <td>
    <table width='100%'>
        <!-- <tr><td style='border: none'> <h1>ACCESS门禁系统(OM-CARDA)</h1></td></tr> -->
        <h1 style='margin:10px 10px 10px 10px;'>ACCESS门禁系统(OM-CARDA)</h1>
        <tr><td style='width: 200px;'>基本信息</td><td>SID:<span class='SID3328'> </span>&nbsp;&nbsp;&nbsp;编址:<span class='Addr3328'> </span>&nbsp;&nbsp;&nbsp;数据端口:<span class='Port3328'> </span></td></tr>
        <tr><td style='width: 200px;'>更新时间</td><td><span class='DateUpd3328'> </span></td></tr>
        <tr><td style='width: 200px;'>监测项状态</td><td><span class='State3328'> </span></td></tr>
    </table>
    <div style="margin: 10px;margin-top: 15px; width:100%">
		<form id='formdoor' method="post" style="display:none" action="/door1/ACT_ID_1" target="door">
			<input type="text" id='usr' name="username" style="display:none" value="abc">
			<input type="password" id="pwd" name="pwd"  value="654321">
			<input type="submit" value="重试">
		</form>
    </div>
    </td>
    </tr>
  </table>
</div>

  <div  style="width: 100%; height:100%">
      <iframe id="door" name="door" frameborder="0" style="width: 100%;background: #F3F3F3; height:100%">
		<!--<form id='formdoor' method="post" style="display:none" action="/door1/ACT_ID_1">
			<input type="text" id='usr' name="username" style="display:none" value="abc">
			<input type="password" id="pwd" name="pwd"  value="654321">
			<input type="submit" value="重试">
		</form>-->
      </iframe>
  </div>
    <a href='javascript:history.back()' class='back' style='color: #fff'>返回</a>
<script>
var itype=3328;
var tescape= 5000,time;

<% db_Open("/NandFlash/dbCfg.db3"); %>
var jsonsm=<% db_QryAdv("select * from tbSM where SID="+sid,0);%>;
var jname=<% db_QryAdv("select Card,Name from tbCardDef",0); %>;
<% db_Close(); %>
	
<% db_Open("/NandFlash/tmp/dbDat0.db3"); %>
var sid=<% write(sid);%>;
var json=<% db_QryAdv("select * from tbCardLog where SID="+sid,0); %>;
<% db_Close(); %>

$(function(){
    time=setInterval(ajax,tescape);
	load();
});

function load()
{
    var user=jsonsm.recs[0].SerDef.split(":");
    sip=user[0].substr(4,user[0].length); sport= parseInt(user[1]);
	usercode=user[2];
	password=user[3];
	//console.log("Get ip: "+sip);
	if (jsonsm.recs[0].Ext1 == 0)
	{
		document.getElementById('door').src = "http://"+sip+":"+sport+"/ACT_ID_1";
		//frames["door"].document.forms["formdoor"].action = "http://"+sip+"/ACT_ID_1";
		document.getElementById('formdoor').action = "http://"+sip+":"+sport+"/ACT_ID_1";
	}
	else
	{
		document.getElementById('door').src = "http://"+jsonsm.recs[0].Note+"/ACT_ID_1";
		//frames["door"].document.forms["formdoor"].action = "http://"+sip+"/ACT_ID_1";
		document.getElementById('formdoor').action = "http://"+jsonsm.recs[0].Note+"/ACT_ID_1";
	}
	if(usr !== null && pwd !== null)
	{
		$('#usr').value = usercode;
		$('#pwd').value = password;
	}
	$('#formdoor').submit();
}

function ajax(){
    $.ajax({
        type: "POST",
        url: "omdev/smdat0.asp",
        data: "itype="+itype+"&sid="+sid,
        dataType:"json",
        success: function(msg){
            list3(msg)
        }
    });
}
list3(json);
function list3(data){
	if (data.qry == 'err')
		return ;
    $.each(data.recs,function(i,n){
        $(".SID3328").html(n.SID);
        $(".Addr3328").html(n.Addr);
        $(".Port3328").html(n.Port%256);
        $(".DateUpd3328").html(n.DateUpd);
        if(n.State==0){n.State="正常"}
        else if(n.State==1){n.State="告警"}
        else  if(n.State<0||n.State>1){n.State="故障"}
        $(".State3328").html(n.State);
    });
    $("span:contains('故障'),span:contains('告警'),span:contains('闭合'),span:contains('关闭')").addClass("red").removeClass("ger");
    $("span:contains('正常')").addClass("ger").removeClass("red");
}

</script>
</body>
</html>