<?php 
session_start();
foreach($_GET as $campo => $valor){${$campo}=trim($valor);} 
foreach($_POST as $campo => $valor){${$campo}=trim($valor);} 
$user_codigo=$_SESSION['user_codigo'];
$user0=data_maes('user',$user_codigo);
// if(empty($user_codigo) and $format>1){include('user_login0.php');die();}
if(empty($user_codigo) and $format>1){include('user_login0.php');return;}

include_once('lib_main.php');
include_once('lib_soft.php');
include_once('lib_soft.js');

if(!empty($empr)){$link_data=msql_connect('','','',$empr); $cfg_empr=$empr;}
//include('lib_soft.php');

// $formato
// 1 Tienda online
// 2 punto de venta (bodega stock foto)
// 3 proforma (cliente stock foto)
// 4 carrito 
// 5 mantenimiento basico (bodega stock foto) ==> linea,marca,color,fotos,precios

//$docu = 'liup';
echo $save_error;
echo '<div id="informacion">';
{
echo '<div id="filtros">';
{
echo '<div id="cabecera" style = "vertical-align:top;">';
{
$sql_liup='select idnum1, hovi, team from liup1 where hovi = 1 and idsoft ='.$idnum;
$res_liup=msql_query($sql_liup,$link_data);
$team1=msql_result($res_liup,0,'team');
$idnumh=msql_result($res_liup,0,'idnum1');
  
$sql_liup='select idnum1, hovi, team from liup1 where hovi = 2 and idsoft ='.$idnum;
$res_liup=msql_query($sql_liup,$link_data);
$team2=msql_result($res_liup,0,'team');
$idnumv=msql_result($res_liup,0,'idnum1');


$sql_soft='select * from soft1 where idnum1 ='.$idnum;
$res_soft=msql_query($sql_soft,$link_data);

$xtitle = "DATOS JUEGO"  ;
  
$liga    = msql_result($res_soft,0,'liga');
$torn    = msql_result($res_soft,0,'torn');
$jornada = msql_result($res_soft,0,'jornada');
$tipo    = msql_result($res_soft,0,'tipo');
$fechag  = msql_result($res_soft,0,'fecha');
$horag    = msql_result($res_soft,0,'horag');

$sql_team='select team_descri from team0 where team_codigo ="'.$team1. '" ';
$res_team=msql_query($sql_team,$link_data);
$team1_des = msql_result($res_team,0,'team_descri');

$sql_team='select team_descri from team0 where team_codigo ="'.$team2. '" ';
$res_team=msql_query($sql_team,$link_data);
$team2_des = msql_result($res_team,0,'team_descri');


//echo '*/*/*/*'.$sql_soft.' - '.$jornada;

$zid='liga';
$ztabla='liga';
$zlabel='Liga';
$zvalue=$liga;
$zondblclick='{document.getElementById("'.$zid.'").removeAttribute("disabled");}';     
// $zonchange='{location.href="?scri='.basename(__FILE__,'.php').'&'.$zid.'="+document.getElementById("'.$zid.'").value;}';
$zonchange='{fn_consulta(event);}';
$zonblur=$zonchange;
$zreado=1;
include('ele_select.php');

$zid='torn';
$ztabla='torn';
$zlabel='Torneo';
$zvalue=$torn;
$zreado=1;
include('ele_select.php');

$zid    = 'tipo';
$zlabel = 'Tipo';
$zvalue = $tipo ;
$zoptions ="AM,AMISTOSO;CA,CAMPEONATO;PO,PLAYOFF";
$zreado = 1;
include('ele_select.php');

//echo '*/*/*/*/* Jornada '.$jornada ;
$zid    = 'jornada';
$zlabel = 'Jornada';
$zvalue = $jornada; 
$zreado = 1;
include('ele_input.php');


$zid='fechag';
$ztype='date';
$zlabel='Fecha';
$zvalue=$fechag;
$zdefa=$fechag;    
include('ele_input.php');  

$zobj=1;
$zid='horag';
$ztype='time';
$zlabel='Hora';
$zvalue=$horag;
$zdefa=$horag;    
include('ele_input.php');  

$zvalue=$cancha; $zlabel='Cancha'; $zid='cancha'; $ztodo=0;
$zoptions='1;2;3;4;';
include('ele_select.php');

include('ele_break.php');

if ($tiempo == 'T')
   $equipo = $team1 ;
else
   $equipo = $team2 ;

if ($entrada == 0)  
   {
     $equipo  = $team1;
     $entrada = 1;
     $outi    = 0;
     $tiempo  = 'T';
     $strikp  = 0 ;
     $bolasp  = 0;
     $ponche  = 0;
     $lanzap  = 0;
   }
   
  
$sql_pit='select enti_descri, team_descri from liup1 left join liup2 on idnum1 = idnum2 left join enti0 on enti_codigo = jugador left join team0 on team_codigo = "'.$equipo.'" where posi = 1 and idsoft ='.$idnum.' and team = "'.$equipo.'"'; 
$res_pit=msql_query($sql_pit,$link_data);
$nom_pit=msql_result($res_pit,0,'enti_descri');
$nom_tea=msql_result($res_pit,0,'team_descri');
  
$zid='nom_pit';
$zlabel='Pitcher - '.$nom_tea;
$zvalue=$nom_pit;
$zreado=1;  

include('ele_input.php');  

$zid='entrada';
$zclass='numeric-int';
$zlabel='Inning';
$zvalue=$entrada; 
$zwidth=3;
include('ele_input.php');  

$zid='tiempo';
$zlabel='Parte';
$zvalue=$tiempo; 
$zoptions='T,TOP;B,BOTTOM';
include('ele_select.php');  

$zid='outi';
$zlabel='Out';
$zvalue=$outi; 
$zwidth=3;
$zreado=1;  
include('ele_input.php');  

$zid='lanzap';
$zlabel='Pitcheos';
$zvalue=$lanzap; 
$zwidth=3;
$zreado=1;  
include('ele_input.php');  

$zid='bolasp';
$zlabel='Bolas';
$zvalue=$bolasp; 
$zwidth=3;
$zreado=1;  
include('ele_input.php');  

$zid='strikp';
$zlabel='Strick';
$zvalue=$strikp; 
$zwidth=8;
$zreado=1;  
include('ele_input.php');  
  
$zid='ponche';
$zlabel='Ponchados';
$zvalue=$ponche; 
$zwidth=3;
$zreado=1;  
include('ele_input.php');  

  
//echo '<a href="fnContulta"> <img src="https://vcrxol.com/_otro/bolasoft.png" alt="Play Ball" width="50" height="50" title = "Play Ball"> </a>';
echo '<img src="https://vcrxol.com/_otro/bolasoft.png" alt="Play Ball" width="50" height="50" title = "Play Ball" onclick="fn_activa(1)">';
include('ele_break.php');
echo "<div id='ining'>";
  {
         
     echo '<table align="center">';
     echo '<thead>';
     echo '<tr>';
     echo '<th>TEAMS</th>';
     echo '<th>1</th>';
     echo '<th>2</th>';
     echo '<th>3</th>';
     echo '<th>4</th>';
     echo '<th>5</th>';
     echo '<th>6</th>';
     echo '<th>7</th>';
     echo '<th>8</th>';
     echo '<th>9</th>';
     echo '<th>10</th>';
     echo '<th>11</th>';
     echo '<th>12</th>';
     echo '<th>R</th>';
     echo '<th>H</th>';
     echo '<th>E</th>';
     echo '</tr>';
     echo '</thead>';
    
     echo '<tr>';
     {
     echo '<td><B>'.$team1_des.'</B></td>';
     echo '<td>';
          $aini1    = 0 ;
          $zid      = "vini1";
          $zvalue   = $vini1 ;
          $zobj     = 5 ;
          $zwidth   = 1;
          $zreado   = 1 ;
          $zsize    = 0.8;
          include('ele_input.php');
     echo '</td>';
     echo '<td>';
          $aini2    = 0 ;
          $zid      = "vini2";
          $zvalue   = $vini2 ;
          $zobj     = 5 ;
          $zwidth   = 3;
          $zreado   = 1 ;
          $zsize    = 0.8;
          include('ele_input.php');
    echo '</td>';
    
     echo '<td>';
          $aini3    = 0 ;
          $zid      = "vini3";
          $zvalue   = $vini3 ;
          $zobj     = 5 ;
          $zwidth   = 3;
          $zreado   = 1 ;
          $zsize    = 0.8;
          include('ele_input.php');
     echo '</td>';

     echo '<td>';
          $aini4     = 0 ;
          $zid      = "vini4";
          $zvalue   = $vini4 ;
          $zobj     = 5 ;
          $zwidth   = 3;
          $zreado   = 1 ;
          $zsize    = 0.8;
          include('ele_input.php');
     echo '</td>';

     echo '<td>';
          $aini5    = 0 ;
          $zid      = "vini5";
          $zvalue   = $vini5 ;
          $zobj     = 5 ;
          $zwidth   = 3;
          $zreado   = 1 ;
          $zsize    = 0.8;
          include('ele_input.php');
     echo '</td>';

     echo '<td>';
          $aini6    = 0 ;
          $zid      = "vini6";
          $zvalue   = $vini6 ;
          $zobj     = 5 ;
          $zwidth   = 3;
          $zreado   = 1 ;
          $zsize    = 0.8;
          include('ele_input.php');
     echo '</td>';
    
     echo '<td>';
          $aini7    = 0 ;
          $zid      = "vini7";
          $zvalue   = $vini7 ;
          $zobj     = 5 ;
          $zwidth   = 3;
          $zreado   = 1 ;
          $zsize    = 0.8;
          include('ele_input.php');
     echo '</td>';

     echo '<td>';
          $aini8     = 0 ;
          $zid      = "vini8";
          $zvalue   = $vini8 ;
          $zobj     = 5 ;
          $zwidth   = 3;
          $zreado   = 1 ;
          $zsize    = 0.8;
          include('ele_input.php');
     echo '</td>';

     echo '<td>';
          $aini9    = 0 ;
          $zid      = "vini9";
          $zvalue   = $vini9 ;
          $zobj     = 5 ;
          $zwidth   = 3;
          $zreado   = 1 ;
          $zsize    = 0.8;
          include('ele_input.php');
     echo '</td>';

     echo '<td>';
          $aini10   = 0 ;
          $zid      = "vini10";
          $zvalue   = $vini10 ;
          $zobj     = 5 ;
          $zwidth   = 3;
          $zreado   = 1 ;
          $zsize    = 0.8;
          include('ele_input.php');
     echo '</td>';
    
     echo '<td>';
          $aini11   = 0 ;
          $zid      = "vini11";
          $zvalue   = $vini11 ;
          $zobj     = 5 ;
          $zwidth   = 3;
          $zreado   = 1 ;
          $zsize    = 0.8;
          include('ele_input.php');
     echo '</td>';

     echo '<td>';
          $aini12   = 0 ;
          $zid      = "vini12";
          $zvalue   = $vini12 ;
          $zobj     = 5 ;
          $zwidth   = 3;
          $zreado   = 1 ;
          $zsize    = 0.8;
          include('ele_input.php');
     echo '</td>';

     echo '<td>';
          $arun   = 0 ;
          $zid      = "vrun";
          $zvalue   = $vrun ;
          $zobj     = 5 ;
          $zwidth   = 3;
          $zreado   = 1 ;
          $zsize    = 0.8;
          include('ele_input.php');
     echo '</td>';

     echo '<td>';
          $ahit     = 0 ;
          $zid      = "vhit";
          $zvalue   = $vhit ;
          $zobj     = 5 ;
          $zwidth   = 3;
          $zreado   = 1 ;
          $zsize    = 0.8;
          include('ele_input.php');
     echo '</td>';

     echo '<td>';
          $aerro    = 0 ;
          $zid      = "verro";
          $zvalue   = $verro ;
          $zobj     = 5 ;
          $zwidth   = 3;
          $zreado   = 1 ;
          $zsize    = 0.8;
          include('ele_input.php');
     echo '</td>';
     }
     echo '</tr>';
     
     echo '<tr>';
     {
     echo '<td><B>'.$team2_des.'</B></td>';

     echo '<td>';
          $aini1    = 0 ;
          $zid      = "hini1";
          $zvalue   = $hini1 ;
          $zobj     = 5 ;
          $zwidth   = 1;
          $zreado   = 1 ;
          $zsize    = 0.8;
          include('ele_input.php');
     echo '</td>';
     echo '<td>';
          $aini2    = 0 ;
          $zid      = "hini2";
          $zvalue   = $hini2 ;
          $zobj     = 5 ;
          $zwidth   = 3;
          $zreado   = 1 ;
          $zsize    = 0.8;
          include('ele_input.php');
    echo '</td>';
    
     echo '<td>';
          $aini3    = 0 ;
          $zid      = "hini3";
          $zvalue   = $hini3 ;
          $zobj     = 5 ;
          $zwidth   = 3;
          $zreado   = 1 ;
          $zsize    = 0.8;
          include('ele_input.php');
     echo '</td>';

     echo '<td>';
          $aini4     = 0 ;
          $zid      = "hini4";
          $zvalue   = $hini4 ;
          $zobj     = 5 ;
          $zwidth   = 3;
          $zreado   = 1 ;
          $zsize    = 0.8;
          include('ele_input.php');
     echo '</td>';

     echo '<td>';
          $aini5    = 0 ;
          $zid      = "hini5";
          $zvalue   = $hini5 ;
          $zobj     = 5 ;
          $zwidth   = 3;
          $zreado   = 1 ;
          $zsize    = 0.8;
          include('ele_input.php');
     echo '</td>';

     echo '<td>';
          $aini6    = 0 ;
          $zid      = "hini6";
          $zvalue   = $hini6 ;
          $zobj     = 5 ;
          $zwidth   = 3;
          $zreado   = 1 ;
          $zsize    = 0.8;
          include('ele_input.php');
     echo '</td>';
    
     echo '<td>';
          $aini7    = 0 ;
          $zid      = "hini7";
          $zvalue   = $hini7 ;
          $zobj     = 5 ;
          $zwidth   = 3;
          $zreado   = 1 ;
          $zsize    = 0.8;
          include('ele_input.php');
     echo '</td>';
     echo '<td>';
          $aini8     = 0 ;
          $zid      = "hini8";
          $zvalue   = $hini8 ;
          $zobj     = 5 ;
          $zwidth   = 3;
          $zreado   = 1 ;
          $zsize    = 0.8;
          include('ele_input.php');
     echo '</td>';

     echo '<td>';
          $aini9    = 0 ;
          $zid      = "hini9";
          $zvalue   = $hini9 ;
          $zobj     = 5 ;
          $zwidth   = 3;
          $zreado   = 1 ;
          $zsize    = 0.8;
          include('ele_input.php');
     echo '</td>';

     echo '<td>';
          $aini10   = 0 ;
          $zid      = "hini10";
          $zvalue   = $hini10 ;
          $zobj     = 5 ;
          $zwidth   = 3;
          $zreado   = 1 ;
          $zsize    = 0.8;
          include('ele_input.php');
     echo '</td>';
    
     echo '<td>';
          $aini11   = 0 ;
          $zid      = "hini11";
          $zvalue   = $hini11 ;
          $zobj     = 5 ;
          $zwidth   = 3;
          $zreado   = 1 ;
          $zsize    = 0.8;
          include('ele_input.php');
     echo '</td>';

     echo '<td>';
          $aini12   = 0 ;
          $zid      = "hini12";
          $zvalue   = $hini12 ;
          $zobj     = 5 ;
          $zwidth   = 3;
          $zreado   = 1 ;
          $zsize    = 0.8;
          include('ele_input.php');
     echo '</td>';

     echo '<td>';
          $arun   = 0 ;
          $zid      = "hrun";
          $zvalue   = $hrun ;
          $zobj     = 5 ;
          $zwidth   = 3;
          $zreado   = 1 ;
          $zsize    = 0.8;
          include('ele_input.php');
     echo '</td>';

     echo '<td>';
          $ahit     = 0 ;
          $zid      = "hhit";
          $zvalue   = $hhit ;
          $zobj     = 5 ;
          $zwidth   = 3;
          $zreado   = 1 ;
          $zsize    = 0.8;
          include('ele_input.php');
     echo '</td>';

     echo '<td>';
          $aerro    = 0 ;
          $zid      = "berro";
          $zvalue   = $berro ;
          $zobj     = 5 ;
          $zwidth   = 3;
          $zreado   = 1 ;
          $zsize    = 0.8;
          include('ele_input.php');
     echo '</td>';
     }
     echo '</tr>';
     echo '</table>';
       
  }  
echo "</div>";
// Div Ining
include('ele_break.php');

  
//$zid='btn_play'; 
//$zlabel='';
//$zalign='right';
//$zimage = 'https://vcrxol.com/_otro/bolasoft3.png';
//$zonclick='{fn_consulta(event);}';

//include('ele_button.php');

}
// Cabecera
echo '</div>';
}
echo '</div>';
// Filtros
  
echo '<div id="detalle" style = "float:left;margin-left:0.5em;margin-right:0.5em;margin-bottom:0em;">';
{
  
  //Div Home
  echo '<div id="thome" style = "float:left;margin-left:0.5em;margin-right:0.5em;margin-bottom:0em;">';
    {
     $domdlu1 = new DOMDocument();
     $domdlu1->encoding = 'utf-8';
     $domdlu1->xmlVersion = '1.0';
     $domdlu1->formatOutput = true;
     $elem1=$domdlu1;

     $div1=$elem1->appendChild($domdlu1->createElement('div'," "));
     $div1->setAttribute("style","float:left;margin-left:0.5em;margin-right:0.5em;margin-bottom:0em;");
     $zid    = 'team1';
     $ztabla = 'team' ;
     $zlabel = 'Home Team';
     $zvalue = $team1 ;
     $zreado = 1;
     $zobj = 1;
     //include('ele_select.php');

     $table=$div1->appendChild($domdlu1->createElement('table',""));
     $table=$div1->appendChild($domdlu1->createElement('caption',$team1_des));
     $table->setAttribute("border","1");
     $table->setAttribute("cellpadding","0");

     $tr=$table->appendChild($domdlu1->createElement('tr',""));
     $td=$tr->appendChild($domdlu1->createElement('th',"Orden"));
     $td=$tr->appendChild($domdlu1->createElement('th',"Jugador"));
     $td=$tr->appendChild($domdlu1->createElement('th',"Número"));
     $td=$tr->appendChild($domdlu1->createElement('th',"Posición"));
     $td=$tr->appendChild($domdlu1->createElement('th',"Base"));
     $td=$tr->appendChild($domdlu1->createElement('th',"Out"));
     $td=$tr->appendChild($domdlu1->createElement('th',"Turno"));

     $sql_bat='select turno from liup1 left join liup2 on idnum1 = idnum2 where idsoft ='.$idnum.' and team = "'.$team1.'" order by bateo desc';      
     $res_bat=msql_query($sql_liup,$link_data);
     
     if(msql_num_rows($res_bat)==0)
       $mrca_ok=1;
     else
       {
         $$mrca_ok=msql_result($res_bat,0,'turno');
         $mrca_ok=$mrca_ok+1;
         if ($mrca_ok>11)
             $mrca_ok=1;
       }
       
     $lbat  = 1;
     $netxb = 1;
     $sql_liup='select bateo, enti_descri, camisa, posi_abrevia, turno, jugador, iddet from liup1 left join liup2 on idnum1 = idnum2 left join posi0 on posi=posi_codigo left join enti0 on jugador = enti_codigo where idsoft ='.$idnum.' and team = "'.$team1.'" order by idnum1, bateo';
     $res_liup=msql_query($sql_liup,$link_data);

     while($aso_liup=msql_fetch_assoc($res_liup))
      {
          $tr=$table->appendChild($domdlu1->createElement('tr',""));
          $td=$tr->appendChild($domdlu1->createElement('td',$aso_liup['bateo']));
          $td=$tr->appendChild($domdlu1->createElement('td',$aso_liup['enti_descri']));
          $td=$tr->appendChild($domdlu1->createElement('td',$aso_liup['camisa']));
          $td=$tr->appendChild($domdlu1->createElement('td',$aso_liup['posi_abrevia']));
          $td->setAttribute('align','center');
          $td=$tr->appendChild($domdlu1->createElement('td',$aso_liup['base']));
          $td=$tr->appendChild($domdlu1->createElement('td',$aso_liup['out']));
       
          $td=$tr->appendChild($domdlu1->createElement('td',$aso_liup['jugador']));
          if ($tiempo == 'B')
             {
               if ($aso_liup['turno']==1)
                  $lbat = 0;
            
               if ($aso_liup['turno']==0 and $lbat > 1 and $netxb < 4)
                  {
                    $td=$tr->appendChild($domdlu1->createElement('td','Bat'));
                    $lnFlag = 1 ;
                    if ($netxb==1)
                       {
                         $batea   = $aso_liup['enti_descri'].'-'.$aso_liup['posi_abrevia'];
                         $jugador = $aso_liup['jugador'];
                         $iddet   = $aso_liup['iddet'];
                         if ($lnFlag == 1)
                            {
                               $sql_bate  = 'update liup2 set turno = '.$lnFlag.' ' ;
                               $sql_bate .= 'where jugador = "'.$jugador.'" and ';
                               $sql_bate .= 'idnum2 ='.$idnumh. ' and ' ;
                               $sql_bate .= 'iddet  ='.$iddet ;
                               $res_bate  = msql_query($sql_bate,$link_data);
                               $lnFlag    = $lnFlag + 1 ;
                            }
                       }
                    $td->setAttribute('align','center');
                    $netxb = $netxb + 1;
                  }
               $lbat = $lbat + 1;
             }
      }

      echo $domdlu1->saveXML();
  }
  echo '</div>';
  // Div Home
  
  //Visita  
  echo '<div id="tvisit">';
    {
     $domdlu2 = new DOMDocument();
     $domdlu2->encoding = 'utf-8';
     $domdlu2->xmlVersion = '1.0';
     $domdlu2->formatOutput = true;
     $elem2=$domdlu2;

     $div2=$elem2->appendChild($domdlu2->createElement('div'," "));
     $div2->setAttribute("style","float:right;margin-right:0.5em;margin-left:0.5em;margin-bottom:0em;");

     $table=$div2->appendChild($domdlu2->createElement('table',""));
     $table=$div2->appendChild($domdlu2->createElement('caption',$team2_des));
     $table->setAttribute("border","1");
     $table->setAttribute("cellpadding","0");

     $tr=$table->appendChild($domdlu2->createElement('tr',""));
     $td=$tr->appendChild($domdlu2->createElement('th',"Bateo"));
     $td=$tr->appendChild($domdlu2->createElement('th',"Jugador"));
     $td=$tr->appendChild($domdlu2->createElement('th',"Número"));
     $td=$tr->appendChild($domdlu2->createElement('th',"Posición"));
     $td=$tr->appendChild($domdlu2->createElement('th',"Base"));
     $td=$tr->appendChild($domdlu2->createElement('th',"Out"));
     $td=$tr->appendChild($domdlu2->createElement('th',"Turno"));

     $lbat  = 1;
     $netxb = 1;
     $sql_liup='select bateo, enti_descri, camisa, posi_abrevia, turno, jugador, iddet from liup1 left join liup2 on idnum1 = idnum2 left join posi0 on posi=posi_codigo left join enti0 on jugador = enti_codigo where idsoft ='.$idnum.' and team = "'.$team2.'" order by idnum1, bateo';
     $res_liup=msql_query($sql_liup,$link_data);

     while($aso_liup=msql_fetch_assoc($res_liup))
      {
          $tr=$table->appendChild($domdlu2->createElement('tr',""));
          $td=$tr->appendChild($domdlu2->createElement('td',$aso_liup['bateo']));
          $td=$tr->appendChild($domdlu2->createElement('td',$aso_liup['enti_descri']));
          $td=$tr->appendChild($domdlu2->createElement('td',$aso_liup['camisa']));
          $td=$tr->appendChild($domdlu2->createElement('td',$aso_liup['posi_abrevia']));
          $td->setAttribute('align','center');
          $td=$tr->appendChild($domdlu2->createElement('td',$aso_liup['base']));
          $td=$tr->appendChild($domdlu2->createElement('td',$aso_liup['out']));

          if ($tiempo == 'T')
             {
               if ($aso_liup['turno']==1)
                  $lbat = 0;

               if ($entrada==1 and $lanzap == 0)
                   $lbat = 1;
       
               if ($aso_liup['turno']==0 and $lbat > 0 and $netxb < 4)
                  {
                    $td=$tr->appendChild($domdlu2->createElement('td','Bat'));
                    $td->setAttribute('align','center');
                    $lnFlag = 1 ;
                    if ($netxb==1)
                       {
                         $batea   = $aso_liup['enti_descri'].'-'.$aso_liup['posi_abrevia'];
                         $jugador = $aso_liup['jugador'];
                         $iddet   = $aso_liup['iddet'];
                         if ($lnFlag == 1)
                            {
                               $sql_bate  = 'update liup2 set turno = 1 ';
                               $sql_bate .= 'where jugador = "'.$jugador.'" and ';
                               $sql_bate .= 'idnum2 ='.$idnumv. ' and ' ;
                               $sql_bate .= 'iddet  ='.$iddet ;
                               $res_bate  = msql_query($sql_bate,$link_data);
                               $lnFlag    = $lnFlag + 1 ;
                            }
                       }
                       
                    $netxb = $netxb + 1;
                  }
               $lbat = $lbat + 1;
             }
          
      }

     echo $domdlu2->saveXML();
     }
  echo '</div">';
  // Div Visita

  // Lazamineto
  echo '<div id="Datos" style = "display: inline-block;">';
    {
       include('ele_break.php');
       echo '<div hide>';   
          {
             $cant = 1;
             echo '<input id="jugador" value="'.$jugador.'">';
             echo '<input id="idnum2" value="'.$idnumv.'">';
          }     
       echo '</div>';   

       echo '<div id="Bateador">';
          {
              include('ele_break.php');

              $zid    = 'batea';
              $zlabel = 'Bateador';
              $zvalue = $batea ;
              $zreado = 1 ;
              include('ele_input.php');

              $zid    = 'lanza';
              $zlabel = 'Lanzamiento';
              $zvalue = $lanza ;
              $zreado = 1 ;
              $zoptions= 'BA,Ball;ST,Strike;FB,FoulBall;OU,Out;BI,Base Intencional;BB, Base por Bola;PI,Pitcheo Ilegal;PL,Play ';
              //$zonchange='{fn_pitcheo();}';
              include('ele_select.php');

              $zid    = 'bola';
              $zlabel = 'Bola';
              $zvalue = $bola ;
              $zreado = 1 ;
              include('ele_input.php');

              $zid    = 'strike';
              $zlabel = 'Strike';
              $zvalue = $strike ;
              $zreado = 1 ;
              include('ele_input.php');

              $docu="soft";
              $zid='btn_grabar'; 
              $zlabel='Grabar';
              $zalign='right';
              //$zonclick='{save_docu(event);}';
              $zonclick='{save_soft();fn_activa(2); fn_pitcheo();}';
              $zsize=1.5;
              $zreado = 1 ;
              include('ele_button.php');
  
          }  
       echo '</div>';
       //Div Bateador
       echo '<div id="main2">';
       echo '</div>';
  
       // Golpe
       echo '<div>';
          {
              $zid    = 'golpe';
              $zlabel = 'Ball in Play';
              $zvalue = $golpe ;
              $zoptions = 'HT,Hit;2b,Doblete;3b,Triple;HR,Home Run; BB, Base por Bola';
              $zreado = 1 ;
              include('ele_select.php');

              $zid    = 'base';
              $zlabel = 'Base';
              $zoptions = '1,1 Base;2,2 Base;3,3 Base;4,Carrera';
              $zreado = 1 ;
              include('ele_select.php');

              $zid    = 'outru';
              $zlabel = 'Out Corredor';
              $zvalue = $outrun ;
              $zreado = 1 ;
              include('ele_input.php');

              $zid      = 'rbib';
              $zlabel   = 'RBI';
              $zvalue   = $rbib ;
              $zoptions = '1;2;3';
              $zreado   = 1 ;
              include('ele_select.php');

              $zid      = 'outb';
              $zlabel   = 'Out Ining';
              $zvalue   = $outb ;
              $zreado   = 1 ;
              include('ele_input.php');

              // $zid    = 'sbb';
              // $zlabel = 'SB';
              // $zvalue = $sbb ;
              // $zoptions = '1;2;3';
              // $zreado = 1 ;
              // include('ele_select.php');
          }
       echo '</div>';
       // Div Golpe
     
       include('ele_break.php');
   }
  echo '</div>';
  // Div Laxamiento
}
echo '</div>';
// Div Detalle

$x=32;
if ($x==22)
{

// // echo '<div id="tfield2" style = "float:right;margin-right:0.5em;margin-left:0.5em;margin-bottom:0em;">';
// echo '<div id="tfield0" style = "display:inline-block" >';
//  $znombre = "DANNY COPIANO";
//  $zbase    = 2;
//  include('ele_diamante.php');
// echo '</div>';


//  $znombre = "XAVIER MOLINA";
//  $zbase    = 3;
//  include('ele_diamante.php');
// echo '</div>';

//  //echo '<div id="tfield2" style = "float:right;display:inline-block" >';
//  $zbase    = 1;
//  $znombre = "JOSE QUIMI";
//  include('ele_diamante.php');

//  $znombre = "Bateador";
//  $zbase    = 0;
//  include('ele_diamante.php');

//   $domdlu1b = new DOMDocument();
// $domdlu1b->encoding = 'utf-8';
// $domdlu1b->xmlVersion = '1.0';
// $domdlu1b->formatOutput = true;
// $elem1b=$domdlu1b;
// $div1b=$elem1b->appendChild($domdlu1b->createElement('div'," "));
// $div1b->setAttribute("style","display:inline-block;");
// $table=$div1b->appendChild($domdlu1b->createElement('table',""));
// $table=$div1b->appendChild($domdlu1b->createElement('caption','CORREDORES'));
// $table->setAttribute("border","1");
// $table->setAttribute("cellpadding","0");

// $tr=$table->appendChild($domdlu1b->createElement('tr',""));
//      $td=$tr->appendChild($domdlu1b->createElement('th',"1 Base"));
//      $td=$tr->appendChild($domdlu1b->createElement('th',"2 Base"));
//      $td=$tr->appendChild($domdlu1b->createElement('th',"3 Base"));
//      $td=$tr->appendChild($domdlu1b->createElement('th',"Bateador"));

//      $tr=$table->appendChild($domdlu1b->createElement('tr',''));

//      $td=$tr->appendChild($domdlu1b->createElement('td',''));
//      $td=$tr->appendChild($domdlu1b->createElement('td',''));
//      $td=$tr->appendChild($domdlu1b->createElement('td',''));
//      $td=$tr->appendChild($domdlu1b->createElement('td',''));

// echo $domdlu1b->saveXML();
  
}
}
echo '</div>';
// Informacion
  
