var pageStore=null;
var pnoStore=null;

var set_param_0 = function(){
    var j_body = new Object();
    j_body.CMD = 16;
    j_body.COMMID=0;
    j_body.BUSADD=40;
    j_body.VALUE=$("#param_value_0").val();
    j_body.TYPE=1;
    var json_str = 'queryJson:'+JSON.stringify(j_body);
    $.ajax({
       url:"cgi-bin/ws",
       data:json_str,
       timeout:1000,
       type:"POST",
       success:function(result){
    	   alert('#1线缆温度限值已设置');
       }
   });
}

var set_param_1 = function(){
    var j_body = new Object();
    j_body.CMD = 16;
    j_body.COMMID=0;
    j_body.BUSADD=41;
    j_body.VALUE=$("#param_value_1").val();
    j_body.TYPE=1;
    var json_str = 'queryJson:'+JSON.stringify(j_body);
    $.ajax({
       url:"cgi-bin/ws",
       data:json_str,
       timeout:1000,
       type:"POST",
       success:function(result){
    	   alert('#2线缆温度限值已设置');
       }
   });
}

var set_param_2 = function(){
    var j_body = new Object();
    j_body.CMD = 16;
    j_body.COMMID=0;
    j_body.BUSADD=20;
    j_body.VALUE=$("#param_value_2").val();
    j_body.TYPE=1;
    var json_str = 'queryJson:'+JSON.stringify(j_body);
    $.ajax({
       url:"cgi-bin/ws",
       data:json_str,
       timeout:1000,
       type:"POST",
       success:function(result){
    	   alert('电流限值已设置');
       }
   });
}

var set_param_3 = function(){
    var j_body = new Object();
    j_body.CMD = 18;
    j_body.COMMID=0;
    j_body.BUSADD=0;
    j_body.VALUE=0
    var json_str = 'queryJson:'+JSON.stringify(j_body);
    $.ajax({
       url:"cgi-bin/ws",
       data:json_str,
       timeout:1000,
       type:"POST",
       success:function(result){
    	   alert('消音操作已执行');
       }
   });
}

var set_param_4 = function(){
    var j_body = new Object();
    j_body.CMD = 17;
    j_body.COMMID=0;
    j_body.BUSADD=0;
    j_body.VALUE=0
    var json_str = 'queryJson:'+JSON.stringify(j_body);
    $.ajax({
       url:"cgi-bin/ws",
       data:json_str,
       timeout:1000,
       type:"POST",
       success:function(result){
    	   alert('复位操作已执行');
       }
   });
}

var save_ef = function(id){
	if((id==1)||(id=='1')){
	    var j_body = new Object();
	    var j_value = new Object();
	    j_value.VALUE = $("#ef_value_0").val();
	    j_value.NAME= 'TEMP';
	    j_body.CMD = 67;
	    j_body.COMMID=0;
	    j_body.BUSADD=0;
	    j_body.PARAM=j_value;
	    var json_str = 'queryJson:'+JSON.stringify(j_body);
	    $.ajax({
	       url:"cgi-bin/ws",
	       data:json_str,
	       timeout:1000,
	       type:"POST",
	       success:function(result){
	    	   var ret = eval('('+result+')');
		   
	       }
	   });
	}else if((id==2)||(id=='2')){
	    var j_body = new Object();
	    var j_value = new Object();
	    j_value.VALUE = $("#ef_value_1").val();
	    j_value.NAME= 'OVERA';
	    j_body.CMD = 67;
	    j_body.COMMID=0;
	    j_body.BUSADD=0;
	    j_body.PARAM=j_value;
	    var json_str = 'queryJson:'+JSON.stringify(j_body);
	    $.ajax({
	       url:"cgi-bin/ws",
	       data:json_str,
	       timeout:1000,
	       type:"POST",
	       success:function(result){
	    	   var ret = eval('('+result+')');
		   
	       }
	   });
	}else if((id==3)||(id=='3')){
	    var j_body = new Object();
	    var j_value = new Object();
	    j_value.VALUE = $("#ef_value_2").val();
	    j_value.NAME= 'OVERV';
	    j_body.CMD = 67;
	    j_body.COMMID=0;
	    j_body.BUSADD=0;
	    j_body.PARAM=j_value;
	    var json_str = 'queryJson:'+JSON.stringify(j_body);
	    $.ajax({
	       url:"cgi-bin/ws",
	       data:json_str,
	       timeout:1000,
	       type:"POST",
	       success:function(result){
	    	   var ret = eval('('+result+')');
		   
	       }
	   });
	}else if((id==4)||(id=='4')){
	    var j_body = new Object();
	    var j_value = new Object();
	    j_value.VALUE = $("#ef_value_3").val();
	    j_value.NAME= 'LOWV';
	    j_body.CMD = 67;
	    j_body.COMMID=0;
	    j_body.BUSADD=0;
	    j_body.PARAM=j_value;
	    var json_str = 'queryJson:'+JSON.stringify(j_body);
	    $.ajax({
	       url:"cgi-bin/ws",
	       data:json_str,
	       timeout:1000,
	       type:"POST",
	       success:function(result){
	    	   var ret = eval('('+result+')');
		   
	       }
	   });
	}else if((id==5)||(id=='5')){
	    var j_body = new Object();
	    var j_value = new Object();
	    j_value.VALUE = $("#ef_value_4").val();
	    j_value.NAME= 'LEAKA';
	    j_body.CMD = 67;
	    j_body.COMMID=0;
	    j_body.BUSADD=0;
	    j_body.PARAM=j_value;
	    var json_str = 'queryJson:'+JSON.stringify(j_body);
	    $.ajax({
	       url:"cgi-bin/ws",
	       data:json_str,
	       timeout:1000,
	       type:"POST",
	       success:function(result){
	    	   var ret = eval('('+result+')');
		   
	       }
	   });
	}
}

