<?php
declare(strict_types=0);

$pbground='#D4FEF9';
$zstyle='height:1.9em; min-width:2em; ';
// $zstyle='height:1.85em;min-width:2em;';
// $zstyle.='font-size:0.90em;';

$zstyle.='padding:0px; ';

if(!empty($zwidth))
{$zstyle.='width:'.$zwidth.'; ';}


$selected_ok=0;
$zstyle1='';

$cradio=0;
$hidesele=0;
if($ztype=='radio')
{
     $zname=$zid; 
     $ztodo=0;
     $zexact=1;
     $hidesele=1;
}

//
$set_cookie='{document.cookie = "'.$zid.'= "+encodeURIComponent(this.value)+"; max-age=" + '.(60*60*24*90).' + "; path=/";}';
$zonblur=$set_cookie.$zonblur;

$zonfocus.='{this.style.background="'.$pbground.'";}';       
$zonblur.='{this.style.background="white";}';       



if(!empty($zsave)){$zonblur.="{save_data(event,'".$zid."');}";}
if(empty($zorient)){$zorient=1;}

if(empty($zmaintag)){$zmaintag='select';}
if(empty($zstep)){$zstep=1;}
if($zmaintag!='select'){$zobj=1;}

// 🅿✅

// if(strtolower($zlabel)=='fecha'){$zlabel='🗓📆📅 '.$zlabel;}
// if(strtolower($zlabel)=='fecha'){$zlabel='📅 '.$zlabel;}
if($ztype=='date' and !empty($zlabel)){$zlabel='📅 '.$zlabel;}
if($ztype=='month' and !empty($zlabel)){$zlabel='🗓 '.$zlabel;}
if($ztype=='week' and !empty($zlabel)){$zlabel='🗓 '.$zlabel;}

// $zlabel=add_unicode($zlabel);
if(!mb_stristr($zlabel,'&#'))
{$zlabel=add_unicode($zlabel);}


$zoptions=trim($zoptions);

$zlong=strlen($zcaption);
$zdefa=trim($zdefa);
$zvalue=trim($zvalue);

// echo '====>T '.$ztabla;
// echo '====>D '.$zdefa;
// echo '====>V '.$zvalue;

// if($zbool==1){$zoptions='1,🔹SI;2,🔸NO';}
// if($ztriv==1){$zoptions='1,🔹SI;2,🔸NO';}
// if($ztetrav==1){$zoptions='1,🔹Positivo;2,🔸Negativo;3,0️⃣En Cero;'; $ztodo=1;}
// if($zheptav==1){$zoptions='6,< 0; 8,= 0; 9,> 0; 68,<= 0; 69,<> 0; 98,>= 0;'; $ztodo=1;}


if($zbool==1){$zoptions='1,SI;2,NO';}
if($ztriv==1){$zoptions='1,SI;2,NO';}
if($ztetrav==1){$zoptions='1,Positivo;2,Negativo;3,En Cero;'; $ztodo=1;}
// if($zheptav==1){$zoptions='6,< 0; 8,= 0; 9,> 0; 68,<= 0; 69,<> 0; 98,>= 0;'; $ztodo=1;}
if($zheptav==1)
{
     $zoptions='';
     $zoptions.='69,<> 0;'; 
     $zoptions.='8,= 0;'; 
     $zoptions.='9,> 0;'; 
     $zoptions.='6,< 0;'; 
     $zoptions.='98,>= 0;'; 
     $zoptions.='68,<= 0;'; 
     $ztodo=1;
}
if($zabc==1)
{
     $zoptions='';
     for($xabc=65; $xabc<=90; $xabc++)
     {
          $zoptions.=chr($xabc).';';
     }
}



