<?php
############################################################################
# A Project of TNET Services, Inc. and Saratoga-Weather.org (Canada/World-ML template set)
############################################################################
#
#   Project:    Sample Included Website Design
#   Module:     sample.php
#   Purpose:    Sample Page
#   Authors:    Kevin W. Reed <kreed@tnet.com>
#               TNET Services, Inc.
#
# 	Copyright:	(c) 1992-2007 Copyright TNET Services, Inc.
############################################################################
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
############################################################################
#	This document uses Tab 4 Settings
############################################################################
require_once("Settings.php");
require_once("common.php");
############################################################################
$TITLE = langtransstr($SITE['organ']) . " - " .langtransstr('Radar');
$showGizmo = true;  // set to false to exclude the gizmo
include("top.php");
############################################################################
?>
</head>
<style type="text/css">
p #imgrad {
	margin-left: 125px;
	border: 4px solid #333;
}
</style>
<body>
<?php
############################################################################
include("header.php");
############################################################################
include("menubar.php");
############################################################################
?>

<div id="main-copy">
  
 
	  <h1><?php langtrans('Radar Lluvia'); ?></h1>
  <h3><?php langtrans('Imagen &uacute;ltima media hora en movimiento'); ?></h3>
      </br>
      </br>
        
  <script type="text/javascript">
				 
				onload = function(){
				var cadena = "http://www.aemet.es/imagenes_d/eltiempo/observacion/radar/";

				function elegir_radar() {
				var valor = formulario.nombre.value;
				if (valor == "mur") return "_r8mu.gif";
				else if (valor == "val") return "_r8va.gif";
				else if (valor == "gen") return "_r8pb.gif";
				else return "_r8pb.gif";
				}

				function error_radar() {
				var valor = formulario.nombre.value;
				if (valor == "mur") return cadena + "r8mu_nodisp.gif";
				else if (valor == "val") return cadena + "r8va_nodisp.gif";
				else if (valor == "gen") return cadena + "r8pb_nodisp.gif";
				else return "r8pb_nodisp.gif";
				}

				function converttime(offset,nac) {
				var minhor;
				var meses = {0:31,1:31,2:28,3:31,4:30,5:31,6:30,7:31,8:31,9:30,10:31,11:30};
				var d = new Date();
				var min = d.getUTCMinutes();
				var min = Math.floor(min/10)*10;
				var hor = d.getUTCHours();
				var dia = d.getUTCDate();
				var mes = d.getUTCMonth() + 1;
				var anho = d.getUTCFullYear();
				if (nac) {
				if (min >= 20 && min <= 40) minhor_10 = 30 - offset;
				else if (min == 50) minhor_10 = 60 - offset;
				else minhor_10 = 0 - offset;
				} 
				else minhor_10 = min - offset;
				if (minhor_10 < 0) {minhor = Math.ceil(Math.abs(minhor_10/60)); minhor_10 = minhor_10 + (60 * minhor); hor = hor - minhor;}
				if (hor < 0) {dia = dia - 1;hor = hor + 24;}
				if (dia < 1) {mes = mes - 1;dia = meses[mes]; if (dia == 28)if (anho % 4 == 0) dia = 29;}
				if (mes < 1) {mes = 12;anho = anho - 1;}
				if (minhor_10 < 10) minhor_10 = "0" + minhor_10;
				if (hor < 10) hor = "0" + hor;
				if (dia < 10) dia = "0" + dia;
				if (mes < 10) mes = "0" + mes;
				return anho+""+mes+dia+hor+minhor_10;

				}

				var i = 0;
				function animacion() { 
				var secuencia = [converttime(70), converttime(60), converttime(50), converttime(40), converttime(30), converttime(20), converttime(10), converttime(10)];
				var meses = {Jan:"01",Feb:"02",Mar:"03",Apr:"04",May:"05",Jun:"06",Jul:"07",Aug:"08",Sep:"09",Oct:"10",Nov:"11",Dec:"12"};
				if (elegir_radar() == "_r8pb.gif") secuencia = [converttime(210,1), converttime(180,1),converttime(150,1), converttime(120,1),converttime(90,1), converttime(60,1), converttime(30,1), converttime(30,1)];
				if (i > secuencia.length-1) i = 0;         
				var imagen_radar = cadena + secuencia[i] + elegir_radar();
				document.getElementById("ajaxradar").src = imagen_radar;
				var hora = secuencia[i].substring(8,10);
				var minuto = secuencia[i].substring(10,12);
				var dia = secuencia[i].substring(6,8); 
				var mes = secuencia[i].substring(4,6);
				var anho = secuencia[i].substring(0,4);
				var horalocal = new Date(mes + "/" + dia + "/" + anho + " " + hora + ":" + minuto + ":00 UTC");
				horalocal = String(horalocal).split(" ");
				horalocal = horalocal[2] + "-" + meses[horalocal[1]] + "-" + horalocal[3] + " " + horalocal[4].substring(0,5);
				document.getElementById("mostrar_hora").innerHTML = horalocal;
				i++;

				}
				setInterval(animacion,1000);
				}
				</script> 
				<form name="formulario" style="float:right; margin-top:-22.4px; margin-right: 136px; " onClick="elegir_radar()">
					 <div align="justify">
						<select name="nombre" size="1" style="font-size:10px;">
						   <option value="val">Radar de Valencia</option>
						   <option value="mur">Radar de Murcia</option>
						  <option value="gen">Radar General</option>
						</select>
					  </div>
				</form> 
				<div align="center">
					<img id="ajaxradar" src="r8pb_nodisp.gif" onerror="this.src=error_radar()" width="500" border="1" style="margin-right:14px" alt="Radar AEMET" />
				</div>
				<div align="center">
					<p  id="mostrar_hora" style="font-weight:bold;color:#800000;height:13px;background-color:white;font-size:90%;width:130px;text-align:center;margin-top:-55px;margin-bottom:40px;padding:3px;position:relative;"></p> 
				</div>
   <h4 style="margin-left:125px">FUENTE:<a href="http://www.aemet.es/es/portada"> Aemet</a></h4>
  

	  
</div><!-- end main-copy -->

<?php
############################################################################
include("footer.php");
############################################################################
# End of Page
############################################################################
?>