<?php
require('startinclude.php');
// aaaaaaaaaaaaa
$camara=parametro('camara',-1);
$ventanan=parametro('ventanan',0);
$iuniquev=$_SERVER['REMOTE_ADDR']."_pf_".$ventanan;
if ($camara==-1) {
	$camara=@apc_fetch($iuniquev);
} else {
	
	apc_store($iuniquev,$camara);
}
if ($camara==0) {
	$anterior_num=apc_fetch('numero_de_camaras');
} else {
	$anterior_num=$camara-1;
}
if ($camara==apc_fetch('numero_de_camaras')) {
	$despues_num=0;
} else {
	$despues_num=$camara+1;
}
$anterior_c="<a href='wprocesotabla.php?camara=".$anterior_num."&ventanan=$ventanan'>&lt;&lt;&lt;</a>&nbsp;&nbsp;&nbsp;";
$despues_c="&nbsp;&nbsp;&nbsp;<a href='wprocesotabla.php?camara=".($despues_num)."&ventanan=$ventanan'>&gt;&gt;&gt;</a>";


// aaaaaaaaaaaaaa
setcookie('estado_camara'.$camara,'sensor');
?>
<head>
<title> No title</title>

<meta name="GENERATOR" content="Namo WebEditor">
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"> 
<META NAME="ROBOTS" CONTENT="NOARCHIVE"> 
<script type='text/javascript' src='ajaxlib/utils/southprojects.js'></script>
<script type='text/javascript' src='jscriptrpc.js'></script>
<script type='text/javascript' src='ajaxlib/utils/progress.js'></script>
<script type='text/javascript' src='ajaxlib/dhtmlwindow.js'></script>
<link href='ajaxlib/dhtmlwindow.css' rel='stylesheet' type='text/css'>
<style type="text/css">

.alerta {
	text-decoration:none;
	background-color:#CC0000;
	FONT-WEIGHT: bold;
	font-family:  Tahoma,Verdana, Helvetica;
	font-size:10px;
}
.offline {
	text-decoration:none;
	background-color:#CCC0C0;
	FONT-WEIGHT: normal;
	font-family:  Tahoma,Verdana, Helvetica;
	font-size:10px;
}

.ok {
	text-decoration:none;
	background-color:#FFFFFF;
	FONT-WEIGHT: normal;
	font-family:  Tahoma,Verdana, Helvetica;
	font-size:10px;
}

</style> 


<script type="text/javascript">
	var loader;


		loader = new southprojects.Progress({
			theme: 'default',
			themePath: "ajaxlib/spextra/themes/progress/"
		});



	function showespere() {
		loader.start('espere..');
		//setTimeout("loader.stop();", 4000);
	}

	function clickcheck(direccion) {
		fetchUrl(direccion, 'transportdiv')
		loader.start('espere..');
	}
	


</script>

<script type="text/javascript">
phprpc='wsensor_rpc.php';
function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

</script>



</head>
<!--
<BODY  onload="javascript:
inicio_ciclo();
">
-->

<body>
<div id="transportdiv" name='transportdiv' style="border-width:1px; border-color:rgb(0,0,240); border-style:solid; display: none;"></div>            



<?php




$totalcamaras=0;


$titulowin=array();
$id_camara=array();
$nsensores=array();


	$camaras_actual=array();
	$camaras=array();
	leer_camaras($camaras);
	leer_camaras_actual($camaras_actual);
	$totalcamaras=count($camaras);


$temp=array();

$tabla=array();



// leer_temperatura($temp,$camara,$maxima,$minima,$estado,$nombre_sensor,$num_temp);
leer_temperatura2($temp,$camara);
leer_estados_historicos(&$tabla,1,1);
echo "<h2 align='left'>$anterior_c".$camaras[$camara]["nombre_camara"]."$despues_c</h2>\n";
echo "<table border='1' width='100%'>\n";
for ($i=0;$i<$temp["num_temp"];$i++) {
	if ($temp[$i]["t"]==-66.6) {
		$check="<input type='checkbox' name='checkb$i' value='1' onclick=\"	clickcheck('wsensor_rpc.php?id=$i&camara=$camara');\">";
	} else {
		$check="<input type='checkbox' name='checkb$i' value='1' onclick=\"	clickcheck('wsensor_rpc.php?id=$i&camara=$camara');\" checked>";
	}
	echo "    <tr>\n";
	echo "        <td width='50%' id='celnombre$i' class='ok' >".$temp[$i]["nombre"]."</td>\n";
	echo "        <td width='30%' id='valor$i' class='ok' >".$temp[$i]["t"]."</td>\n";
	echo "        <td width='20%' id='chk$i' class='ok' >".$check."</td>\n";
	echo "    </tr>\n";
}
echo "</table>\n";
echo "<br>";







?>

<script type="text/javascript">
//document.getElementById('valor0').className='alerta';

//window.parent.window.parent.document.getElementById('spWin0Container').className='spWinRedxpContainer';



</script>
</BODY>