if($zgamacolor==1){$zoptions='Amarillo;Azul;Rojo;Verde;Morado;Naranja;Blanco;Negro;';}
if($zmes==1){$zoptions='1,Enero;2,Febrero;3,Marzo;4,Abril;5,Mayo;6,Junio;7,Julio;8,Agosto;9,Septiembre;10,Octubre;11,Noviembre;12,Diciembre;';}
if($zdia==1){$zoptions='1,Lunes;2,Martes;3,Miércoles;4,Jueves;5,Viernes;6,Sábado;7,Domingo;';}
if($zdia==2){$zoptions='1,Lunes;2,Martes;3,Miércoles;4,Jueves;5,Viernes;6,Sábado;7,Domingo;12345,Lunes ➜ Viernes;67,Sábado ➜ Domingo;';}
if($zdia==3){$zoptions='12345,Lunes ➜ Viernes;67,Sábado ➜ Domingo;1234567,Lunes ➜ Domingo';}
if($zanio==1){$xyear = date("Y");for ($idx = $xyear ; $idx > 1945 ; $idx--){$zoptions.= $idx.";";}}

if($zdestino>=1)
{
     $zoptions='';
     $zoptions.='0,Pantalla;';
     $zoptions.='1,Impresora;';
//      $zoptions.='3,Excel';
}
if($zoptn1>0 and $zoptn2>$zoptn1)
{
     $zoptions='';
     for($coptn=$zoptn1; $coptn<=$zoptn2; $coptn=$coptn+$zstep )
     {$zoptions.=$coptn.','.$coptn.';';	}
}


if(empty($zoptions))
{	
	if(empty($zdocu))
	{
//           echo '*/*/*'.$zdefa;
		if(!empty($zdefa))
		{
			$sql_defa ='select * from '.$ztabla.'0 where '.$ztabla.'_codigo="'.$zdefa.'"';
			$res_defa=msql_query($sql_defa,$link_data);
			if(msql_num_rows($res_defa)!=0){$zdefad=msql_result($res_defa,0,$ztabla.'_descri');}
//                echo '=='.$sql_defa;
		}
//           if($ztabla=='lsub')
//           echo '<br>000 '.$zwhere;
          include('col2list.php');
          
	}
	else
	{
          $sql_docu='select * from docu0 where docu_codigo like "'.$zdocu.'%"';
          $res_docu=msql_query($sql_docu,$link_data);
          $ztabla=msql_result($res_docu,0,'docu_tabla');
          
		if(!empty($zdefa))
		{
// 			$sql_defa ='select * from '.$ztabla.'2 ';
		     $sql_sele ='select * from '.$ztabla.'1 left join  '.$ztabla.'2 on idnum1=idnum2 ';
			$sql_defa.='where docu like "'.$zdocu.'%" ';
			$sql_defa.='and '.$zcolu.'="'.$zdefa.'" ';
			$sql_defa.='and status not like ("O","X") ';
			$res_defa=msql_query($sql_defa,$link_data);
			if(msql_num_rows($res_defa)!=0){$zdefad=msql_result($res_defa,0,$zcolu2);}
		}

// 		$sql_sele ='select * from '.$ztabla.'2 ';
		$sql_sele ='select * from '.$ztabla.'1 left join  '.$ztabla.'2 on idnum1=idnum2 ';
		$sql_sele.='where docu like "'.$zdocu.'%" ';
		$sql_sele.='and status not in ("O","X") ';
		if(!empty($zwhere))
		{$sql_sele.='and ('.$zwhere.') ';}
		$sql_sele.='group by '.$zcolu2.' ';
          
          $xorderby='order by '.$zcolu2.' ';
          if(mb_stristr('.impor.',$zcolu2))
          {$xorderby.=' desc ';}
          
//           if(mb_stristr2('.civa',$ztabla))
//           {$xorderby='order by '.$ztabla.'_descri*(1),'.$ztabla.'_codigo ' ;}
//           if(mb_stristr2('.docu',$zdocu))
//           {$xorderby='order by '.$ztabla.'_codigo ';}
//           echo '*/*/*'.$xorderby;
          
		$sql_sele.=$xorderby;
          

		$res_sele=msql_query($sql_sele,$link_data);
          
          
		$zoptions.=$zdefa.','.$zdefad.';';
		if(msql_num_rows($res_sele)>0)
		{
			while ($aso_sele=msql_fetch_assoc($res_sele))
			{$zoptions.=$aso_sele[$zcolu].','.$aso_sele[$zcolu2].';';}
		}
          
//           if(msql_num_rows($res_sele)==1)
//           {$ztodo=0;}

	}
}