var show_page = function(){
	if(pageStore!=null){
		$("#sys_value_0").val(pageStore.RESULT.Net.LocIP);
		$("#sys_value_1").val(pageStore.RESULT.Net.GateWay);
		$("#sys_value_2").val(pageStore.RESULT.Net.NetMask);
		$("#sys_value_3").val(pageStore.RESULT.Net.MacAddr);
		$("#param_value_0").val(pageStore.RESULT.Term.DeviceCode);
		$("#param_value_1").val(pageStore.RESULT.Term.DeviceID);
		$("#param_value_2").val(pageStore.RESULT.Term.AppKey);
		$("#param_value_3").val(pageStore.RESULT.Term.AgboxUrl);
		$("#param_value_4").val(pageStore.RESULT.Term.ServerID);
		$("#param_value_5").val(pageStore.RESULT.Term.ServerKey);
		$("#ef_value_0").val(pageStore.RESULT.ELECFILE.TEMP);
		$("#ef_value_1").val(pageStore.RESULT.ELECFILE.OVERA);
		$("#ef_value_2").val(pageStore.RESULT.ELECFILE.OVERV);
		$("#ef_value_3").val(pageStore.RESULT.ELECFILE.LOWV);
		$("#ef_value_4").val(pageStore.RESULT.ELECFILE.LEAKA);
		if(pageStore.RESULT.Term.AgboxEnabled==1)
			$("#param_value_6").attr("checked","checked");
		else
			$("#param_value_6").attr("checked",false);
		if(pageStore.RESULT.Term.ServerEnabled==1)
			$("#param_value_7").attr("checked","checked");
		else
			$("#param_value_7").attr("checked",false);
		if(pageStore.RESULT.List.length>0){
			var n;
			for(n=0;n<pageStore.RESULT.List.length;n++){
				var idx = pageStore.RESULT.List[n].Id;
				if((idx<512)&&(idx>=0)){
					$("#iotid_"+idx).html(pageStore.RESULT.List[n].DeviceCode);
					$("#istid_"+idx).html(pageStore.RESULT.List[n].DeviceID);
					switch(pageStore.RESULT.List[n].DeviceType){
						case 0:
						case '0':
							$("#isttype_"+idx).html('未设置');
						break;
						case 1:
						case '1':
							$("#isttype_"+idx).html('用水数据采集装置');
						break;
						case 2:
						case '2':
							$("#isttype_"+idx).html('紧急（求助）按钮');
						break;
						case 3:
						case '3':
							$("#isttype_"+idx).html('电气火灾监控探测器');
						break;
						case 4:
						case '4':
							$("#isttype_"+idx).html('智慧用电探测器');
						break;
						case 5:
						case '5':
							$("#isttype_"+idx).html('可燃气体探测器');
						break;
						case 6:
						case '6':
							$("#isttype_"+idx).html('火灾探测器');
						break;
						case 7:
						case '7':
							$("#isttype_"+idx).html('门体开启状态探测装置');
						break;
						case 8:
						case '8':
							$("#isttype_"+idx).html('二次供水探测装置（井盖）');
						break;
						case 9:
						case '9':
							$("#isttype_"+idx).html('二次供水探测装置（含水位告警）');
						break;
						case 10:
						case '10':
							$("#isttype_"+idx).html('窨井盖探测装置');
						break;
						case 11:
						case '11':
							$("#isttype_"+idx).html('窨井盖探测装置（含水位告警）');
						break;
						case 12:
						case '12':
							$("#isttype_"+idx).html('消防占道探测装置');
						break;
						case 13:
						case '13':
							$("#isttype_"+idx).html('电梯运行采集探测装置');
						break;
						case 14:
						case '14':
							$("#isttype_"+idx).html('水质监测采集探测装置');
						break;
						case 15:
						case '15':
							$("#isttype_"+idx).html('室内消火栓');
						break;
						case 16:
						case '16':
							$("#isttype_"+idx).html('室外消火栓');
						break;
						case 17:
						case '17':
							$("#isttype_"+idx).html('喷淋水压探测器');
						break;
						case 18:
						case '18':
							$("#isttype_"+idx).html('水泵探测装置');
						break;
						default:
							$("#isttype_"+idx).html('未定义');
						break;
					}
				}else
					break;
			}
		}
	}
	if(pnoStore!=null){
		var n,cno,pno;
		if(pnoStore.RESULT.IOT_LIST.length>0){
			for(n=0;n<pnoStore.RESULT.IOT_LIST.length;n++){
				cno = pnoStore.RESULT.IOT_LIST[n].COMM;
				pno = pnoStore.RESULT.IOT_LIST[n].ADDR;
				if((cno>=0)&&(cno<4)&&(pno>=0)&&(pno<256)){
					$("#name_"+cno+"_"+pno).html(pnoStore.RESULT.IOT_LIST[n].NAME);
					switch(pnoStore.RESULT.IOT_LIST[n].PNO_TYPE){
					case 0:
					case '0':
						$("#pnotype_"+cno+"_"+pno).html("不监控");
						break;
					case 1:
					case '1':
						$("#pnotype_"+cno+"_"+pno).html("开关量输入");
						break;
					case 2:
					case '2':
						$("#pnotype_"+cno+"_"+pno).html("模拟量输入");
						break;
					case 3:
					case '3':
						$("#pnotype_"+cno+"_"+pno).html("开关量输出");
						break;
					case 4:
					case '4':
						$("#pnotype_"+cno+"_"+pno).html("模拟量输出");
						break;
					}
					switch(pnoStore.RESULT.IOT_LIST[n].PNO_VALUE){
					case 0:
					case '0':
						if(pnoStore.RESULT.IOT_LIST[n].PNO_TYPE==1){
							$("#pnovalue_"+cno+"_"+pno).html("0为开（告警），1为关（正常)");
						}else if(pnoStore.RESULT.IOT_LIST[n].PNO_TYPE==3){
							$("#pnovalue_"+cno+"_"+pno).html("电平型");
						}else if(pnoStore.RESULT.IOT_LIST[n].PNO_TYPE==2){
							$("#pnovalue_"+cno+"_"+pno).html("无上下限告警");
						}
						break;
					case 1:
					case '1':
						if(pnoStore.RESULT.IOT_LIST[n].PNO_TYPE==1){
							$("#pnovalue_"+cno+"_"+pno).html("1为开（告警），0为关（正常)");
						}else if(pnoStore.RESULT.IOT_LIST[n].PNO_TYPE==3){
							$("#pnovalue_"+cno+"_"+pno).html("脉冲型");
						}else if(pnoStore.RESULT.IOT_LIST[n].PNO_TYPE==2){
							$("#pnovalue_"+cno+"_"+pno).html("上限告警");
						}
						break;
					case 2:
					case '2':
						if(pnoStore.RESULT.IOT_LIST[n].PNO_TYPE==2){
							$("#pnovalue_"+cno+"_"+pno).html("下限告警");
						}
						break;
					case 3:
					case '3':
						if(pnoStore.RESULT.IOT_LIST[n].PNO_TYPE==2){
							$("#pnovalue_"+cno+"_"+pno).html("上下限告警");
						}
						break;
					}
					switch(pnoStore.RESULT.IOT_LIST[n].PNO_ALARM){
					case 0:
					case '0':
						$("#pnoalarm_"+cno+"_"+pno).html("不告警");
						break;
					case 1:
					case '1':
						$("#pnoalarm_"+cno+"_"+pno).html("次要告警");
						break;
					case 2:
					case '2':
						$("#pnoalarm_"+cno+"_"+pno).html("重要告警");
						break;
					}
					$("#alarmh_"+cno+"_"+pno).html(pnoStore.RESULT.IOT_LIST[n].ALARM_H);
					$("#alarml_"+cno+"_"+pno).html(pnoStore.RESULT.IOT_LIST[n].ALARM_L);
				}
			}
		}
	}
}

