<?php
require("../../inc/header.inc");
require("../serverStatusImprove/function.inc");
?>

<body onload="javascript:adjust();" onresize="javascript:adjust();" leftmargin="15" style="overflow:hidden;overflow-x:hidden;overflow-y:hidden;">


<?php
$global_id=0;
function AssignID()
{
	global $global_id;
	
	$id="ID_{$global_id}";
	$global_id++;
	return $id;
}

?>

<?php
adjust_head();
adjust_title_head();

echo "<FORM NAME=\"downForm\">";
echo "<table id=\"table_up\" border=\"0\" width=\"100%\">";
	echo "<tr>";
		echo "<td width=\"50%\">";
		echo "Advanced > IPTRANS Status";
		echo "</td>";
		echo "<td width=\"50%\" align=\"right\" title=\"Help\">";
		//showHelp($helpId);
		echo "</td>";
	echo "</tr>";
	
	echo "<tr>";
		echo "<td width=\"50%\">";
		echo "&nbsp;";
		echo "</td>";
		echo "<td width=\"50%\" align=\"right\" title=\"Clear\">";
		echo "<a href=\"./plat_test_status.php\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">Back</a>";
		echo "</td>";
	echo "</tr>";
echo "</table>";


adjust_title_tail();
adjust_content_head();

if(0)
{
	echo "subSysNo=$subSysNo,platID=$platID<br>";
}

$config=parse_ini_file("config.ini",true);
$config_count=sizeof($config);

$platDetailInfo=GetDetailPlatInfo($sysNo,$subSysNo,0);

if(0)
{
	echo "<pre>";
	print_r($plat);
	echo "</pre>";
}

$table_title="<font color=\"#0000FF\">IPTRANS</font>( Version:";
$id=AssignID();
$table_title.="<span id=\"{$id}\" style=\"color:#000000;\">$id</span>";
$table_title.=",";

$table_title.=" Status:";
$id=AssignID();
$table_title.="<span id=\"{$id}\" style=\"color:#000000;\">$id</span>";
$table_title.=",";

$table_title.="RefreshTime:";
$id=AssignID();
$table_title.="<span id=\"{$id}\" style=\"color:#000000;\">4id</span>";
$table_title.=")";


  echo "<br><center>$table_title</center>";
	
	echo "<table width=\"100%\" border=\"1\" cellpadding=\"2\" cellspacing=\"0\" bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\" bgcolor=\"#FFFFFF\">";
	echo "<tr bgcolor=\"#E6E6E6\">";
	
	echo "<td align=\"left\" >Port no</td>";
	echo "<td align=\"left\" >Status</td>";
	echo "<td align=\"left\" >Port no</td>";
	echo "<td align=\"left\" >Status</td>";
	echo "<td align=\"left\" >Port no</td>";
	echo "<td align=\"left\" >Status</td>";
	echo "<td align=\"left\" >Port no</td>";
	echo "<td align=\"left\" >Status</td>";
	echo "</tr>";


for($i=0;$i<8;$i++)
{
	echo "<tr>";
		for($j=0;$j<4;$j++)
		{	
		  	
      $dis_no=4950+($j)*8+$i;
		  echo "<td>";
		  echo $dis_no;
			echo "</td>";
			
			$id=AssignID();
			echo "<td>";
			$dis_port=($j)*8+$i;
			echo "<span id=\"{$id}\" style=\"color:#000000;\">$id</span>";
			echo "</td>";
    }
  echo "</tr>";
}

echo "</table>";


//Remark Table
echo "<table border=\"0\" width=\"100%\" cellpadding=1 cellspacing=0>";
	echo "<tr>";
		echo "<td width=\"50%\" align=\"left\">";
		echo "Remarks:  <font color=\"blue\">Y</font> = Normal,    <font color=\"red\">N</font> = Abnormal,   -- = None.";
		echo "</td>";
		echo "<td width=\"50%\" align=\"right\" title=\"Clear\">";
		echo "<a href=\"plat_test_status.php\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">Back</a>";
		echo "</td>";
	echo "</tr>";
echo "</table>";

adjust_content_tail();
?>

<script language="JavaScript">

function updateStatus(sysNo,subSysNo)
{
	var fixurl="./iptrans_status_update.php?sysNo="+sysNo+"&subSysNo="+subSysNo;
	var browserr = navigator.appName;
	if(browserr == "Microsoft Internet Explorer")
	{
		request_oo = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
		request_oo = new XMLHttpRequest();
	}
	
	request_oo.open("GET",fixurl,"false");

	request_oo.onreadystatechange=function()
	{ 
		checUpdateState(); 
	}
	request_oo.send(null);
	setTimeout("updateStatus('"+sysNo+"','"+subSysNo+"')", 10000);
}


function checUpdateState()
{
	//not
	if(request_oo.readyState == 3)
	{
		//alert("not finish");
	}
	if(request_oo.readyState == 4)
	{
		var response = request_oo.responseText;
		response=response.replace(/(^\s*)|(\s*$)/g, "");
		//alert(response);
		if(response == "")
			return;

		var objects=response.split(';');
		//alert(objects.length);
		for(i=0;i<objects.length;i++)
		{
			
			var items=objects[i].split(',');
			var item_id=items[0].replace(/(^\s*)|(\s*$)/g, "");
			if(document.getElementById(item_id) == null)
				continue;
				
			var item_display=items[1].replace(/(^\s*)|(\s*$)/g, "");
			var item_value=items[2].replace(/(^\s*)|(\s*$)/g, "");
			var item_color=items[3].replace(/(^\s*)|(\s*$)/g, "");
			
			if(item_display == 'Rect')
			{
				document.getElementById(item_id).value=GetLabel(item_value);
				document.getElementById(item_id).style.color='#3366aa';
			}
			else if(item_display == 'layerShow')
			{
				document.getElementById(item_id).style.display='';
			}
			else if(item_display == 'layerHide')
			{
				document.getElementById(item_id).style.display='none';
			}
			else
			{
				document.getElementById(item_id).style.color=item_color;
				document.getElementById(item_id).innerHTML=item_value;
				if(item_display == 'none')
					document.getElementById(item_id).style.display='none';
				else
					document.getElementById(item_id).style.display='';
					
			}
			
		}
		
	}
}


</script>
<?php
	echo "\n<script language=\"JavaScript\">\n";
	echo "updateStatus('$sysNo','$subSysNo');\n";
	echo "</script>\n";
?>