$zoptionsx=explode(';',$zoptions);
if(count($zoptionsx)<=1){$ztodo=0; $zexact=1;}
// if(count($zoptionsx)<=2){$ztodo=1; $zexact=1;}

if($ztodo==1){$zoptions=' '.','.'*️⃣ TODO '.';'.$zoptions; }
else
{if($zexact!=1){$zoptions=' '.','.' ♾️ N/A  '.';'.$zoptions;}}


$zoptions=explode(';',$zoptions);



if(!empty($zsort)){sort($zoptions);}

$seloptv='';

for ($copt=0; $copt<count($zoptions); $copt++)
{ 
     $optval=explode(',',$zoptions[$copt]); 
     $seloptv1= $optval[0]; 
     $seloptv2= $optval[1]; 
     $xlong=strlen($seloptv2);
     if($xlong>$zlong){$zlong=$xlong;}
} 


if(empty($zobj)){$zobj=3;}
if(empty($zsize)){$zsize=1;}
if(empty($zalign)){$zalign='left';}
if(empty($zmaxlen)){$zmaxlen=0;}
if(empty($zid) and !empty($ztabla)){$zid='dl_'.$ztabla;}
if(empty($zid)){$zid=$ztabla;}
if(empty($zid)){$zid=$zlabel;}
if(empty($zlabel)){$zlabel=$zid;}
if(empty($zid)){$zid=microtime()*1000000;}
if(empty($zvalue) and !empty($zdefa) and empty($ztodo)){$zvalue=$zdefa;}
if(empty($zcolu2)){$zcolu;}

if(empty($zvalue)){$zreado=0;}


if(empty($zakey)){$zakey=substr_1letra($zlabel);}
if($zreado==1){$zakey='';}

// if($zreado==2){$zondblclick.='{document.getElementById("'.$zid.'").removeAttribute("disabled");}';}
if($zreado==2)
{
//      $zondblclick.='{habilitarInput(this);}';
// <input type="text" id="miInput" disabled ondblclick="habilitarInput(this)">
     
}

$subchar1='';
$subchar2='';
// ⬛◼️
// if(mb_stristr2('.lsub.zsub.csub.asub',$ztabla)){$zoptgroup=1; $subchar1='=';$subchar2='-';}

$android=0;
$linux=0;
if(mb_stristr2('.lsub.zsub.csub.asub',$ztabla)){$zoptgroup=1; $subchar1='⬛';$subchar2='.◾';}
if(getPlatform()=='Android'){$android=1;}
if(getPlatform()=='Linux'){$linux=1;}
// echo '<br>**'.$oscreen;

// if(($zobj==2 or $zobj==3 or $zobj==6) and $ztcell<=1 and getPlatform()=='Android'){$zobj=4;}
if(($zobj==2 or $zobj==3 or $zobj==6) and $ztcell<=1 and $android==1){$zobj=4;}
if(($zobj==2 or $zobj==3 or $zobj==6) and $ztcell<=1 and $linux==1){$zobj=4;}

if(!empty($ztabla) and empty($zdocu))
{
   $sql_input='describe '.$ztabla.'0';
   $res_input=msql_query($sql_input,$link_data);
   
   if(!msql_error($link_data))	
   {
      $zmaxlen=msql_result($res_input,0,1);
      $zmaxlen=str_replace(')','',$zmaxlen);
      $zmaxlen=str_replace('varchar(','',$zmaxlen);
      $zmaxlen=str_replace('char(','',$zmaxlen);
      $zmaxlen=str_replace('int(','',$zmaxlen);
      $ztype='search';
      $zwidth=0;
   }else{$ztabla='';}
}