var save_data = function(){
    var j_body = new Object();
    var j_value = new Object();
    j_value.DEVICECODE = $("#param_value_0").val();
    j_value.DEVICEID= $("#param_value_1").val();
    j_value.APPKEY = $("#param_value_2").val();
    j_value.AGBOXURL = $("#param_value_3").val();
    j_value.SERVERID = $("#param_value_4").val();
    j_value.SERVERKEY = $("#param_value_5").val();
    j_value.AGBOXENABLED = $("#param_value_6").is(':checked')?1:0;
    j_value.SERVERENABLED = $("#param_value_7").is(':checked')?1:0;
    j_body.CMD = 65;
    j_body.COMMID=0;
    j_body.BUSADD=0;
    j_body.PARAM=j_value;
    var json_str = 'queryJson:'+JSON.stringify(j_body);
    $.ajax({
       url:"cgi-bin/ws",
       data:json_str,
       timeout:1000,
       type:"POST",
       success:function(result){
    	   var ret = eval('('+result+')');
           
       }
   });
}

var save_value = function(){
    var j_body = new Object();
    var j_value = new Object();
    j_value.LOCIP = $("#sys_value_0").val();
    j_value.GATEWAY= $("#sys_value_1").val();
    j_value.NETMASK = $("#sys_value_2").val();
    j_value.MACADDR = $("#sys_value_3").val();
    j_body.CMD = 68;
    j_body.COMMID=0;
    j_body.BUSADD=0;
    j_body.PARAM=j_value;
    var json_str = 'queryJson:'+JSON.stringify(j_body);
    $.ajax({
       url:"cgi-bin/ws",
       data:json_str,
       timeout:1000,
       type:"POST",
       success:function(result){
    	   var ret = eval('('+result+')');
           
       }
   });
}

