<?php
ob_start();

header("Expires: Mon, 20 Mar 1998 12:01:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

require_once("Sigma.php");

$tpl =& new HTML_Template_Sigma('.', './template/cache');
$tpl->loadTemplateFile('bal.htm');
$tpl->setVariable('fecha', date("d/m/Y"));

$colores = "";
$archivo = $_GET['file'];
$fila = 1;

if (file_exists($archivo) && is_readable($archivo)) {
    if (!$myxml = simplexml_load_file($archivo))
        echo 'Error al Cargar Archivo BAL.XML';
    else {
		
		$line_count = count($myxml->children());
		
        foreach ($myxml as $node) {
            if ($colores == "grey") {
                $tpl->setVariable('colores', '');
                $colores = "";
            } else {
                $tpl->setVariable('colores', ' class="grey"');
                $colores = "grey";
            }
            
            $tpl->setVariable('nu', BlankSpace($node->Orden));
            $tpl->setVariable('dep', $node->Liga);
            
            $timegame = explode(":", $node->TimeGame);
            $hora     = $timegame[0] . ':' . $timegame[1];
            
            if ($timegame[2] == 'p.' || $timegame[2] == 'P.')
                $meridian = 'PM';
            elseif ($timegame[2] == 'a.' || $timegame[2] == 'A.')
                $meridian = 'AM';
            else
                $meridian = $timegame[2];
            
            $tpl->setVariable('hora1', $hora);
            $tpl->setVariable('espa1', $meridian);
            $tpl->setVariable('vId1', $node->VisTeam);
            
            $tpl->setVariable('eq_visitante1', $node->EquipoVisitante);
            $tpl->setVariable('lId1', $node->LocTeam);
            $tpl->setVariable('eq_local1', utf8_decode($node->EquipoLocal));
            
            $tpl->setVariable('jc_mlv1', utf8_decode($node->PriceMLJCVis));
            $tpl->setVariable('jc_mll1', utf8_decode($node->PriceMLJCLoc));
            
            $tpl->setVariable('jc_rlv1', utf8_decode($node->RLJCVis . ' ' . $node->PriceRLJCVis));
            $tpl->setVariable('jc_rll1', utf8_decode($node->RLJCLoc . ' ' . $node->PriceRLJCLoc));
            
            $tpl->setVariable('total', utf8_decode($node->TotalJC));
            
            if ($fila <= ($line_count / 2)) {
				$tpl->parse('bloque1');
            } else {
				$tpl->parse('bloque2');
            }
            $fila++;
            
        } //for.
    }
    
} //if file_exists.

$tpl->show();
?>