if(empty($zwidth) and !empty($zmaxlen)){$zwidth=(int)$zmaxlen*(.7);}
if(!empty($zsize) and $zsize!=1){$zstyle.='font-size:'.($zsize).'em;';$zstyle.='height:1.7em;';}
if(!empty($zsize) and $zsize!=1){$zstyle1.='font-size:'.($zsize).'em;';}
if(!empty($zmaxwidth)){$zstyle.='max-width:'.($zmaxwidth).'em;';}
// if(!empty($zsize) and $zsize!=1){$zstyle3.='font-size:'.($zsize).'em;';$zstyle3.='height:'.($zsize).'em;';}

$zstyle1.='vertical-align:top;';
if($ztcell>=2){$zstyle1.='width:100%;';}

$domd_s = new DOMDocument();
     $domd_s->encoding = 'utf-8';
     $domd_s->xmlVersion = '1.0';
     $domd_s->formatOutput = true;
$elem_s=$domd_s;

if(!empty($zdom)){$domd_s=$zdom;}
if(!empty($zele)){$elem_s=$zele;}

// if($zobj>1)
{
     
if($ztcell>=2 and $zobj>=2 and $zobj<=3)
{
     $element=$elem_s->appendChild($domd_s->createElement("td"));
     $element->setAttribute("valign","top");
}
else
{
     $element=$elem_s->appendChild($domd_s->createElement("span"));
     
     $xstyle0="float:".$zalign.";";
     if(empty($zdom))
     {
//           $xstyle0="float:".$zalign.";margin-left:".$zsize*(0.5)."em;margin-right:".$zsize*(0.5)."em;margin-bottom:0.1em;";
          $xstyle0.="margin-left:".$zsize*(0.5)."em;margin-right:".$zsize*(0.5)."em;margin-bottom:0.1em;";
          if($zobj==4)
          {$xstyle0.="margin-top:10px;";}
//           $element->setAttribute("style",$xstyle0);
     }
     $element->setAttribute("style",$xstyle0);
     
     if(mb_stristr($zwidth,'%'))
     {$element->setAttribute("style","width:".$zwidth."");}
//      if(mb_stristr($zwidth,'em'))
//      {$element->setAttribute("style","width:".$zwidth."");}
}
$element->setAttribute("id",$zid.'_ele');
if(!empty($zhide)){$element->setAttribute("hide","");}
if(!empty($znoprint)){$element->setAttribute("noprint","");}
if(!empty($ztitle)){$element->setAttribute("title",$ztitle);}
if($zreado==2){$element->setAttribute("ondblclick","habilitarInput('".$zid."')");}
// {habilitarInput(this);}
     
  // windows
   if($zobj==2 or $zobj==3)
   {
    //   echo '===='.$zlabel;
      $zclass1='';
      $label=$element->appendChild($domd_s->createElement("button",htmlspecialchars($zlabel)));   
      if(!empty($zid))
      {
        $label->setAttribute("id",$zid.'_l');
        $label->setAttribute("type","button");
        $label->setAttribute("tabindex","-1");
      }
     if($hidesele==1){$label->setAttribute("hide","");}

      if(!empty($zlabel)){$label->setAttribute("value",($zlabel));}
      if(!empty($zstyle1)){$label->setAttribute("style",$zstyle1);}
      if(!empty($zclass1)){$label->setAttribute("class",$zclass1);}
      if(!empty($zdefa)){$label->setAttribute("defa",$zdefa);}
      if(!empty($zonclick)){$label->setAttribute("onclick",$zonclick);}
      if(!empty($zondblclick)){$label->setAttribute("ondblclick",$zondblclick);}
   }

}


     if($ztcell>=2)
     {
       $element=$elem_s->appendChild($domd_s->createElement("td"));
       $element->setAttribute("colspan",$ztcell);
       $element->setAttribute("valign","top");
     }

    //android
   if($zobj==4)
   {
      $zclass1='input-label';
      $label=$element->appendChild($domd_s->createElement("label",htmlspecialchars($zlabel)));   
      if($hidesele==1){$label->setAttribute("hide","");}
      if(!empty($zid)){$label->setAttribute("id",$zid.'_l');}
      if(!empty($zid)){$label->setAttribute("for",$zid);}
      if(!empty($zstyle1)){$label->setAttribute("style",$zstyle1);}
      if(!empty($zclass1)){$label->setAttribute("class",$zclass1);}
      if(!empty($zondblclick)){$label->setAttribute("ondblclick",$zondblclick);}
   }

     $div=$element->appendChild($domd_s->createElement("span"));
     if(mb_stristr($zwidth,'%'))
     {$div->setAttribute("style","width:".$zwidth."");}

     $input=$div->appendChild($domd_s->createElement($zmaintag," "));