var chk_ip = function(){
   window.open('ftp://'+pageStore.RESULT.Net.LocIP+"/etc/network/interfaces");
}

var reboot = function(){
    var j_body = new Object();
    j_body.CMD = 254;
    j_body.COMMID=0;
    j_body.BUSADD=0;
    j_body.VALUE=0;
    var json_str = 'queryJson:'+JSON.stringify(j_body);
    $.ajax({
       url:"cgi-bin/ws",
       data:json_str,
       timeout:1000,
       type:"POST",
       success:function(result){
    	   pageStore = eval('('+result+')');
       }
   });
}

var restart = function(){
    var j_body = new Object();
    j_body.CMD = 255;
    j_body.COMMID=0;
    j_body.BUSADD=0;
    j_body.VALUE=0;
    var json_str = 'queryJson:'+JSON.stringify(j_body);
    $.ajax({
       url:"cgi-bin/ws",
       data:json_str,
       timeout:1000,
       type:"POST",
       success:function(result){
    	   pageStore = eval('('+result+')');
       }
   });
}

var reset_dev = function(){
	var idx = $("#dev_param_0").val();
	if((idx>=0)&&(idx<512)&&(pageStore.RESULT.List.length>0)){
		var n;
		for(n=0;n<pageStore.RESULT.List.length;n++){
			if(pageStore.RESULT.List[n].Id==idx){
				$("#dev_param_1").val(pageStore.RESULT.List[n].DeviceCode);
				$("#dev_param_2").val(pageStore.RESULT.List[n].DeviceID);
				$("#dev_param_3").val(pageStore.RESULT.List[n].DeviceType);				
				break;
			}
		}
	}
}