?>

<script>
function fn_consulta(event)
{
     var xhref='',dataget;
     xhref=xhref+'?scri=<?php echo basename(__FILE__,'.php');?>';

//     alert(document.getElementById('numero').value);
     
     dataget=new_FormData('filtros','get');
   
     xhref=xhref+dataget;
     
     document.getElementById("main2").innerHTML='Espere...';
     location.href=xhref;
}
</script>

<script>
function fn_activa(nacc)
{
     //alert("Xavier");
     var lacci = 0;
     lacci = nacc ;
     if (lacci ==1)
        {
           document.getElementById('lanza').disabled = false ;
           document.getElementById('golpe').disabled = false ;
           document.getElementById('rbib').disabled = false ;
           document.getElementById('outru').disabled = false ;
           document.getElementById('base').disabled = false ;
        }
     else
        {
          document.getElementById('lanza').disabled = true ;
          document.getElementById('golpe').disabled = true ;
          document.getElementById('rbib').disabled = true ;
          document.getElementById('outru').disabled = true ;
          document.getElementById('base').disabled = true ;
        }
}
</script>

<script>
function fn_pitcheo()
{
     var lanza = document.getElementById('lanza').value;
     var lnbola, lnstri, lnvalor, lnVal, lnball = 0;
    
     switch (lanza) 
     {
        case "BA":
        case "PI":
          lnbola = 1 ;
          lnstri = 0 ;
          break;
        case "ST":
        case "FB":
        case "OU":
          lnstri = 1;
          lnbola = 0 ;
          break;
        case "BB":
        case "BI":
          lnbola = 4 ;
          lnstri = 0 ;
          break;
        default:
          lnbola = 0 ;
          lnstri = 0 ;
        break;
     }
  
     // Bateador
     lnvalor = document.getElementById('bola').value;
     lnvalor = (lnvalor == null || lnvalor == undefined || lnvalor == "") ? 0 : lnvalor;
     lnball  = parseInt(lnvalor) + parseInt(lnbola) ;
     document.getElementById('bola').value = lnball ;

     lnvalor = document.getElementById('stri').value;
     lnvalor = (lnvalor == null || lnvalor == undefined || lnvalor == "") ? 0 : lnvalor;
     lnVal   = parseInt(lnvalor) + parseInt(lnstri) ;
     document.getElementById('stri').value = lnVal;
  
     if (lnVal == 3)
        {
          var lout = document.getElementById('outb').value
          lout = (lout == null || lout == undefined || lout == "") ? 0 : lout;
          lout = parseInt(lout) + 1;
          document.getElementById('outb').value = lout;
          document.getElementById('stri').value = 0;
          document.getElementById('bola').value = 0;
          if (lout==3)
             {
               document.getElementById('outb').value = 0;
               var ltiempo = document.getElementById('tiempo').value ;
               if (ltiempo == "T")
                   {
                      document.getElementById('tiempo').value = "B"
                   }
               else
                   {
                       var linin = document.getElementById('entrada').value ;
                       linin = (linin == null || linin == undefined || linin == "") ? 0 : linin;
                       linin = parseInt(linin) + 1 ;
                       document.getElementById('entrada').value = linin;
                       document.getElementById('tiempo').value = "T"
                   }
             }
        }
     
     if (lnball == 4)
        {
          document.getElementById('base').value = 2 ;
        }
       
     // Pitcher
     lnvalor = document.getElementById('lanzap').value;
     lnvalor = (lnvalor == null || lnvalor == undefined || lnvalor == "") ? 0 : lnvalor;
     document.getElementById('lanzap').value = parseInt(lnvalor) + 1 ;

     lnvalor = document.getElementById('strikp').value;
     lnvalor = (lnvalor == null || lnvalor == undefined || lnvalor == "") ? 0 : lnvalor;
     document.getElementById('strikp').value = parseInt(lnvalor) + parseInt(lnstri) ;
 
     lnvalor = document.getElementById('bolasp').value;
     lnvalor = (lnvalor == null || lnvalor == undefined || lnvalor == "") ? 0 : lnvalor;
     document.getElementById('bolasp').value = parseInt(lnvalor) + parseInt(lnbola) ;
  
     document.getElementById('lanza').selectedIndex = 0;
}
</script>

<script>document.title="<?php echo $xtitle;?>"</script>
<script>document.getElementById('topcenter').innerHTML="<?php echo $xtopcenter;?>"</script>
<!--<script>calc_subtot()</script>
<!-- <script>set_noback();</script> -->
<!-- <script>window.onbeforeunload = function(){return 'Are you sure you want to leave?';};</script> -->