//           $zclass.='chosen';
//           if(!empty($zreado)){$zstyle.='color:black;';}
          if($hidesele==1){$input->setAttribute("hide","");}

          if(!empty($zid)){$input->setAttribute("id",$zid);}
          if(!empty($zname)){$input->setAttribute("name",$zname);}
          if(!empty($zclass)){$input->setAttribute("class",$zclass);}
          if(!empty($zonchange)){$input->setAttribute("onchange",$zonchange);}
          if(!empty($zonblur)){$input->setAttribute("onblur",$zonblur);}
          if(!empty($zonfocus)){$input->setAttribute("onfocus",$zonfocus);}
          if(!empty($zvalue)){$input->setAttribute("value",$zvalue);}
          if(!empty($zstyle)){$input->setAttribute("style",$zstyle);}
// echo '<br>=== '.$zstyle;
          if(!empty($zreado)){$input->setAttribute("disabled","");}
          if(!empty($zreado)){$input->setAttribute("bold","");}
          if(!empty($zreado)){$input->setAttribute("f-black","");}
          if(!empty($zakey)){$input->setAttribute("accesskey",$zakey);}
          if(!empty($zondblclick2)){$input->setAttribute("ondblclick",$zondblclick2);}




// document.getElementById("miInput").addEventListener("dblclick", function () {
//     alert("¡Doble clic detectado!");
//   });