var set_combox = function(type){
	var div = document.getElementById('pno_param_4');
	switch(type){
	case 0:
	case '0':
		div.innerHTML = "<option value=\"0\">未设置</option>" ;
		break;
	case 1:
	case '1':
		div.innerHTML = "<option value=\"0\">0为开（告警），1为关（正常)</option><option value=\"1\">1为开（告警），0为关（正常)</option>" ;
		break;
	case 2:
	case '2':
		div.innerHTML = "<option value=\"0\">无上下限告警</option><option value=\"1\">上限告警</option><option value=\"2\">下限告警</option><option value=\"3\">上下限告警</option>" ;
		break;
	case 3:
	case '3':
		div.innerHTML = "<option value=\"0\">电平型</option><option value=\"1\">脉冲型</option>" ;
		break;
	default:
		div.innerHTML = "<option value=\"0\">未设置</option>" ;
		break;
	}
}

var close_pno = function()
{
	document.getElementById('dialog2').style.display='none';
}

var reset_pno = function(){
	var cno = $("#pno_param_0").val();
	var pno = $("#pno_param_1").val();
	if((cno>=0)&&(cno<4)&&(pno>=0)&&(pno<256)){
		if(pnoStore.RESULT.IOT_LIST.length>0){
			var n;
			for(n=0;n<pnoStore.RESULT.IOT_LIST.length;n++){
				if((pnoStore.RESULT.IOT_LIST[n].COMM==cno)
					&&(pnoStore.RESULT.IOT_LIST[n].ADDR==pno)){
					$("#pno_param_2").html(pnoStore.RESULT.IOT_LIST[n].NAME);
					$("#pno_param_3").val(pnoStore.RESULT.IOT_LIST[n].PNO_TYPE);
					set_combox(pnoStore.RESULT.IOT_LIST[n].PNO_TYPE);
					$("#pno_param_4").val(pnoStore.RESULT.IOT_LIST[n].PNO_VALUE);
					$("#pno_param_5").val(pnoStore.RESULT.IOT_LIST[n].PNO_ALARM);
					$("#pno_param_6").val(pnoStore.RESULT.IOT_LIST[n].ALARM_H);
					$("#pno_param_7").val(pnoStore.RESULT.IOT_LIST[n].ALARM_L);
					break;
				}
			}
		}
	}
}

var settab = function(id){
	$("#app_tab").removeClass("on_tab");
	$("#sys_tab").removeClass("on_tab");
	$("#pno_tab").removeClass("on_tab");
	$("#ef_tab").removeClass("on_tab");
	$("#app_set").css('display','none');
	$("#sys_set").css('display','none');
	$("#pno_set").css('display','none');
	$("#ef_set").css('display','none');
	switch(id){
		case 1:
			$("#app_tab").addClass("on_tab");
			$("#app_tab").css('z-index',501);
			$("#sys_tab").css('z-index',499);
			$("#pno_tab").css('z-index',499);
			$("#ef_tab").css('z-index',499);
			$("#app_set").css('display','block');
		break;
		case 2:
			$("#sys_tab").addClass("on_tab");
			$("#app_tab").css('z-index',499);
			$("#sys_tab").css('z-index',501);
			$("#pno_tab").css('z-index',499);
			$("#ef_tab").css('z-index',499);
			$("#sys_set").css('display','block');
		break;
		case 3:
			$("#pno_tab").addClass("on_tab");
			$("#app_tab").css('z-index',499);
			$("#sys_tab").css('z-index',499);
			$("#pno_tab").css('z-index',501);
			$("#ef_tab").css('z-index',499);
			$("#pno_set").css('display','block');
		break;
		case 4:
			$("#ef_tab").addClass("on_tab");
			$("#app_tab").css('z-index',499);
			$("#sys_tab").css('z-index',499);
			$("#pno_tab").css('z-index',499);
			$("#ef_tab").css('z-index',501);
			$("#ef_set").css('display','block');
		break;
	}
}

var save_dev = function(){
	var idx = $("#dev_param_0").val();
	if((idx>=0)&&(idx<512)){
    	var j_body = new Object();
		var j_value = new Object();
		j_value.ID = parseInt($("#dev_param_0").val());
		j_value.DEVICECODE = $("#dev_param_1").val();
		j_value.DEVICEID= $("#dev_param_2").val();
		j_value.DEVICETYPE = parseInt($("#dev_param_3").val());
		j_value.ENABLED = $("#dev_param_3").val()>0?1:0;
		j_body.CMD = 66;
		j_body.COMMID=0;
		j_body.BUSADD=0;
		j_body.PARAM=j_value;
		var json_str = 'queryJson:'+JSON.stringify(j_body);
		$.ajax({
		   url:"cgi-bin/ws",
		   data:json_str,
		   timeout:1000,
		   type:"POST",
		   success:function(result){
			   var ret = eval('('+result+')');
		       
		   }
	   });
	}
	document.getElementById('dialog').style.display='none';
	get_data();
}