//           if(!empty($zondblclick))
          {
//                $eventlisten='document.getElementById("'.$zid.'").addEventListener("dblclick","'.$zondblclick.'" )';
//                $script=$div->appendChild($domd_s->createElement('script',$eventlisten));
//                $script=$div->appendChild('body'->createElement('script',$eventlisten));
               
          }



     if(!empty($zsave))
     {
          $input->setAttribute("savet",$zsavet);
          if(!empty($zsavec))
          {$input->setAttribute("savec",$zsavec);}
          else
          {
          $input->setAttribute("savei",$zsavei);
          if(!empty($zsaved)){$input->setAttribute("saved",$zsaved);}
          }
          $input->setAttribute("savef",$zsavef);
     }

          $xnume=0;
          $xlastg='';
          $xoptgroup=false;
          for ($copt=0; $copt<count($zoptions); $copt++)
          { 
               $optval=explode(',',$zoptions[$copt]); 
               $seloptv1= ($optval[0]); 
               

               
               $seloptv2= ($optval[1]); 
               $seloptv3= $seloptv2.' ('.$seloptv1.')';
               $seloptv4= ' ('.$seloptv1.') '.$seloptv2;
               $seloptvx='';

               
// echo '----'.$empr;
// echo '===='.$cfg_empr;
// echo '****'.$empr_codigo;

            //   if(mb_stristr2('hfre',$_SESSION['empr_codigo']) and $ztabla=='docu')
            //   if(mb_stristr2('hfre',$empr0['empr_codigo']) and $ztabla=='docu')
            
              if(mb_stristr2('hfre',$cfg_empr) and $ztabla=='docu')
              {$seloptvx= '('.$seloptv1.') '.$seloptv2;}
               
            //   echo '---> '.$seloptvx;
               
               if(mb_stristr2('.docu.ptoe.caja.ctab..caba.bode.cair.fpxag.suxco.',$ztabla) and !empty(trim($seloptv1)) and !empty($user_codigo))
               {$seloptvx=$seloptv3;}

            //   echo '===> '.$seloptvx;


               if(mb_stristr2('.fpag.suco',$ztabla) and !empty(trim($seloptv1)) and !empty($user_codigo))
               {$seloptvx=$seloptv4;}
               
            //   echo '***> '.$seloptvx;
               
               if($cfg_empr=='jwib'){$seloptvx=$seloptv2;}


               if(!empty($seloptvx)){$seloptv2=$seloptvx;}

               if($seloptv2==""){$seloptv2=$seloptv1;}
               
               
               if(($seloptv1)!="")
               {
                    if(!empty($ztabla))
                    {
                         if(mb_stristr2('.vndd',$ztabla)){$seloptv2=ucwords(strtolower($seloptv2));}
                         if(mb_stristr2('.ctas.item.enti',$ztabla)){$seloptv2=$seloptv1.' - '.$seloptv2;}
                         
                         if($zoptgroup==1)
                         {
                              if((substr(trim($seloptv1),0,4)=='****' or substr(trim($seloptv1),-1)=='-' or substr(trim($seloptv1),-4)=='0000' )and $android!=1)
                              {
                                   $seloptv1=str_replace('****','',$seloptv1);
                                   $xoptgroup=true;
                                   $optiong=$input->appendChild($domd_s->createElement('optgroup'));
//                                    $optiong->setAttribute('label',($seloptv2));
//                                    〰️
                                   $optiong->setAttribute('label',str_repeat('_',9));
//                                    $optiong->setAttribute('hide','');
                                   $cur_group=$seloptv1;
                                   
                              }
                         }
                         if($ztabla=='ctas' and $zcoddet==1)
                         {if(!ctas_deta($seloptv1)){$xoptgroup=true;}}
                    }
                    
                    if($seloptv1=='ogroup')
                    {
                         $xoptgroup=true;
                         $optiong=$input->appendChild($domd_s->createElement('optgroup'));
                         $optiong->setAttribute('label',($seloptv2));
//                          $optiong->setAttribute('label','');
                         $cur_group=$seloptv1;
                    }
                    
                    $seloptv2=abrevia($seloptv2);
                    if($znumeric==1){$seloptv2= ++$xnume.'.'.$seloptv2;}
                    
                    
                    //if select tag
                         
//                     if($ztype=='select')
                    {
                    $eleoption='option';                    
                    if($xoptgroup)
                    {
                         if($cur_group==$seloptv1){$seloptv2=$subchar1.' '.$seloptv2; }
                         if($cur_group!=$seloptv1){$seloptv2=$subchar2.' '.$seloptv2;}
                         $optionv=$optiong->appendChild($domd_s->createElement($eleoption,htmlspecialchars($seloptv2.'')));
                         if($seloptv1=='ogroup'){$optionv->setAttribute('hide','');}
                    }
                    else
                    {
                         $optionv=$input->appendChild($domd_s->createElement($eleoption,htmlspecialchars($seloptv2.'')));
                    }
//                     $optionv->setAttribute("value",$seloptv1);
//                     $optionv->setAttribute("value",preg_replace('/[^\x00-\x7F]/', '', $seloptv1));
//                     $optionv->setAttribute("value",trim(preg_replace('/[^\x00-\x7F]/', '', $seloptv1)));
                    $optionv->setAttribute("value",trim(preg_replace('/[^\x00-\x7F]/u', '', $seloptv1)));
//                                               $limpio = preg_replace('/[\x{26A2}-\x{26A9}]/u', '', $texto);                         
//                $seloptv2 = preg_replace('/[^\x00-\x7F]/', '', $seloptv1);
                         
                    
                    if(!empty($zvalue) and empty($selected_ok))
                    {
                         if(strtolower($seloptv1)==strtolower($zvalue)){$optionv->setAttribute("selected","selected"); $selected_ok=1; $zvalue=$seloptv1; }
                         elseif(strtolower(substr($seloptv2,0,strlen(trim($zvalue))))==strtolower($zvalue)){$optionv->setAttribute("selected","selected"); $zvalue=$seloptv2;}
                    }
                    
                    if($ztabla=='clor')
                    {
                         $bcolor='#F2F3F4';
                         $fcolor='black';
                         
                         $clor0=data_maes($ztabla,$seloptv1);
                         $hexa=$clor0['clor_hexa'];
                         if(!empty($hexa)){$bcolor=$hexa;}
                         
                         $optionv->setAttribute("bold","");
                         $optionv->setAttribute("style","background-color:".$bcolor."; color:".$fcolor.";");
                    }
                                             
                    }

                    
                    if($ztype=='radio')
                    {
                         $cradio++;
                         if($zorient==1){$radiodiv=$element->appendChild($domd_s->createElement('div',''));}
                         if($zorient==2){$radiodiv=$element->appendChild($domd_s->createElement('span',''));}
                         if($zhide==1){$radiodiv->setAttribute('hide','');}
                         
                         if($linux==1 or $android==1)
                         if($ztype=='radio')                              
                         if($zorient==1)
                         {$rstyle='margin-bottom:0.5em;';}
                         $radiodiv->setAttribute('style',$rstyle);
   
                         
                         $ronclick='{document.getElementById("'.$zid.'_'.$cradio.'").click(); document.getElementById("'.$zid.'").value=document.getElementById("'.$zid.'_'.$cradio.'").value;}';
                         
                         $radiospan=$radiodiv->appendChild($domd_s->createElement('span','')); 
                         $radio=$radiospan->appendChild($domd_s->createElement('input','')); 
                              $radio->setAttribute('id',$zid.'_'.$cradio);
                              $radio->setAttribute('name',$zid);
                              $radio->setAttribute('type','radio');
                              $radio->setAttribute('value',$seloptv1);
                              if($seloptv1==$zvalue){$radio->setAttribute('checked',''); }
                              $rstyle='height:1.2em; min-width:2em; zoom:1;';
                              $radio->setAttribute('style',$rstyle);
                              $radio->setAttribute('onclick',$ronclick);
                              $rstyle='';
                         
                         $radiolab=$radiodiv->appendChild($domd_s->createElement('span',htmlspecialchars($seloptv2))); 
                              $radiolab->setAttribute('class','input-label');
                              $radiolab->setAttribute('valign-b','');
//                               $ronclick='{document.getElementById("'.$zid.'_'.$cradio.'").click(); document.getElementById("'.$zid.'").value=document.getElementById("'.$zid.'_'.$cradio.'").value;}';
                              $radiolab->setAttribute('onclick',$ronclick);
//                          {document.getElementById(&quot;visita3&quot;).click();}
                    }
                    
                    

               } 
          } 


     $result=$element->appendChild($domd_s->createElement("result",""));   
          $result->setAttribute("id",$zid.'_r');
          $result->setAttribute("style","display:none;");

if(empty($zdom))
{
//      if($zxml==1){$zxml=$domd_s->saveXML();}
//      else{echo $domd_s->saveXML();}
     if($zxml==1){$zxml=$domd_s->saveHTML();}
     else{echo $domd_s->saveHTML();}
}     

// echo '===='.$zwidth;

// if(empty($znoreset))
{include ('ele_reset.php');}
?>