var typechange = function(){
	var type = $("#pno_param_3").val();
	set_combox(type);
}

var get_data = function(){
	var i,j;
	var box = document.getElementById('devlist');
	box.innerHTML="";
	for(i=0;i<512;i++){
		var line = document.createElement("div");
		if(i&1)
			line.style.background='rgba(128,128,128,.2)';
		line.style.width='720px';
		line.style.height='40px';
		box.appendChild(line);
		var idx = document.createElement("div");
		idx.style.width='40px';
		idx.style.height='20px';
		idx.style.paddingTop='10px';
		idx.style.color='#fff';
		idx.style.textAlign='right';
		idx.style.float='left';
		idx.innerHTML=(i+1);
		line.appendChild(idx);
		var iotid = document.createElement("div");
		iotid.id = 'iotid_'+i;
		iotid.style.width='160px';
		iotid.style.height='20px';
		iotid.style.paddingTop='10px';
		iotid.style.paddingLeft='10px';
		iotid.style.overflow='hidden';
		iotid.style.color='#fff';
		iotid.style.float='left';
		iotid.innerHTML='';
		line.appendChild(iotid);
		var istid = document.createElement("div");
		istid.id = 'istid_'+i;
		istid.style.width='160px';
		istid.style.height='20px';
		istid.style.paddingTop='10px';
		istid.style.paddingLeft='10px';
		istid.style.color='#fff';
		istid.style.overflow='hidden';
		istid.style.float='left';
		istid.innerHTML='';
		line.appendChild(istid);
		var isttype = document.createElement("div");
		isttype.id = 'isttype_'+i;
		isttype.style.width='240px';
		isttype.style.height='20px';
		isttype.style.paddingTop='10px';
		isttype.style.paddingLeft='10px';
		isttype.style.color='#fff';
		isttype.style.overflow='hidden';
		isttype.style.float='left';
		isttype.innerHTML='未定义';
		line.appendChild(isttype);
		var edit = document.createElement("div");
		edit.id = 'edit_'+i;
		edit.setAttribute('selfid',i);
		edit.style.cursor='pointer';
		edit.style.width='40px';
		edit.style.height='20px';
		edit.style.paddingTop='10px';
		edit.style.paddingLeft='10px';
		edit.style.color='#fff';
		edit.style.overflow='hidden';
		edit.style.float='left';
		edit.innerHTML='编辑';
		edit.onclick = function(){
			var idx = this.getAttribute('selfid');
			if((idx>=0)&&(idx<512)){
				document.getElementById('dialog').style.display='block';
				$("#dev_param_0").val(idx);
				reset_dev();
			}
		};
		line.appendChild(edit);
	}
	var pno_set = document.getElementById('pno_set');
	pno_set.innerHTML="";
	for(i=0;i<4;i++){
		for(j=0;j<256;j++){
			var line = document.createElement("div");
			if(j&1)
				line.style.background='rgba(128,128,128,.2)';
			line.style.width='780px';
			line.style.height='40px';
			pno_set.appendChild(line);
			var cno = document.createElement("div");
			cno.id='cno_'+i+'_'+j;
			cno.style.width='20px';
			cno.style.height='20px';
			cno.style.paddingTop='10px';
			cno.style.color='#fff';
			cno.style.textAlign='right';
			cno.style.float='left';
			cno.innerHTML=(i+1);
			line.appendChild(cno);
			var pno = document.createElement("div");
			pno.id='pno_'+i+'_'+j;
			pno.style.width='40px';
			pno.style.height='20px';
			pno.style.paddingTop='10px';
			pno.style.color='#fff';
			pno.style.textAlign='right';
			pno.style.float='left';
			pno.innerHTML=(j);
			line.appendChild(pno);
			var name = document.createElement("div");
			name.id='name_'+i+'_'+j;
			name.style.width='160px';
			name.style.overflow='hidden';
			name.style.height='20px';
			name.style.paddingTop='10px';
			name.style.color='#fff';
			name.style.paddingLeft='10px';
			name.style.float='left';
			name.innerHTML=('name_'+i+'_'+j);
			line.appendChild(name);
			var pnotype = document.createElement("div");
			pnotype.id='pnotype_'+i+'_'+j;
			pnotype.style.width='80px';
			pnotype.style.overflow='hidden';
			pnotype.style.height='20px';
			pnotype.style.paddingTop='10px';
			pnotype.style.color='#fff';
			pnotype.style.paddingLeft='10px';
			pnotype.style.float='left';
			pnotype.innerHTML=('不监控');
			line.appendChild(pnotype);
			var pnovalue = document.createElement("div");
			pnovalue.id='pnovalue_'+i+'_'+j;
			pnovalue.style.width='80px';
			pnovalue.style.overflow='hidden';
			pnovalue.style.height='20px';
			pnovalue.style.paddingTop='10px';
			pnovalue.style.color='#fff';
			pnovalue.style.paddingLeft='10px';
			pnovalue.style.float='left';
			pnovalue.innerHTML=('未定义');
			line.appendChild(pnovalue);
			var pnoalarm = document.createElement("div");
			pnoalarm.id='pnoalarm_'+i+'_'+j;
			pnoalarm.style.width='80px';
			pnoalarm.style.overflow='hidden';
			pnoalarm.style.height='20px';
			pnoalarm.style.paddingTop='10px';
			pnoalarm.style.color='#fff';
			pnoalarm.style.paddingLeft='10px';
			pnoalarm.style.float='left';
			pnoalarm.innerHTML=('不告警');
			line.appendChild(pnoalarm);
			var alarmh = document.createElement("div");
			alarmh.id='alarmh_'+i+'_'+j;
			alarmh.style.width='80px';
			alarmh.style.overflow='hidden';
			alarmh.style.height='20px';
			alarmh.style.paddingTop='10px';
			alarmh.style.color='#fff';
			alarmh.style.paddingLeft='10px';
			alarmh.style.float='left';
			line.appendChild(alarmh);
			var alarml = document.createElement("div");
			alarml.id='alarml_'+i+'_'+j;
			alarml.style.width='80px';
			alarml.style.overflow='hidden';
			alarml.style.height='20px';
			alarml.style.paddingTop='10px';
			alarml.style.color='#fff';
			alarml.style.paddingLeft='10px';
			alarml.style.float='left';
			line.appendChild(alarml);
			var pnoedit = document.createElement("div");
			pnoedit.id = 'pnoedit_'+i;
			pnoedit.setAttribute('selfcno',i);
			pnoedit.setAttribute('selfpno',j);
			pnoedit.style.cursor='pointer';
			pnoedit.style.width='40px';
			pnoedit.style.height='20px';
			pnoedit.style.paddingTop='10px';
			pnoedit.style.paddingLeft='10px';
			pnoedit.style.color='#fff';
			pnoedit.style.overflow='hidden';
			pnoedit.style.float='left';
			pnoedit.innerHTML='编辑';
			pnoedit.onclick = function(){
				var cno = this.getAttribute('selfcno');
				var pno = this.getAttribute('selfpno');
				if((cno>=0)&&(cno<4)&&(pno>=0)&&(pno<256)){
					document.getElementById('dialog2').style.display='block';
					$("#pno_param_0").val(cno);
					$("#pno_param_1").val(pno);
					reset_pno();
				}
			};
			line.appendChild(pnoedit);
		}
	}
	var j_body = new Object();
	j_body.CMD = 64;
	j_body.COMMID=0;
	j_body.BUSADD=0;
	j_body.VALUE=0;
	var json_str = 'queryJson:'+JSON.stringify(j_body);

	$.ajax({
		url:"cgi-bin/ws",
		data:json_str,
		timeout:1000,
		type:"POST",
		success:function(result){
		   pageStore = eval('('+result+')');
			var j_body = new Object();
			j_body.CMD = 19;
			j_body.COMMID=0;
			j_body.BUSADD=0;
			j_body.VALUE=0;
			var json_str = 'queryJson:'+JSON.stringify(j_body);
			$.ajax({
				url:"cgi-bin/ws",
				data:json_str,
				timeout:1000,
				type:"POST",
				success:function(result){
					pnoStore = eval('('+result+')');
				   	show_page();
				}
			});
		}
	});
}
